@Test public void create_target_profile_with_same_parent_than_source() { // two profiles : parent and its child db.qualityProfileDao() .insert(dbSession, QProfileTesting.newXooP2().setParentKee(QProfileTesting.XOO_P1_KEY)); // parent and child with x1 activated RuleActivation activation = new RuleActivation(RuleTesting.XOO_X1); activation.setSeverity(Severity.BLOCKER); activation.setParameter("max", "7"); ruleActivator.activate(dbSession, activation, QProfileTesting.XOO_P1_KEY); dbSession.commit(); dbSession.clearCache(); // copy child -> profile2 is created with parent P1 copier.copyToName(QProfileTesting.XOO_P1_KEY, QProfileTesting.XOO_P2_NAME.getName()); verifyOneActiveRule( QProfileTesting.XOO_P2_KEY, Severity.BLOCKER, ActiveRuleDto.INHERITED, ImmutableMap.of("max", "7")); QualityProfileDto profile2Dto = db.qualityProfileDao().selectByKey(dbSession, QProfileTesting.XOO_P2_KEY); assertThat(profile2Dto.getParentKee()).isEqualTo(QProfileTesting.XOO_P1_KEY); }
@Test public void create() { QualityProfileDto dto = factory.create(dbSession, new QProfileName("xoo", "P1")); dbSession.commit(); dbSession.clearCache(); assertThat(dto.getKey()).startsWith("xoo-p1-"); assertThat(dto.getName()).isEqualTo("P1"); assertThat(dto.getLanguage()).isEqualTo("xoo"); assertThat(dto.getId()).isNotNull(); // reload the dto dto = db.qualityProfileDao().selectByNameAndLanguage("P1", "xoo", dbSession); assertThat(dto.getLanguage()).isEqualTo("xoo"); assertThat(dto.getName()).isEqualTo("P1"); assertThat(dto.getKey()).startsWith("xoo-p1"); assertThat(dto.getId()).isNotNull(); assertThat(dto.getParentKee()).isNull(); assertThat(db.qualityProfileDao().selectAll(dbSession)).hasSize(1); }