*/
package org.sonar.server.db.migrations;
+import com.google.common.collect.ImmutableList;
import org.sonar.server.db.migrations.violation.ViolationMigration;
+import java.util.List;
+
public interface DatabaseMigrations {
- Class<? extends DatabaseMigration>[] CLASSES = new Class[]{
+ List<Class<? extends DatabaseMigration>> CLASSES = ImmutableList.<Class<? extends DatabaseMigration>>of(
ViolationMigration.class
- };
+ );
+
}
return totalViolations;
}
- @CheckForNull
Long[] pollGroupOfViolationIds() {
long[] longs = groupsOfViolationIds.poll();
if (longs == null) {
- return null;
+ return new Long[0];
}
Long[] objects = new Long[longs.length];
for (int i = 0; i < longs.length; i++) {
- objects[i] = new Long(longs[i]);
+ objects[i] = Long.valueOf(longs[i]);
}
return objects;
}
private Queue<long[]> initGroupOfViolationIds(Database database) throws SQLException {
Connection connection = database.getDataSource().getConnection();
- connection.setAutoCommit(false);
Statement stmt = null;
ResultSet rs = null;
try {
+ connection.setAutoCommit(false);
stmt = connection.createStatement();
stmt.setFetchSize(10000);
rs = stmt.executeQuery("select id from rule_failures");
// -- delete violations
Long[] violationIds = referentials.pollGroupOfViolationIds();
- while (violationIds != null) {
+ while (violationIds.length>0) {
List<Map<String, Object>> rows = selectRows(violationIds);
convert(rows, violationIds);
for (NotificationDispatcherMetadata metadata : dispatchersMetadata) {
String dispatcherKey = metadata.getDispatcherKey();
String value = metadata.getProperty(propertyKey);
- if (value != null) {
- if (propertyValue == null || value.equals(propertyValue)) {
+ if (value != null && (propertyValue == null || value.equals(propertyValue))) {
keys.add(dispatcherKey);
- }
}
}
return keys;
assertThat(file.exists(), is(true));
}
- public static void assertSimilarXml(String expectedXml, String xml) throws IOException, SAXException {
+ public static void assertSimilarXml(String expectedXml, String xml) throws Exception {
Diff diff = isSimilarXml(expectedXml, xml);
String message = "Diff: " + diff.toString() + CharUtils.LF + "XML: " + xml;
assertTrue(message, diff.similar());
}
- static Diff isSimilarXml(String expectedXml, String xml) throws IOException, SAXException {
+ static Diff isSimilarXml(String expectedXml, String xml) throws Exception {
XMLUnit.setIgnoreWhitespace(true);
return XMLUnit.compareXML(xml, expectedXml);
}