import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
+import java.io.Serializable;
import java.io.StringReader;
import java.util.Collections;
import java.util.Comparator;
}
@VisibleForTesting
- static class DuplicationComparator implements Comparator<Duplication> {
+ static class DuplicationComparator implements Comparator<Duplication>, Serializable {
private static final long serialVersionUID = 1;
private final ComponentDto component;
}
}
- private static class BlockComparator implements Comparator<Block> {
+ private static class BlockComparator implements Comparator<Block>, Serializable {
private static final long serialVersionUID = 1;
@Override
private final String name, severity, internalKey, language;
private final Map<String, String> params = new HashMap<String, String>();
- public ActiveRule(String repositoryKey, String ruleKey, String name, String severity, @Nullable String internalKey, String language) {
+ public ActiveRule(String repositoryKey, String ruleKey, String name, @Nullable String severity, @Nullable String internalKey, @Nullable String language) {
this.repositoryKey = repositoryKey;
this.ruleKey = ruleKey;
this.name = name;
return name;
}
+ /**
+ * Is null on manual rules
+ */
+ @CheckForNull
public String severity() {
return severity;
}
+ /**
+ * Is null on manual rules
+ */
+ @CheckForNull
public String language() {
return language;
}
*/
package org.sonar.core.user;
+import com.google.common.base.Strings;
import org.apache.ibatis.session.SqlSession;
import org.sonar.api.BatchComponent;
import org.sonar.api.ServerComponent;
SqlSession session = mybatis.openSession(false);
try {
// Hack in order to set "." on DEV
- if (resourceDto.getModuleUuidPath() == null || resourceDto.getModuleUuidPath().isEmpty()) {
+ if (Strings.isNullOrEmpty(resourceDto.getModuleUuidPath())) {
resourceDto.setModuleUuidPath(ComponentDto.MODULE_UUID_PATH_SEP);
}
resourceDao.insertUsingExistingSession(resourceDto, session);
setupData("shouldInsertAuthorAndDeveloper");
String login = "developer@company.net";
- ResourceDto resourceDto = new ResourceDto().setName(login).setQualifier("DEV").setUuid("ABCD").setProjectUuid("ABCD");
+ ResourceDto resourceDto = new ResourceDto().setName(login).setQualifier("DEV").setUuid("ABCD").setProjectUuid("ABCD").setModuleUuidPath(".");
dao.insertAuthorAndDeveloper(login, resourceDto);
checkTables("shouldInsertAuthorAndDeveloper",
"authors", "projects");
}
+ @Test
+ public void add_missing_module_uuid_path() throws Exception {
+ setupData("add_missing_module_uuid_path");
+
+ dao.insertAuthorAndDeveloper("developer@company.net", new ResourceDto().setName("developer@company.net").setQualifier("DEV").setUuid("ABCD").setProjectUuid("ABCD")
+ .setModuleUuidPath(""));
+ dao.insertAuthorAndDeveloper("developer2@company.net", new ResourceDto().setName("developer2@company.net").setQualifier("DEV").setUuid("BCDE").setProjectUuid("BCDE"));
+
+ checkTables("add_missing_module_uuid_path",
+ new String[] {"created_at", "updated_at", "copy_resource_id", "description", "enabled", "kee", "deprecated_kee", "path", "language", "long_name", "person_id", "root_id",
+ "scope", "authorization_updated_at"},
+ "authors", "projects");
+ }
+
@Test
public void shouldPreventAuthorsDuplication() {
setupData("shouldPreventAuthorsDuplication");
--- /dev/null
+<dataset>
+ <projects id="1" name="developer@company.net" qualifier="DEV" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="."/>
+ <authors id="1" person_id="1" login="developer@company.net"/>
+
+ <projects id="2" name="developer2@company.net" qualifier="DEV" uuid="BCDE" project_uuid="BCDE" module_uuid="[null]" module_uuid_path="."/>
+ <authors id="2" person_id="2" login="developer2@company.net"/>
+</dataset>
--- /dev/null
+<dataset>
+</dataset>