private void checkSizeOfTables() { assertThat(db.countRowsOfTable("organizations")).isEqualTo(1); assertThat(db.countRowsOfTable("groups")).isEqualTo(0); assertThat(db.countRowsOfTable("groups_users")).isEqualTo(0); assertThat(db.countRowsOfTable("permission_templates")).isEqualTo(0); assertThat(db.countRowsOfTable("perm_templates_users")).isEqualTo(0); assertThat(db.countRowsOfTable("perm_templates_groups")).isEqualTo(0); }
@Test public void clear_db() { dbTester.prepareDbUnit(getClass(), "shared.xml"); underTest.clearDb(); assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(0); assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(0); assertThat(dbTester.countRowsOfTable("rules")).isEqualTo(0); assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(0); }
@Test public void shouldDeleteIssuesAndIssueChanges() { dbTester.prepareDbUnit(getClass(), "shouldDeleteResource.xml"); PurgeCommands purgeCommands = new PurgeCommands(dbTester.getSession(), profiler); purgeCommands.deleteIssues("uuid_1"); assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(1); assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(1); assertThat(dbTester.countRowsOfTable("events")).isEqualTo(3); assertThat(dbTester.countRowsOfTable("issues")).isZero(); assertThat(dbTester.countRowsOfTable("issue_changes")).isZero(); }
@Test public void mass_insert() { execute(new BigRepository()); assertThat(db.countRowsOfTable("rules")).isEqualTo(BigRepository.SIZE); assertThat(db.countRowsOfTable("rules_parameters")).isEqualTo(BigRepository.SIZE * 20); assertThat(es.getIds(RuleIndexDefinition.INDEX_TYPE_RULE)).hasSize(BigRepository.SIZE); }
@Test public void delete_project_and_associated_data() { db.prepareDbUnit(getClass(), "shouldDeleteProject.xml"); underTest.deleteProject(dbSession, "A"); dbSession.commit(); assertThat(db.countRowsOfTable("projects")).isZero(); assertThat(db.countRowsOfTable("snapshots")).isZero(); assertThat(db.countRowsOfTable("issues")).isZero(); assertThat(db.countRowsOfTable("issue_changes")).isZero(); assertThat(db.countRowsOfTable("file_sources")).isZero(); }
@Test public void deleteByUuids() { insertData(A_UUID); assertThat(dbTester.countRowsOfTable(TABLE_NAME)).isEqualTo(1); underTest.deleteByUuids(dbTester.getSession(), singleton(A_UUID)); dbTester.commit(); assertThat(dbTester.countRowsOfTable(TABLE_NAME)).isEqualTo(0); }
@Test public void insert_as_clob() { AnalysisPropertyDto analysisPropertyDto = insertAnalysisPropertyDto(4000 + random.nextInt(100)); assertThat(dbTester.countRowsOfTable(dbSession, "ANALYSIS_PROPERTIES")).isEqualTo(1); compareFirstValueWith(analysisPropertyDto); }
@Test public void deleteRulesProfilesByUuids_does_nothing_if_specified_uuid_does_not_exist() { insertRulesProfile(); underTest.deleteRulesProfilesByUuids(dbSession, asList("does_not_exist")); assertThat(db.countRowsOfTable(dbSession, "rules_profiles")).isEqualTo(1); }
@Test public void insert_as_empty() { AnalysisPropertyDto analysisPropertyDto = insertAnalysisPropertyDto(0); assertThat(dbTester.countRowsOfTable(dbSession, "ANALYSIS_PROPERTIES")).isEqualTo(1); compareFirstValueWith(analysisPropertyDto); }
@Test public void deleteByIds_does_nothing_if_empty_list_of_ids() { underTest.insert(dbSession, newRow(profile1, rule1)); underTest.deleteByIds(dbSession, emptyList()); assertThat(db.countRowsOfTable(dbSession, "active_rules")).isEqualTo(1); }
@Test public void insert_core_metrics() { RegisterMetrics register = new RegisterMetrics(dbClient); register.start(); assertThat(dbTester.countRowsOfTable("metrics")).isEqualTo(CoreMetrics.getMetrics().size()); }
@Test public void do_nothing_if_input_components_are_empty() { List<QGChangeEvent> result = run(emptyList(), newIncrementalFormula()); assertThat(db.countRowsOfTable(db.getSession(), "live_measures")).isEqualTo(0); assertThatProjectNotChanged(result, project); }
@Test public void nothing_to_persist_when_no_cpd_text_blocks_in_report() { when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true); reportReader.putDuplicationBlocks(FILE_1_REF, Collections.emptyList()); TestComputationStepContext context = new TestComputationStepContext(); underTest.execute(context); assertThat(dbTester.countRowsOfTable("duplications_index")).isEqualTo(0); context.getStatistics().assertValue("inserts", 0); }
@Test public void deletePermissions_deletes_permissions_of_public_project() { OrganizationDto organization = dbTester.organizations().insert(); ComponentDto project = dbTester.components().insertPublicProject(organization); addPermissions(organization, project); PurgeCommands purgeCommands = new PurgeCommands(dbTester.getSession(), profiler); purgeCommands.deletePermissions(project.getId()); assertThat(dbTester.countRowsOfTable("group_roles")).isEqualTo(2); assertThat(dbTester.countRowsOfTable("user_roles")).isEqualTo(1); }
@Test public void do_nothing_if_project_has_not_been_analyzed() { // project has no snapshots List<QGChangeEvent> result = run(file1, newIncrementalFormula()); assertThat(db.countRowsOfTable(db.getSession(), "live_measures")).isEqualTo(0); assertThatProjectNotChanged(result, project); }
@Test public void delete_view_and_child() { db.prepareDbUnit(getClass(), "view_sub_view_and_tech_project.xml"); underTest.deleteProject(dbSession, "A"); dbSession.commit(); assertThat(db.countSql("select count(1) from projects where uuid='A'")).isZero(); assertThat(db.countRowsOfTable("projects")).isZero(); }
@Test public void delete() { IssueDto issue = db.issues().insertIssue(); IssueChangeDto issueChange1 = db.issues().insertChange(issue); IssueChangeDto issueChange2 = db.issues().insertChange(issue); assertThat(underTest.delete(db.getSession(), issueChange1.getKey())).isTrue(); assertThat(db.countRowsOfTable(db.getSession(), "issue_changes")).isEqualTo(1); }
@Test public void delete_branches() { OrganizationDto organization = db.organizations().insert(); ComponentDto project = db.components().insertMainBranch(organization); ComponentDto branch = db.components().insertProjectBranch(project); logInAsAdministrator(organization); sendRequest(organization); verifyOrganizationDoesNotExist(organization); assertThat(db.countRowsOfTable(db.getSession(), "projects")).isZero(); assertThat(db.countRowsOfTable(db.getSession(), "project_branches")).isZero(); verify(projectLifeCycleListeners).onProjectsDeleted(ImmutableSet.of(Project.from(project))); }
@Test public void deleteByIds() { ActiveRuleDto ar1 = underTest.insert(dbSession, newRow(profile1, rule1)); ActiveRuleDto ar2 = underTest.insert(dbSession, newRow(profile1, rule2)); ActiveRuleDto ar3 = underTest.insert(dbSession, newRow(profile2, rule1)); underTest.deleteByIds(dbSession, asList(ar1.getId(), ar3.getId())); assertThat(db.countRowsOfTable(dbSession, "active_rules")).isEqualTo(1); assertThat(underTest.selectByProfile(dbSession, profile1)) .extracting(ActiveRuleDto::getId) .containsExactly(ar2.getId()); }
@Test public void delete() { ComponentDto project = db.components().insertPrivateProject(); ProjectLinkDto link = db.componentLinks().insertProvidedLink(project); underTest.delete(db.getSession(), link.getUuid()); db.getSession().commit(); assertThat(db.countRowsOfTable("project_links")).isEqualTo(0); }