even if the registry do not contains the QualityProfile. BuiltInQProfileRepository must not be used because
the plugin may have been uninstalled and when reinstalled this may break the contract.
QProfileDto profileInOrg2 = dbTester.qualityProfiles().insert(org2, p -> p.setLanguage("java"));
dbTester.qualityProfiles().setAsDefault(profileInOrg1);
- //assertThat(underTest.selectUuidsOfOrganizationsWithoutDefaultProfile(dbSession, "java")).containsExactly(org2.getUuid());
- assertThat(underTest.selectUuidsOfOrganizationsWithoutDefaultProfile(dbSession, "js")).containsExactlyInAnyOrder(org1.getUuid(), org2.getUuid());
+ assertThat(underTest.selectUuidsOfOrganizationsWithoutDefaultProfile(dbSession, "java"))
+ .containsExactly(org2.getUuid());
+ assertThat(underTest.selectUuidsOfOrganizationsWithoutDefaultProfile(dbSession, "js"))
+ .containsExactlyInAnyOrder(org1.getUuid(), org2.getUuid());
}
private void assertThatIsDefault(OrganizationDto org, QProfileDto profile) {
QProfileName name = new QProfileName(rulesProfile.getLanguage(), rulesProfile.getName());
BuiltInQProfile builtIn = builtInsPerName.get(name);
- if (builtIn != null && builtIn.isDefault()) {
+ if (builtIn == null || builtIn.isDefault()) {
+ // If builtIn == null, the plugin has been removed
// rows of table default_qprofiles must be inserted after org_qprofiles
// in order to benefit from batch SQL inserts
defaults.add(new DefaultQProfileDto()
.setQProfileUuid(dto.getUuid())
.setOrganizationUuid(organization.getUuid())
- .setLanguage(builtIn.getLanguage()));
+ .setLanguage(rulesProfile.getLanguage()));
}
dbClient.qualityProfileDao().insert(batchDbSession, dto);
}
}
- @Test
- public void create_fails_with_ISE_if_BuiltInQProfileRepository_has_not_been_initialized() throws OrganizationUpdater.KeyConflictException {
- UserDto user = db.users().insertUser();
- db.qualityGates().insertBuiltInQualityGate();
-
- expectedException.expect(IllegalStateException.class);
- expectedException.expectMessage("initialize must be called first");
-
- underTest.create(dbSession, user, FULL_POPULATED_NEW_ORGANIZATION);
- }
-
@Test
public void create_fails_with_KeyConflictException_if_org_with_key_in_NewOrganization_arg_already_exists_in_db() throws OrganizationUpdater.KeyConflictException {
db.organizations().insertForKey(FULL_POPULATED_NEW_ORGANIZATION.getKey());