diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-07-16 21:41:03 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-07-16 21:41:03 +0200 |
commit | 57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27 (patch) | |
tree | 316a18fb54f71039b89ea405915a397018ce8cb8 /sonar-db | |
parent | 97e740133e533f623b6a0bc774dda3804d8df62f (diff) | |
download | sonarqube-57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27.tar.gz sonarqube-57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27.zip |
Rename variables "sut" to "underTest" in tests
Diffstat (limited to 'sonar-db')
11 files changed, 228 insertions, 229 deletions
diff --git a/sonar-db/src/test/java/org/sonar/db/activity/ActivityDaoTest.java b/sonar-db/src/test/java/org/sonar/db/activity/ActivityDaoTest.java index c2135f6e3ac..13406d5be9e 100644 --- a/sonar-db/src/test/java/org/sonar/db/activity/ActivityDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/activity/ActivityDaoTest.java @@ -39,7 +39,7 @@ public class ActivityDaoTest { @Rule public DbTester dbTester = DbTester.create(system); - ActivityDao sut = dbTester.getDbClient().activityDao(); + ActivityDao underTest = dbTester.getDbClient().activityDao(); @Test public void insert() { @@ -47,7 +47,7 @@ public class ActivityDaoTest { ActivityDto dto = new ActivityDto() .setKey("UUID_1").setAction("THE_ACTION").setType("THE_TYPE") .setAuthor("THE_AUTHOR").setData("THE_DATA"); - sut.insert(dto); + underTest.insert(dto); Map<String, Object> map = dbTester.selectFirst("select created_at as \"createdAt\", log_action as \"action\", data_field as \"data\" from activities where log_key='UUID_1'"); assertThat(map.get("action")).isEqualTo("THE_ACTION"); diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java index b1e97c6ea72..dde4347b69c 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java @@ -45,13 +45,13 @@ public class ComponentDaoTest { @Rule public DbTester db = DbTester.create(System2.INSTANCE); - ComponentDao sut = new ComponentDao(); + ComponentDao underTest = new ComponentDao(); @Test public void get_by_uuid() { db.prepareDbUnit(getClass(), "shared.xml"); - ComponentDto result = sut.selectByUuid(db.getSession(), "KLMN").get(); + ComponentDto result = underTest.selectByUuid(db.getSession(), "KLMN").get(); assertThat(result).isNotNull(); assertThat(result.uuid()).isEqualTo("KLMN"); assertThat(result.moduleUuid()).isEqualTo("EFGH"); @@ -67,14 +67,14 @@ public class ComponentDaoTest { assertThat(result.language()).isEqualTo("java"); assertThat(result.getCopyResourceId()).isNull(); - assertThat(sut.selectByUuid(db.getSession(), "UNKNOWN")).isAbsent(); + assertThat(underTest.selectByUuid(db.getSession(), "UNKNOWN")).isAbsent(); } @Test public void get_by_uuid_on_technical_project_copy() { db.prepareDbUnit(getClass(), "shared.xml"); - ComponentDto result = sut.selectByUuid(db.getSession(), "STUV").get(); + ComponentDto result = underTest.selectByUuid(db.getSession(), "STUV").get(); assertThat(result).isNotNull(); assertThat(result.uuid()).isEqualTo("STUV"); assertThat(result.moduleUuid()).isEqualTo("OPQR"); @@ -95,7 +95,7 @@ public class ComponentDaoTest { public void get_by_uuid_on_disabled_component() { db.prepareDbUnit(getClass(), "shared.xml"); - ComponentDto result = sut.selectByUuid(db.getSession(), "DCBA").get(); + ComponentDto result = underTest.selectByUuid(db.getSession(), "DCBA").get(); assertThat(result).isNotNull(); assertThat(result.isEnabled()).isFalse(); } @@ -106,14 +106,14 @@ public class ComponentDaoTest { db.prepareDbUnit(getClass(), "shared.xml"); - sut.selectNonNullByUuid(db.getSession(), "unknown"); + underTest.selectNonNullByUuid(db.getSession(), "unknown"); } @Test public void get_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - Optional<ComponentDto> optional = sut.selectByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java"); + Optional<ComponentDto> optional = underTest.selectByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java"); assertThat(optional).isPresent(); ComponentDto result = optional.get(); @@ -126,7 +126,7 @@ public class ComponentDaoTest { assertThat(result.language()).isEqualTo("java"); assertThat(result.parentProjectId()).isEqualTo(2); - assertThat(sut.selectByKey(db.getSession(), "unknown")).isAbsent(); + assertThat(underTest.selectByKey(db.getSession(), "unknown")).isAbsent(); } @Test @@ -135,14 +135,14 @@ public class ComponentDaoTest { db.prepareDbUnit(getClass(), "shared.xml"); - sut.selectNonNullByKey(db.getSession(), "unknown"); + underTest.selectNonNullByKey(db.getSession(), "unknown"); } @Test public void get_by_key_on_disabled_component() { db.prepareDbUnit(getClass(), "shared.xml"); - ComponentDto result = sut.selectNonNullByKey(db.getSession(), "org.disabled.project"); + ComponentDto result = underTest.selectNonNullByKey(db.getSession(), "org.disabled.project"); assertThat(result.isEnabled()).isFalse(); } @@ -150,7 +150,7 @@ public class ComponentDaoTest { public void get_by_key_on_a_root_project() { db.prepareDbUnit(getClass(), "shared.xml"); - ComponentDto result = sut.selectNonNullByKey(db.getSession(), "org.struts:struts"); + ComponentDto result = underTest.selectNonNullByKey(db.getSession(), "org.struts:struts"); assertThat(result.key()).isEqualTo("org.struts:struts"); assertThat(result.deprecatedKey()).isEqualTo("org.struts:struts"); assertThat(result.path()).isNull(); @@ -168,7 +168,7 @@ public class ComponentDaoTest { public void get_by_keys() { db.prepareDbUnit(getClass(), "shared.xml"); - List<ComponentDto> results = sut.selectByKeys(db.getSession(), Collections.singletonList("org.struts:struts-core:src/org/struts/RequestContext.java")); + List<ComponentDto> results = underTest.selectByKeys(db.getSession(), Collections.singletonList("org.struts:struts-core:src/org/struts/RequestContext.java")); assertThat(results).hasSize(1); ComponentDto result = results.get(0); @@ -182,14 +182,14 @@ public class ComponentDaoTest { assertThat(result.language()).isEqualTo("java"); assertThat(result.parentProjectId()).isEqualTo(2); - assertThat(sut.selectByKeys(db.getSession(), Collections.singletonList("unknown"))).isEmpty(); + assertThat(underTest.selectByKeys(db.getSession(), Collections.singletonList("unknown"))).isEmpty(); } @Test public void get_by_ids() { db.prepareDbUnit(getClass(), "shared.xml"); - List<ComponentDto> results = sut.selectByIds(db.getSession(), newArrayList(4L)); + List<ComponentDto> results = underTest.selectByIds(db.getSession(), newArrayList(4L)); assertThat(results).hasSize(1); ComponentDto result = results.get(0); @@ -203,14 +203,14 @@ public class ComponentDaoTest { assertThat(result.language()).isEqualTo("java"); assertThat(result.parentProjectId()).isEqualTo(2); - assertThat(sut.selectByIds(db.getSession(), newArrayList(555L))).isEmpty(); + assertThat(underTest.selectByIds(db.getSession(), newArrayList(555L))).isEmpty(); } @Test public void get_by_uuids() { db.prepareDbUnit(getClass(), "shared.xml"); - List<ComponentDto> results = sut.selectByUuids(db.getSession(), newArrayList("KLMN")); + List<ComponentDto> results = underTest.selectByUuids(db.getSession(), newArrayList("KLMN")); assertThat(results).hasSize(1); ComponentDto result = results.get(0); @@ -228,14 +228,14 @@ public class ComponentDaoTest { assertThat(result.scope()).isEqualTo("FIL"); assertThat(result.language()).isEqualTo("java"); - assertThat(sut.selectByUuids(db.getSession(), newArrayList("unknown"))).isEmpty(); + assertThat(underTest.selectByUuids(db.getSession(), newArrayList("unknown"))).isEmpty(); } @Test public void get_by_uuids_on_removed_components() { db.prepareDbUnit(getClass(), "shared.xml"); - List<ComponentDto> results = sut.selectByUuids(db.getSession(), newArrayList("DCBA")); + List<ComponentDto> results = underTest.selectByUuids(db.getSession(), newArrayList("DCBA")); assertThat(results).hasSize(1); ComponentDto result = results.get(0); @@ -247,25 +247,25 @@ public class ComponentDaoTest { public void select_existing_uuids() { db.prepareDbUnit(getClass(), "shared.xml"); - List<String> results = sut.selectExistingUuids(db.getSession(), newArrayList("KLMN")); + List<String> results = underTest.selectExistingUuids(db.getSession(), newArrayList("KLMN")); assertThat(results).containsOnly("KLMN"); - assertThat(sut.selectExistingUuids(db.getSession(), newArrayList("KLMN", "unknown"))).hasSize(1); - assertThat(sut.selectExistingUuids(db.getSession(), newArrayList("unknown"))).isEmpty(); + assertThat(underTest.selectExistingUuids(db.getSession(), newArrayList("KLMN", "unknown"))).hasSize(1); + assertThat(underTest.selectExistingUuids(db.getSession(), newArrayList("unknown"))).isEmpty(); } @Test public void get_by_id() { db.prepareDbUnit(getClass(), "shared.xml"); - assertThat(sut.selectNonNullById(db.getSession(), 4L)).isNotNull(); + assertThat(underTest.selectNonNullById(db.getSession(), 4L)).isNotNull(); } @Test public void get_by_id_on_disabled_component() { db.prepareDbUnit(getClass(), "shared.xml"); - Optional<ComponentDto> result = sut.selectById(db.getSession(), 10L); + Optional<ComponentDto> result = underTest.selectById(db.getSession(), 10L); assertThat(result).isPresent(); assertThat(result.get().isEnabled()).isFalse(); } @@ -274,23 +274,23 @@ public class ComponentDaoTest { public void fail_to_get_by_id_when_project_not_found() { db.prepareDbUnit(getClass(), "shared.xml"); - sut.selectNonNullById(db.getSession(), 111L); + underTest.selectNonNullById(db.getSession(), 111L); } @Test public void get_nullable_by_id() { db.prepareDbUnit(getClass(), "shared.xml"); - assertThat(sut.selectById(db.getSession(), 4L)).isPresent(); - assertThat(sut.selectById(db.getSession(), 111L)).isAbsent(); + assertThat(underTest.selectById(db.getSession(), 4L)).isPresent(); + assertThat(underTest.selectById(db.getSession(), 111L)).isAbsent(); } @Test public void count_by_id() { db.prepareDbUnit(getClass(), "shared.xml"); - assertThat(sut.existsById(4L, db.getSession())).isTrue(); - assertThat(sut.existsById(111L, db.getSession())).isFalse(); + assertThat(underTest.existsById(4L, db.getSession())).isTrue(); + assertThat(underTest.existsById(111L, db.getSession())).isFalse(); } @Test @@ -298,34 +298,34 @@ public class ComponentDaoTest { db.prepareDbUnit(getClass(), "multi-modules.xml"); // Sub project of a file - List<ComponentDto> results = sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("HIJK")); + List<ComponentDto> results = underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("HIJK")); assertThat(results).hasSize(1); assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts-data"); // Sub project of a directory - results = sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("GHIJ")); + results = underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("GHIJ")); assertThat(results).hasSize(1); assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts-data"); // Sub project of a sub module - results = sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("FGHI")); + results = underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("FGHI")); assertThat(results).hasSize(1); assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts"); // Sub project of a module - results = sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("EFGH")); + results = underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("EFGH")); assertThat(results).hasSize(1); assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts"); // Sub project of a project - assertThat(sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("ABCD"))).isEmpty(); + assertThat(underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("ABCD"))).isEmpty(); // SUb projects of a component and a sub module - assertThat(sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("HIJK", "FGHI"))).hasSize(2); + assertThat(underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("HIJK", "FGHI"))).hasSize(2); - assertThat(sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("unknown"))).isEmpty(); + assertThat(underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("unknown"))).isEmpty(); - assertThat(sut.selectSubProjectsByComponentUuids(db.getSession(), Collections.<String>emptyList())).isEmpty(); + assertThat(underTest.selectSubProjectsByComponentUuids(db.getSession(), Collections.<String>emptyList())).isEmpty(); } @Test @@ -333,20 +333,20 @@ public class ComponentDaoTest { db.prepareDbUnit(getClass(), "multi-modules.xml"); // From root project - List<ComponentDto> modules = sut.selectEnabledDescendantModules(db.getSession(), "ABCD"); + List<ComponentDto> modules = underTest.selectEnabledDescendantModules(db.getSession(), "ABCD"); assertThat(modules).extracting("uuid").containsOnly("ABCD", "EFGH", "FGHI"); // From module - modules = sut.selectEnabledDescendantModules(db.getSession(), "EFGH"); + modules = underTest.selectEnabledDescendantModules(db.getSession(), "EFGH"); assertThat(modules).extracting("uuid").containsOnly("EFGH", "FGHI"); // From sub module - modules = sut.selectEnabledDescendantModules(db.getSession(), "FGHI"); + modules = underTest.selectEnabledDescendantModules(db.getSession(), "FGHI"); assertThat(modules).extracting("uuid").containsOnly("FGHI"); // Folder - assertThat(sut.selectEnabledDescendantModules(db.getSession(), "GHIJ")).isEmpty(); - assertThat(sut.selectEnabledDescendantModules(db.getSession(), "unknown")).isEmpty(); + assertThat(underTest.selectEnabledDescendantModules(db.getSession(), "GHIJ")).isEmpty(); + assertThat(underTest.selectEnabledDescendantModules(db.getSession(), "unknown")).isEmpty(); } @Test @@ -354,15 +354,15 @@ public class ComponentDaoTest { db.prepareDbUnit(getClass(), "multi-modules.xml"); // From root project, disabled sub module is returned - List<ComponentDto> modules = sut.selectDescendantModules(db.getSession(), "ABCD"); + List<ComponentDto> modules = underTest.selectDescendantModules(db.getSession(), "ABCD"); assertThat(modules).extracting("uuid").containsOnly("ABCD", "EFGH", "FGHI", "IHGF"); // From module, disabled sub module is returned - modules = sut.selectDescendantModules(db.getSession(), "EFGH"); + modules = underTest.selectDescendantModules(db.getSession(), "EFGH"); assertThat(modules).extracting("uuid").containsOnly("EFGH", "FGHI", "IHGF"); // From removed sub module -> should not be returned - assertThat(sut.selectDescendantModules(db.getSession(), "IHGF")).isEmpty(); + assertThat(underTest.selectDescendantModules(db.getSession(), "IHGF")).isEmpty(); } @Test @@ -370,30 +370,30 @@ public class ComponentDaoTest { db.prepareDbUnit(getClass(), "select_module_files_tree.xml"); // From root project - List<FilePathWithHashDto> files = sut.selectEnabledDescendantFiles(db.getSession(), "ABCD"); + List<FilePathWithHashDto> files = underTest.selectEnabledDescendantFiles(db.getSession(), "ABCD"); assertThat(files).extracting("uuid").containsOnly("EFGHI", "HIJK"); assertThat(files).extracting("moduleUuid").containsOnly("EFGH", "FGHI"); assertThat(files).extracting("srcHash").containsOnly("srcEFGHI", "srcHIJK"); assertThat(files).extracting("path").containsOnly("src/org/struts/pom.xml", "src/org/struts/RequestContext.java"); // From module - files = sut.selectEnabledDescendantFiles(db.getSession(), "EFGH"); + files = underTest.selectEnabledDescendantFiles(db.getSession(), "EFGH"); assertThat(files).extracting("uuid").containsOnly("EFGHI", "HIJK"); assertThat(files).extracting("moduleUuid").containsOnly("EFGH", "FGHI"); assertThat(files).extracting("srcHash").containsOnly("srcEFGHI", "srcHIJK"); assertThat(files).extracting("path").containsOnly("src/org/struts/pom.xml", "src/org/struts/RequestContext.java"); // From sub module - files = sut.selectEnabledDescendantFiles(db.getSession(), "FGHI"); + files = underTest.selectEnabledDescendantFiles(db.getSession(), "FGHI"); assertThat(files).extracting("uuid").containsOnly("HIJK"); assertThat(files).extracting("moduleUuid").containsOnly("FGHI"); assertThat(files).extracting("srcHash").containsOnly("srcHIJK"); assertThat(files).extracting("path").containsOnly("src/org/struts/RequestContext.java"); // From directory - assertThat(sut.selectEnabledDescendantFiles(db.getSession(), "GHIJ")).isEmpty(); + assertThat(underTest.selectEnabledDescendantFiles(db.getSession(), "GHIJ")).isEmpty(); - assertThat(sut.selectEnabledDescendantFiles(db.getSession(), "unknown")).isEmpty(); + assertThat(underTest.selectEnabledDescendantFiles(db.getSession(), "unknown")).isEmpty(); } @Test @@ -401,69 +401,69 @@ public class ComponentDaoTest { db.prepareDbUnit(getClass(), "select_module_files_tree.xml"); // From root project - List<FilePathWithHashDto> files = sut.selectEnabledFilesFromProject(db.getSession(), "ABCD"); + List<FilePathWithHashDto> files = underTest.selectEnabledFilesFromProject(db.getSession(), "ABCD"); assertThat(files).extracting("uuid").containsOnly("EFGHI", "HIJK"); assertThat(files).extracting("moduleUuid").containsOnly("EFGH", "FGHI"); assertThat(files).extracting("srcHash").containsOnly("srcEFGHI", "srcHIJK"); assertThat(files).extracting("path").containsOnly("src/org/struts/pom.xml", "src/org/struts/RequestContext.java"); // From module - assertThat(sut.selectEnabledFilesFromProject(db.getSession(), "EFGH")).isEmpty(); + assertThat(underTest.selectEnabledFilesFromProject(db.getSession(), "EFGH")).isEmpty(); // From sub module - assertThat(sut.selectEnabledFilesFromProject(db.getSession(), "FGHI")).isEmpty(); + assertThat(underTest.selectEnabledFilesFromProject(db.getSession(), "FGHI")).isEmpty(); // From directory - assertThat(sut.selectEnabledFilesFromProject(db.getSession(), "GHIJ")).isEmpty(); + assertThat(underTest.selectEnabledFilesFromProject(db.getSession(), "GHIJ")).isEmpty(); - assertThat(sut.selectEnabledFilesFromProject(db.getSession(), "unknown")).isEmpty(); + assertThat(underTest.selectEnabledFilesFromProject(db.getSession(), "unknown")).isEmpty(); } @Test public void select_all_components_from_project() { db.prepareDbUnit(getClass(), "multi-modules.xml"); - List<ComponentDto> components = sut.selectAllComponentsFromProjectKey(db.getSession(), "org.struts:struts"); + List<ComponentDto> components = underTest.selectAllComponentsFromProjectKey(db.getSession(), "org.struts:struts"); // Removed components are included assertThat(components).hasSize(8); - assertThat(sut.selectAllComponentsFromProjectKey(db.getSession(), "UNKNOWN")).isEmpty(); + assertThat(underTest.selectAllComponentsFromProjectKey(db.getSession(), "UNKNOWN")).isEmpty(); } @Test public void select_modules_from_project() { db.prepareDbUnit(getClass(), "multi-modules.xml"); - List<ComponentDto> components = sut.selectEnabledModulesFromProjectKey(db.getSession(), "org.struts:struts"); + List<ComponentDto> components = underTest.selectEnabledModulesFromProjectKey(db.getSession(), "org.struts:struts"); assertThat(components).hasSize(3); - assertThat(sut.selectEnabledModulesFromProjectKey(db.getSession(), "UNKNOWN")).isEmpty(); + assertThat(underTest.selectEnabledModulesFromProjectKey(db.getSession(), "UNKNOWN")).isEmpty(); } @Test public void select_views_and_sub_views() { db.prepareDbUnit(getClass(), "shared_views.xml"); - assertThat(sut.selectAllViewsAndSubViews(db.getSession())).extracting("uuid").containsOnly("ABCD", "EFGH", "FGHI", "IJKL"); - assertThat(sut.selectAllViewsAndSubViews(db.getSession())).extracting("projectUuid").containsOnly("ABCD", "EFGH", "IJKL"); + assertThat(underTest.selectAllViewsAndSubViews(db.getSession())).extracting("uuid").containsOnly("ABCD", "EFGH", "FGHI", "IJKL"); + assertThat(underTest.selectAllViewsAndSubViews(db.getSession())).extracting("projectUuid").containsOnly("ABCD", "EFGH", "IJKL"); } @Test public void select_projects_from_view() { db.prepareDbUnit(getClass(), "shared_views.xml"); - assertThat(sut.selectProjectsFromView(db.getSession(), "ABCD", "ABCD")).containsOnly("JKLM"); - assertThat(sut.selectProjectsFromView(db.getSession(), "EFGH", "EFGH")).containsOnly("KLMN", "JKLM"); - assertThat(sut.selectProjectsFromView(db.getSession(), "FGHI", "EFGH")).containsOnly("JKLM"); - assertThat(sut.selectProjectsFromView(db.getSession(), "IJKL", "IJKL")).isEmpty(); - assertThat(sut.selectProjectsFromView(db.getSession(), "Unknown", "Unknown")).isEmpty(); + assertThat(underTest.selectProjectsFromView(db.getSession(), "ABCD", "ABCD")).containsOnly("JKLM"); + assertThat(underTest.selectProjectsFromView(db.getSession(), "EFGH", "EFGH")).containsOnly("KLMN", "JKLM"); + assertThat(underTest.selectProjectsFromView(db.getSession(), "FGHI", "EFGH")).containsOnly("JKLM"); + assertThat(underTest.selectProjectsFromView(db.getSession(), "IJKL", "IJKL")).isEmpty(); + assertThat(underTest.selectProjectsFromView(db.getSession(), "Unknown", "Unknown")).isEmpty(); } @Test public void select_provisioned_projects() { db.prepareDbUnit(getClass(), "select_provisioned_projects.xml"); - List<ComponentDto> result = sut.selectProvisionedProjects(db.getSession(), 0, 10, null); + List<ComponentDto> result = underTest.selectProvisionedProjects(db.getSession(), 0, 10, null); ComponentDto project = result.get(0); assertThat(result).hasSize(1); @@ -474,7 +474,7 @@ public class ComponentDaoTest { public void count_provisioned_projects() { db.prepareDbUnit(getClass(), "select_provisioned_projects.xml"); - int numberOfProjects = sut.countProvisionedProjects(db.getSession(), null); + int numberOfProjects = underTest.countProvisionedProjects(db.getSession(), null); assertThat(numberOfProjects).isEqualTo(1); } @@ -483,11 +483,11 @@ public class ComponentDaoTest { public void select_ghost_projects() { db.prepareDbUnit(getClass(), "select_ghost_projects.xml"); - List<ComponentDto> result = sut.selectGhostProjects(db.getSession(), 0, 10, null); + List<ComponentDto> result = underTest.selectGhostProjects(db.getSession(), 0, 10, null); assertThat(result).hasSize(1); assertThat(result.get(0).key()).isEqualTo("org.ghost.project"); - assertThat(sut.countGhostProjects(db.getSession(), null)).isEqualTo(1); + assertThat(underTest.countGhostProjects(db.getSession(), null)).isEqualTo(1); } @Test @@ -515,7 +515,7 @@ public class ComponentDaoTest { .setCreatedAt(DateUtils.parseDate("2014-06-18")) .setAuthorizationUpdatedAt(123456789L); - sut.insert(db.getSession(), componentDto); + underTest.insert(db.getSession(), componentDto); db.getSession().commit(); assertThat(componentDto.getId()).isNotNull(); @@ -544,7 +544,7 @@ public class ComponentDaoTest { .setCreatedAt(DateUtils.parseDate("2014-06-18")) .setAuthorizationUpdatedAt(123456789L); - sut.insert(db.getSession(), componentDto); + underTest.insert(db.getSession(), componentDto); db.getSession().commit(); assertThat(componentDto.getId()).isNotNull(); @@ -574,7 +574,7 @@ public class ComponentDaoTest { .setEnabled(false) .setAuthorizationUpdatedAt(12345678910L); - sut.update(db.getSession(), componentDto); + underTest.update(db.getSession(), componentDto); db.getSession().commit(); db.assertDbUnit(getClass(), "update-result.xml", "projects"); diff --git a/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java index d2a7f81cc30..e9737aada6f 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java @@ -47,13 +47,13 @@ public class ResourceDaoTest { @Rule public DbTester dbTester = DbTester.create(system); - ResourceDao sut = dbTester.getDbClient().resourceDao(); + ResourceDao underTest = dbTester.getDbClient().resourceDao(); @Test public void get_resource_by_uuid() { dbTester.prepareDbUnit(getClass(), "fixture.xml"); - ResourceDto resource = sut.getResource("ABCD"); + ResourceDto resource = underTest.getResource("ABCD"); assertThat(resource.getUuid()).isEqualTo("ABCD"); assertThat(resource.getProjectUuid()).isEqualTo("ABCD"); @@ -74,19 +74,19 @@ public class ResourceDaoTest { ResourceQuery query = ResourceQuery.create().setKey("org.struts:struts-core"); - assertThat(sut.getResource(query).getKey()).isEqualTo("org.struts:struts-core"); + assertThat(underTest.getResource(query).getKey()).isEqualTo("org.struts:struts-core"); } @Test public void find_root_project_by_component_key() { dbTester.prepareDbUnit(getClass(), "fixture.xml"); - assertThat(sut.getRootProjectByComponentKey("org.struts:struts-core:src/org/struts/RequestContext.java").getKey()).isEqualTo("org.struts:struts"); - assertThat(sut.getRootProjectByComponentKey("org.struts:struts-core:src/org/struts").getKey()).isEqualTo("org.struts:struts"); - assertThat(sut.getRootProjectByComponentKey("org.struts:struts-core").getKey()).isEqualTo("org.struts:struts"); - assertThat(sut.getRootProjectByComponentKey("org.struts:struts").getKey()).isEqualTo("org.struts:struts"); + assertThat(underTest.getRootProjectByComponentKey("org.struts:struts-core:src/org/struts/RequestContext.java").getKey()).isEqualTo("org.struts:struts"); + assertThat(underTest.getRootProjectByComponentKey("org.struts:struts-core:src/org/struts").getKey()).isEqualTo("org.struts:struts"); + assertThat(underTest.getRootProjectByComponentKey("org.struts:struts-core").getKey()).isEqualTo("org.struts:struts"); + assertThat(underTest.getRootProjectByComponentKey("org.struts:struts").getKey()).isEqualTo("org.struts:struts"); - assertThat(sut.getRootProjectByComponentKey("unknown")).isNull(); + assertThat(underTest.getRootProjectByComponentKey("unknown")).isNull(); } @Test @@ -102,8 +102,8 @@ public class ResourceDaoTest { .setDeprecatedKey("org.struts:struts:org.struts.Filter").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE) .setLanguage("java").setName("Filter").setLongName("org.struts.Filter"); - sut.insertUsingExistingSession(file1, dbTester.getSession()); - sut.insertUsingExistingSession(file2, dbTester.getSession()); + underTest.insertUsingExistingSession(file1, dbTester.getSession()); + underTest.insertUsingExistingSession(file2, dbTester.getSession()); dbTester.getSession().rollback(); @@ -114,59 +114,59 @@ public class ResourceDaoTest { public void should_find_component_by_key() { dbTester.prepareDbUnit(getClass(), "fixture.xml"); - assertThat(sut.findByKey("org.struts:struts")).isNotNull(); - Component component = sut.findByKey("org.struts:struts-core:src/org/struts/RequestContext.java"); + assertThat(underTest.findByKey("org.struts:struts")).isNotNull(); + Component component = underTest.findByKey("org.struts:struts-core:src/org/struts/RequestContext.java"); assertThat(component).isNotNull(); assertThat(component.path()).isEqualTo("src/org/struts/RequestContext.java"); - assertThat(sut.findByKey("unknown")).isNull(); + assertThat(underTest.findByKey("unknown")).isNull(); } @Test public void should_select_projects_by_qualifiers() { dbTester.prepareDbUnit(getClass(), "fixture-including-ghost-projects-and-technical-project.xml"); - List<Component> components = sut.selectProjectsByQualifiers(newArrayList("TRK")); + List<Component> components = underTest.selectProjectsByQualifiers(newArrayList("TRK")); assertThat(components).hasSize(1); assertThat(components.get(0).key()).isEqualTo("org.struts:struts"); assertThat(((ComponentDto) components.get(0)).getId()).isEqualTo(1L); - assertThat(sut.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("unknown"))).isEmpty(); - assertThat(sut.selectProjectsIncludingNotCompletedOnesByQualifiers(Collections.<String>emptyList())).isEmpty(); + assertThat(underTest.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("unknown"))).isEmpty(); + assertThat(underTest.selectProjectsIncludingNotCompletedOnesByQualifiers(Collections.<String>emptyList())).isEmpty(); } @Test public void should_select_projects_including_not_finished_by_qualifiers() { dbTester.prepareDbUnit(getClass(), "fixture-including-ghost-projects-and-technical-project.xml"); - List<Component> components = sut.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("TRK")); + List<Component> components = underTest.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("TRK")); assertThat(getKeys(components)).containsOnly("org.struts:struts", "org.apache.shindig", "org.sample:sample"); - assertThat(sut.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("unknown"))).isEmpty(); - assertThat(sut.selectProjectsIncludingNotCompletedOnesByQualifiers(Collections.<String>emptyList())).isEmpty(); + assertThat(underTest.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("unknown"))).isEmpty(); + assertThat(underTest.selectProjectsIncludingNotCompletedOnesByQualifiers(Collections.<String>emptyList())).isEmpty(); } @Test public void should_select_ghosts_projects_by_qualifiers() { dbTester.prepareDbUnit(getClass(), "fixture-including-ghost-projects-and-technical-project.xml"); - List<Component> components = sut.selectGhostsProjects(newArrayList("TRK")); + List<Component> components = underTest.selectGhostsProjects(newArrayList("TRK")); assertThat(components).hasSize(1); assertThat(getKeys(components)).containsOnly("org.apache.shindig"); - assertThat(sut.selectGhostsProjects(newArrayList("unknown"))).isEmpty(); - assertThat(sut.selectGhostsProjects(Collections.<String>emptyList())).isEmpty(); + assertThat(underTest.selectGhostsProjects(newArrayList("unknown"))).isEmpty(); + assertThat(underTest.selectGhostsProjects(Collections.<String>emptyList())).isEmpty(); } @Test public void should_select_provisioned_projects_by_qualifiers() { dbTester.prepareDbUnit(getClass(), "fixture-including-ghost-projects-and-technical-project.xml"); - List<ResourceDto> components = sut.selectProvisionedProjects(newArrayList("TRK")); + List<ResourceDto> components = underTest.selectProvisionedProjects(newArrayList("TRK")); assertThat(components).hasSize(1); assertThat(components.get(0).getKey()).isEqualTo("org.sample:sample"); - assertThat(sut.selectProvisionedProjects(newArrayList("unknown"))).isEmpty(); - assertThat(sut.selectProvisionedProjects(Collections.<String>emptyList())).isEmpty(); + assertThat(underTest.selectProvisionedProjects(newArrayList("unknown"))).isEmpty(); + assertThat(underTest.selectProvisionedProjects(Collections.<String>emptyList())).isEmpty(); } @Test @@ -174,7 +174,7 @@ public class ResourceDaoTest { dbTester.prepareDbUnit(getClass(), "update_authorization_date.xml"); when(system.now()).thenReturn(987654321L); - sut.updateAuthorizationDate(1L, dbTester.getSession()); + underTest.updateAuthorizationDate(1L, dbTester.getSession()); dbTester.getSession().commit(); dbTester.assertDbUnit(getClass(), "update_authorization_date-result.xml", "projects"); diff --git a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java index e3978c2083a..f1afab1e9aa 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java @@ -41,13 +41,13 @@ public class SnapshotDaoTest { @Rule public DbTester db = DbTester.create(System2.INSTANCE); - SnapshotDao sut = db.getDbClient().snapshotDao(); + SnapshotDao underTest = db.getDbClient().snapshotDao(); @Test public void get_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - SnapshotDto result = sut.selectNullableById(db.getSession(), 3L); + SnapshotDto result = underTest.selectNullableById(db.getSession(), 3L); assertThat(result).isNotNull(); assertThat(result.getId()).isEqualTo(3L); assertThat(result.getComponentId()).isEqualTo(3L); @@ -82,12 +82,12 @@ public class SnapshotDaoTest { assertThat(result.getCreatedAt()).isEqualTo(1228172400000L); assertThat(result.getBuildDate()).isEqualTo(1317247200000L); - assertThat(sut.selectNullableById(db.getSession(), 999L)).isNull(); + assertThat(underTest.selectNullableById(db.getSession(), 999L)).isNull(); } @Test public void lastSnapshot_returns_null_when_no_last_snapshot() { - SnapshotDto snapshot = sut.selectLastSnapshotByComponentId(db.getSession(), 123L); + SnapshotDto snapshot = underTest.selectLastSnapshotByComponentId(db.getSession(), 123L); assertThat(snapshot).isNull(); } @@ -96,7 +96,7 @@ public class SnapshotDaoTest { public void lastSnapshot_from_one_resource() { db.prepareDbUnit(getClass(), "snapshots.xml"); - SnapshotDto snapshot = sut.selectLastSnapshotByComponentId(db.getSession(), 2L); + SnapshotDto snapshot = underTest.selectLastSnapshotByComponentId(db.getSession(), 2L); assertThat(snapshot).isNotNull(); assertThat(snapshot.getId()).isEqualTo(4L); @@ -106,7 +106,7 @@ public class SnapshotDaoTest { public void lastSnapshot_from_one_resource_without_last_is_null() { db.prepareDbUnit(getClass(), "snapshots.xml"); - SnapshotDto snapshot = sut.selectLastSnapshotByComponentId(db.getSession(), 5L); + SnapshotDto snapshot = underTest.selectLastSnapshotByComponentId(db.getSession(), 5L); assertThat(snapshot).isNull(); } @@ -115,7 +115,7 @@ public class SnapshotDaoTest { public void snapshot_and_child_retrieved() { db.prepareDbUnit(getClass(), "snapshots.xml"); - List<SnapshotDto> snapshots = sut.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L); + List<SnapshotDto> snapshots = underTest.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L); assertThat(snapshots).isNotEmpty(); assertThat(snapshots).extracting("id").containsOnly(1L, 6L); @@ -125,7 +125,7 @@ public class SnapshotDaoTest { public void select_snapshots_by_component_id() { db.prepareDbUnit(getClass(), "snapshots.xml"); - List<SnapshotDto> snapshots = sut.selectSnapshotsByComponentId(db.getSession(), 1L); + List<SnapshotDto> snapshots = underTest.selectSnapshotsByComponentId(db.getSession(), 1L); assertThat(snapshots).hasSize(3); } @@ -134,37 +134,37 @@ public class SnapshotDaoTest { public void select_snapshots_by_query() { db.prepareDbUnit(getClass(), "select_snapshots_by_query.xml"); - assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery())).hasSize(6); + assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery())).hasSize(6); - assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L))).hasSize(3); + assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L))).hasSize(3); - assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setVersion("2.2-SNAPSHOT"))).extracting("id").containsOnly(3L); + assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setVersion("2.2-SNAPSHOT"))).extracting("id").containsOnly(3L); - assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setIsLast(true))).extracting("id").containsOnly(1L); - assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setIsLast(false))).extracting("id").containsOnly(2L, 3L); + assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setIsLast(true))).extracting("id").containsOnly(1L); + assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setIsLast(false))).extracting("id").containsOnly(2L, 3L); - assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setCreatedAfter(1228172400002L))).extracting("id").containsOnly(2L, 3L); - assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setCreatedBefore(1228172400002L))).extracting("id").containsOnly(1L); + assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setCreatedAfter(1228172400002L))).extracting("id").containsOnly(2L, 3L); + assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setCreatedBefore(1228172400002L))).extracting("id").containsOnly(1L); - assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(2L).setStatus("P"))).hasSize(1); - assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(2L).setStatus("U"))).hasSize(1); + assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(2L).setStatus("P"))).hasSize(1); + assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(2L).setStatus("U"))).hasSize(1); - assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setSort(BY_DATE, ASC)).get(0).getId()).isEqualTo(1L); - assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setSort(BY_DATE, DESC)).get(0).getId()).isEqualTo(3L); + assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setSort(BY_DATE, ASC)).get(0).getId()).isEqualTo(1L); + assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setSort(BY_DATE, DESC)).get(0).getId()).isEqualTo(3L); } @Test public void select_previous_version_snapshots() { db.prepareDbUnit(getClass(), "select_previous_version_snapshots.xml"); - List<SnapshotDto> snapshots = sut.selectPreviousVersionSnapshots(db.getSession(), 1L, "1.2-SNAPSHOT"); + List<SnapshotDto> snapshots = underTest.selectPreviousVersionSnapshots(db.getSession(), 1L, "1.2-SNAPSHOT"); assertThat(snapshots).hasSize(2); SnapshotDto firstSnapshot = snapshots.get(0); assertThat(firstSnapshot.getVersion()).isEqualTo("1.1"); // All snapshots are returned on an unknown version - assertThat(sut.selectPreviousVersionSnapshots(db.getSession(), 1L, "UNKNOWN")).hasSize(3); + assertThat(underTest.selectPreviousVersionSnapshots(db.getSession(), 1L, "UNKNOWN")).hasSize(3); } @Test @@ -173,7 +173,7 @@ public class SnapshotDaoTest { SnapshotDto dto = defaultSnapshot().setCreatedAt(1403042400000L); - sut.insert(db.getSession(), dto); + underTest.insert(db.getSession(), dto); db.getSession().commit(); assertThat(dto.getId()).isNotNull(); @@ -184,7 +184,7 @@ public class SnapshotDaoTest { public void insert_snapshots() { db.prepareDbUnit(getClass(), "empty.xml"); - sut.insert(db.getSession(), + underTest.insert(db.getSession(), new SnapshotDto().setComponentId(1L).setLast(false), new SnapshotDto().setComponentId(2L).setLast(false)); db.getSession().commit(); @@ -197,10 +197,10 @@ public class SnapshotDaoTest { db.prepareDbUnit(getClass(), "snapshots.xml"); SnapshotDto snapshot = defaultSnapshot().setId(1L); - sut.updateSnapshotAndChildrenLastFlagAndStatus(db.getSession(), snapshot, false, SnapshotDto.STATUS_PROCESSED); + underTest.updateSnapshotAndChildrenLastFlagAndStatus(db.getSession(), snapshot, false, SnapshotDto.STATUS_PROCESSED); db.getSession().commit(); - List<SnapshotDto> snapshots = sut.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L); + List<SnapshotDto> snapshots = underTest.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L); assertThat(snapshots).hasSize(2); assertThat(snapshots).extracting("id").containsOnly(1L, 6L); assertThat(snapshots).extracting("last").containsOnly(false); @@ -212,10 +212,10 @@ public class SnapshotDaoTest { db.prepareDbUnit(getClass(), "snapshots.xml"); SnapshotDto snapshot = defaultSnapshot().setId(1L); - sut.updateSnapshotAndChildrenLastFlag(db.getSession(), snapshot, false); + underTest.updateSnapshotAndChildrenLastFlag(db.getSession(), snapshot, false); db.getSession().commit(); - List<SnapshotDto> snapshots = sut.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L); + List<SnapshotDto> snapshots = underTest.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L); assertThat(snapshots).hasSize(2); assertThat(snapshots).extracting("id").containsOnly(1L, 6L); assertThat(snapshots).extracting("last").containsOnly(false); diff --git a/sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java b/sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java index c86e7304724..6a1e740a7f3 100644 --- a/sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java @@ -48,7 +48,7 @@ public class AnalysisReportDaoTest { @Rule public DbTester db = DbTester.create(system2); - AnalysisReportDao sut = db.getDbClient().analysisReportDao(); + AnalysisReportDao underTest = db.getDbClient().analysisReportDao(); @Test public void insert_multiple_reports() { @@ -58,8 +58,8 @@ public class AnalysisReportDaoTest { AnalysisReportDto report1 = new AnalysisReportDto().setProjectKey("ProjectKey1").setProjectName("Project 1").setUuid("UUID_1").setStatus(PENDING); AnalysisReportDto report2 = new AnalysisReportDto().setProjectKey("ProjectKey2").setProjectName("Project 2").setUuid("UUID_2").setStatus(PENDING); - sut.insert(db.getSession(), report1); - sut.insert(db.getSession(), report2); + underTest.insert(db.getSession(), report1); + underTest.insert(db.getSession(), report2); db.getSession().commit(); db.assertDbUnit(getClass(), "insert-result.xml", "analysis_reports"); @@ -69,7 +69,7 @@ public class AnalysisReportDaoTest { public void resetAllToPendingStatus() { db.prepareDbUnit(getClass(), "update-all-to-status-pending.xml"); - sut.resetAllToPendingStatus(db.getSession()); + underTest.resetAllToPendingStatus(db.getSession()); db.getSession().commit(); db.assertDbUnit(getClass(), "update-all-to-status-pending-result.xml", "analysis_reports"); @@ -79,7 +79,7 @@ public class AnalysisReportDaoTest { public void truncate() { db.prepareDbUnit(getClass(), "any-analysis-reports.xml"); - sut.truncate(db.getSession()); + underTest.truncate(db.getSession()); db.getSession().commit(); db.assertDbUnit(getClass(), "truncate-result.xml", "analysis_reports"); @@ -90,7 +90,7 @@ public class AnalysisReportDaoTest { db.prepareDbUnit(getClass(), "select.xml"); final String projectKey = "123456789-987654321"; - List<AnalysisReportDto> reports = sut.selectByProjectKey(db.getSession(), projectKey); + List<AnalysisReportDto> reports = underTest.selectByProjectKey(db.getSession(), projectKey); AnalysisReportDto report = reports.get(0); assertThat(reports).hasSize(1); @@ -105,7 +105,7 @@ public class AnalysisReportDaoTest { db.prepareDbUnit(getClass(), "select.xml"); final String projectKey = "987654321-123456789"; - List<AnalysisReportDto> reports = sut.selectByProjectKey(db.getSession(), projectKey); + List<AnalysisReportDto> reports = underTest.selectByProjectKey(db.getSession(), projectKey); assertThat(reports).hasSize(2); } @@ -114,7 +114,7 @@ public class AnalysisReportDaoTest { public void pop_oldest_pending() { db.prepareDbUnit(getClass(), "pop_oldest_pending.xml"); - AnalysisReportDto nextAvailableReport = sut.pop(db.getSession()); + AnalysisReportDto nextAvailableReport = underTest.pop(db.getSession()); assertThat(nextAvailableReport.getId()).isEqualTo(3); assertThat(nextAvailableReport.getProjectKey()).isEqualTo("P2"); @@ -124,7 +124,7 @@ public class AnalysisReportDaoTest { public void pop_null_if_no_pending_reports() { db.prepareDbUnit(getClass(), "pop_null_if_no_pending_reports.xml"); - AnalysisReportDto nextAvailableReport = sut.pop(db.getSession()); + AnalysisReportDto nextAvailableReport = underTest.pop(db.getSession()); assertThat(nextAvailableReport).isNull(); } @@ -133,7 +133,7 @@ public class AnalysisReportDaoTest { public void getById_maps_all_the_fields_except_the_data() { db.prepareDbUnit(getClass(), "one_analysis_report.xml"); - AnalysisReportDto report = sut.selectById(db.getSession(), 1L); + AnalysisReportDto report = underTest.selectById(db.getSession(), 1L); assertThat(report.getProjectKey()).isEqualTo(DEFAULT_PROJECT_KEY); assertThat(report.getCreatedAt()).isEqualTo(1_500_000_000_001L); @@ -147,7 +147,7 @@ public class AnalysisReportDaoTest { public void getById_returns_null_when_id_not_found() { db.prepareDbUnit(getClass(), "select.xml"); - AnalysisReportDto report = sut.selectById(db.getSession(), 4L); + AnalysisReportDto report = underTest.selectById(db.getSession(), 4L); assertThat(report).isNull(); } @@ -156,7 +156,7 @@ public class AnalysisReportDaoTest { public void delete_one_analysis_report() { db.prepareDbUnit(getClass(), "one_analysis_report.xml"); - sut.delete(db.getSession(), 1); + underTest.delete(db.getSession(), 1); db.getSession().commit(); db.assertDbUnit(getClass(), "truncate-result.xml", "analysis_reports"); @@ -166,7 +166,7 @@ public class AnalysisReportDaoTest { public void findAll_one_analysis_report() { db.prepareDbUnit(getClass(), "one_analysis_report.xml"); - List<AnalysisReportDto> reports = sut.selectAll(db.getSession()); + List<AnalysisReportDto> reports = underTest.selectAll(db.getSession()); assertThat(reports).hasSize(1); } @@ -175,7 +175,7 @@ public class AnalysisReportDaoTest { public void findAll_empty_table() { db.prepareDbUnit(getClass(), "empty.xml"); - List<AnalysisReportDto> reports = sut.selectAll(db.getSession()); + List<AnalysisReportDto> reports = underTest.selectAll(db.getSession()); assertThat(reports).isEmpty(); } @@ -184,7 +184,7 @@ public class AnalysisReportDaoTest { public void findAll_three_analysis_reports() { db.prepareDbUnit(getClass(), "three_analysis_reports.xml"); - List<AnalysisReportDto> reports = sut.selectAll(db.getSession()); + List<AnalysisReportDto> reports = underTest.selectAll(db.getSession()); assertThat(reports).hasSize(3); } diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java index 8f7bc6bce9e..196f1cba010 100644 --- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java @@ -42,13 +42,13 @@ public class MeasureDaoTest { @Rule public DbTester db = DbTester.create(System2.INSTANCE); - MeasureDao sut = db.getDbClient().measureDao(); + MeasureDao underTest = db.getDbClient().measureDao(); @Test public void get_value_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = sut.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); + MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); assertThat(result.getId()).isEqualTo(22); assertThat(result.getValue()).isEqualTo(10d); assertThat(result.getData()).isNull(); @@ -66,7 +66,7 @@ public class MeasureDaoTest { public void get_data_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = sut.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "authors_by_line"); + MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "authors_by_line"); assertThat(result.getId()).isEqualTo(20); assertThat(result.getData()).isEqualTo("0123456789012345678901234567890123456789"); } @@ -75,7 +75,7 @@ public class MeasureDaoTest { public void get_text_value_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = sut.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "coverage_line_hits_data"); + MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "coverage_line_hits_data"); assertThat(result.getId()).isEqualTo(21); assertThat(result.getData()).isEqualTo("36=1;37=1;38=1;39=1;43=1;48=1;53=1"); } @@ -84,11 +84,11 @@ public class MeasureDaoTest { public void find_by_component_key_and_metrics() { db.prepareDbUnit(getClass(), "shared.xml"); - List<MeasureDto> results = sut.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", + List<MeasureDto> results = underTest.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc", "authors_by_line")); assertThat(results).hasSize(2); - results = sut.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc")); + results = underTest.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc")); assertThat(results).hasSize(1); MeasureDto result = results.get(0); @@ -107,7 +107,7 @@ public class MeasureDaoTest { public void find_by_component_key_and_metric() { db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = sut.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); + MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); assertThat(result.getId()).isEqualTo(22); assertThat(result.getValue()).isEqualTo(10d); assertThat(result.getMetricKey()).isEqualTo("ncloc"); @@ -118,22 +118,22 @@ public class MeasureDaoTest { assertThat(result.getVariation(4)).isEqualTo(4d); assertThat(result.getVariation(5)).isEqualTo(-5d); - assertThat(sut.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isNull(); + assertThat(underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isNull(); } @Test public void exists_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - assertThat(sut.existsByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc")).isTrue(); - assertThat(sut.existsByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isFalse(); + assertThat(underTest.existsByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc")).isTrue(); + assertThat(underTest.existsByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isFalse(); } @Test public void select_past_measures_by_component_uuid_and_root_snapshot_id_and_metric_keys() { db.prepareDbUnit(getClass(), "past_measures.xml"); - List<PastMeasureDto> fileMeasures = sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 1000L, ImmutableSet.of(1, 2)); + List<PastMeasureDto> fileMeasures = underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 1000L, ImmutableSet.of(1, 2)); assertThat(fileMeasures).hasSize(2); PastMeasureDto fileMeasure1 = fileMeasures.get(0); @@ -147,7 +147,7 @@ public class MeasureDaoTest { assertThat(fileMeasure2.getValue()).isEqualTo(60d); assertThat(fileMeasure2.getMetricId()).isEqualTo(2); - List<PastMeasureDto> projectMeasures = sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1, 2)); + List<PastMeasureDto> projectMeasures = underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1, 2)); assertThat(projectMeasures).hasSize(2); PastMeasureDto projectMeasure1 = projectMeasures.get(0); @@ -158,9 +158,9 @@ public class MeasureDaoTest { assertThat(projectMeasure2.getValue()).isEqualTo(80d); assertThat(projectMeasure2.getMetricId()).isEqualTo(2); - assertThat(sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "UNKNOWN", 1000L, ImmutableSet.of(1, 2))).isEmpty(); - assertThat(sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 987654L, ImmutableSet.of(1, 2))).isEmpty(); - assertThat(sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 1000L, ImmutableSet.of(123, 456))).isEmpty(); + assertThat(underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "UNKNOWN", 1000L, ImmutableSet.of(1, 2))).isEmpty(); + assertThat(underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 987654L, ImmutableSet.of(1, 2))).isEmpty(); + assertThat(underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 1000L, ImmutableSet.of(123, 456))).isEmpty(); } @Test @@ -168,7 +168,7 @@ public class MeasureDaoTest { db.prepareDbUnit(getClass(), "past_measures_with_rule_id.xml"); db.getSession().commit(); - List<PastMeasureDto> measures = sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1)); + List<PastMeasureDto> measures = underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1)); assertThat(measures).hasSize(3); Map<Long, PastMeasureDto> pastMeasuresById = pastMeasuresById(measures); @@ -199,7 +199,7 @@ public class MeasureDaoTest { public void select_past_measures_on_characteristic_by_component_uuid_and_root_snapshot_id_and_metric_keys() { db.prepareDbUnit(getClass(), "past_measures_with_characteristic_id.xml"); - List<PastMeasureDto> measures = sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1)); + List<PastMeasureDto> measures = underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1)); assertThat(measures).hasSize(3); Map<Long, PastMeasureDto> pastMeasuresById = pastMeasuresById(measures); @@ -230,7 +230,7 @@ public class MeasureDaoTest { public void select_past_measures_on_person_by_component_uuid_and_root_snapshot_id_and_metric_keys() { db.prepareDbUnit(getClass(), "past_measures_with_person_id.xml"); - List<PastMeasureDto> measures = sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1)); + List<PastMeasureDto> measures = underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1)); assertThat(measures).hasSize(3); Map<Long, PastMeasureDto> pastMeasuresById = pastMeasuresById(measures); @@ -261,7 +261,7 @@ public class MeasureDaoTest { public void insert() { db.prepareDbUnit(getClass(), "empty.xml"); - sut.insert(db.getSession(), new MeasureDto() + underTest.insert(db.getSession(), new MeasureDto() .setSnapshotId(2L) .setMetricId(3) .setCharacteristicId(4) @@ -288,7 +288,7 @@ public class MeasureDaoTest { public void insert_measures() { db.prepareDbUnit(getClass(), "empty.xml"); - sut.insert(db.getSession(), new MeasureDto() + underTest.insert(db.getSession(), new MeasureDto() .setSnapshotId(2L) .setMetricId(3) .setComponentId(6L) diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java index 058b0007c6c..fb80a71d966 100644 --- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java @@ -27,11 +27,11 @@ import static org.assertj.core.api.Assertions.assertThat; public class MeasureDtoTest { - MeasureDto sut = new MeasureDto(); + MeasureDto underTest = new MeasureDto(); @Test public void test_getter_and_setter() throws Exception { - sut + underTest .setComponentKey("component") .setMetricKey("metric") .setId(10L) @@ -43,33 +43,33 @@ public class MeasureDtoTest { .setVariation(4, 4d) .setVariation(5, 5d); - assertThat(sut.getId()).isEqualTo(10); - assertThat(sut.getValue()).isEqualTo(2d); - assertThat(sut.getData()).isNotNull(); - assertThat(sut.getVariation(1)).isEqualTo(1d); - assertThat(sut.getVariation(2)).isEqualTo(2d); - assertThat(sut.getVariation(3)).isEqualTo(3d); - assertThat(sut.getVariation(4)).isEqualTo(4d); - assertThat(sut.getVariation(5)).isEqualTo(5d); + assertThat(underTest.getId()).isEqualTo(10); + assertThat(underTest.getValue()).isEqualTo(2d); + assertThat(underTest.getData()).isNotNull(); + assertThat(underTest.getVariation(1)).isEqualTo(1d); + assertThat(underTest.getVariation(2)).isEqualTo(2d); + assertThat(underTest.getVariation(3)).isEqualTo(3d); + assertThat(underTest.getVariation(4)).isEqualTo(4d); + assertThat(underTest.getVariation(5)).isEqualTo(5d); } @Test public void value_with_text_over_4000_characters() { - assertThat(sut.setData(Strings.repeat("1", 4001)).getData()).isNotNull(); + assertThat(underTest.setData(Strings.repeat("1", 4001)).getData()).isNotNull(); } @Test public void text_value_under_4000_characters() { - assertThat(sut.setData("text value").getData()).isEqualTo("text value"); + assertThat(underTest.setData("text value").getData()).isEqualTo("text value"); } @Test(expected = IndexOutOfBoundsException.class) public void fail_to_set_out_of_bounds_variation() { - sut.setVariation(6, 1d); + underTest.setVariation(6, 1d); } @Test(expected = IndexOutOfBoundsException.class) public void fail_to_get_out_of_bounds_variation() { - sut.getVariation(6); + underTest.getVariation(6); } } diff --git a/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java index 559b4779032..31307a148b4 100644 --- a/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java @@ -43,13 +43,13 @@ public class CustomMeasureDaoTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - CustomMeasureDao sut; + CustomMeasureDao underTest; DbSession session; @Before public void setUp() { session = db.getSession(); - sut = new CustomMeasureDao(); + underTest = new CustomMeasureDao(); db.truncateTables(); } @@ -57,9 +57,9 @@ public class CustomMeasureDaoTest { public void insert() { CustomMeasureDto measure = newCustomMeasureDto(); - sut.insert(session, measure); + underTest.insert(session, measure); - CustomMeasureDto result = sut.selectById(session, measure.getId()); + CustomMeasureDto result = underTest.selectById(session, measure.getId()); assertThat(result.getId()).isEqualTo(measure.getId()); assertThat(result.getMetricId()).isEqualTo(measure.getMetricId()); assertThat(result.getComponentUuid()).isEqualTo(measure.getComponentUuid()); @@ -74,56 +74,56 @@ public class CustomMeasureDaoTest { @Test public void delete_by_metric_id() { CustomMeasureDto measure = newCustomMeasureDto(); - sut.insert(session, measure); - assertThat(sut.selectNullableById(session, measure.getId())).isNotNull(); + underTest.insert(session, measure); + assertThat(underTest.selectNullableById(session, measure.getId())).isNotNull(); - sut.deleteByMetricIds(session, Arrays.asList(measure.getMetricId())); + underTest.deleteByMetricIds(session, Arrays.asList(measure.getMetricId())); - assertThat(sut.selectNullableById(session, measure.getId())).isNull(); + assertThat(underTest.selectNullableById(session, measure.getId())).isNull(); } @Test public void update() { CustomMeasureDto measure = newCustomMeasureDto().setDescription("old-description"); - sut.insert(session, measure); + underTest.insert(session, measure); measure.setDescription("new-description"); - sut.update(session, measure); + underTest.update(session, measure); - assertThat(sut.selectNullableById(session, measure.getId()).getDescription()).isEqualTo("new-description"); + assertThat(underTest.selectNullableById(session, measure.getId()).getDescription()).isEqualTo("new-description"); } @Test public void delete() { CustomMeasureDto measure = newCustomMeasureDto(); - sut.insert(session, measure); + underTest.insert(session, measure); - sut.delete(session, measure.getId()); - assertThat(sut.selectNullableById(session, measure.getId())).isNull(); + underTest.delete(session, measure.getId()); + assertThat(underTest.selectNullableById(session, measure.getId())).isNull(); } @Test public void select_by_component_uuid() { - sut.insert(session, newCustomMeasureDto().setComponentUuid("u1")); - sut.insert(session, newCustomMeasureDto().setComponentUuid("u1")); - sut.insert(session, newCustomMeasureDto().setComponentUuid("u2")); + underTest.insert(session, newCustomMeasureDto().setComponentUuid("u1")); + underTest.insert(session, newCustomMeasureDto().setComponentUuid("u1")); + underTest.insert(session, newCustomMeasureDto().setComponentUuid("u2")); session.commit(); - List<CustomMeasureDto> result = sut.selectByComponentUuid(session, "u1"); + List<CustomMeasureDto> result = underTest.selectByComponentUuid(session, "u1"); assertThat(result).hasSize(2); assertThat(result).extracting("componentUuid").containsOnly("u1"); - assertThat(sut.countByComponentUuid(session, "u1")).isEqualTo(2); + assertThat(underTest.countByComponentUuid(session, "u1")).isEqualTo(2); } @Test public void select_by_component_uuid_with_options() { - sut.insert(session, newCustomMeasureDto().setComponentUuid("u1")); - sut.insert(session, newCustomMeasureDto().setComponentUuid("u1")); - sut.insert(session, newCustomMeasureDto().setComponentUuid("u2")); + underTest.insert(session, newCustomMeasureDto().setComponentUuid("u1")); + underTest.insert(session, newCustomMeasureDto().setComponentUuid("u1")); + underTest.insert(session, newCustomMeasureDto().setComponentUuid("u2")); session.commit(); - List<CustomMeasureDto> result = sut.selectByComponentUuid(session, "u1", 0, 100); + List<CustomMeasureDto> result = underTest.selectByComponentUuid(session, "u1", 0, 100); assertThat(result).hasSize(2); assertThat(result).extracting("componentUuid").containsOnly("u1"); @@ -131,20 +131,20 @@ public class CustomMeasureDaoTest { @Test public void select_by_metric_id() { - sut.insert(session, newCustomMeasureDto().setMetricId(123)); - sut.insert(session, newCustomMeasureDto().setMetricId(123)); + underTest.insert(session, newCustomMeasureDto().setMetricId(123)); + underTest.insert(session, newCustomMeasureDto().setMetricId(123)); - List<CustomMeasureDto> result = sut.selectByMetricId(session, 123); + List<CustomMeasureDto> result = underTest.selectByMetricId(session, 123); assertThat(result).hasSize(2); } @Test public void count_by_component_uuid_and_metric_id() { - sut.insert(session, newCustomMeasureDto().setMetricId(123).setComponentUuid("123")); - sut.insert(session, newCustomMeasureDto().setMetricId(123).setComponentUuid("123")); + underTest.insert(session, newCustomMeasureDto().setMetricId(123).setComponentUuid("123")); + underTest.insert(session, newCustomMeasureDto().setMetricId(123).setComponentUuid("123")); - int count = sut.countByComponentIdAndMetricId(session, "123", 123); + int count = underTest.countByComponentIdAndMetricId(session, "123", 123); assertThat(count).isEqualTo(2); } @@ -153,7 +153,7 @@ public class CustomMeasureDaoTest { public void select_by_id_fail_if_no_measure_found() { expectedException.expect(IllegalArgumentException.class); - sut.selectById(session, 42L); + underTest.selectById(session, 42L); } } diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java index b981084b439..84aaa26470a 100644 --- a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java @@ -40,33 +40,33 @@ public class PurgeDaoTest { @Rule public DbTester dbTester = DbTester.create(system2); - PurgeDao sut = dbTester.getDbClient().purgeDao(); + PurgeDao underTest = dbTester.getDbClient().purgeDao(); @Test public void shouldDeleteAbortedBuilds() { dbTester.prepareDbUnit(getClass(), "shouldDeleteAbortedBuilds.xml"); - sut.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler()); + underTest.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler()); dbTester.assertDbUnit(getClass(), "shouldDeleteAbortedBuilds-result.xml", "snapshots"); } @Test public void should_purge_project() { dbTester.prepareDbUnit(getClass(), "shouldPurgeProject.xml"); - sut.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler()); + underTest.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler()); dbTester.assertDbUnit(getClass(), "shouldPurgeProject-result.xml", "projects", "snapshots"); } @Test public void delete_file_sources_of_disabled_resources() { dbTester.prepareDbUnit(getClass(), "delete_file_sources_of_disabled_resources.xml"); - sut.purge(newConfigurationWith30Days(system2), PurgeListener.EMPTY, new PurgeProfiler()); + underTest.purge(newConfigurationWith30Days(system2), PurgeListener.EMPTY, new PurgeProfiler()); dbTester.assertDbUnit(getClass(), "delete_file_sources_of_disabled_resources-result.xml", "file_sources"); } @Test public void shouldDeleteHistoricalDataOfDirectoriesAndFiles() { dbTester.prepareDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml"); - sut.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[] {Scopes.DIRECTORY, Scopes.FILE}, 30), PurgeListener.EMPTY, new PurgeProfiler()); + underTest.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[]{Scopes.DIRECTORY, Scopes.FILE}, 30), PurgeListener.EMPTY, new PurgeProfiler()); dbTester.assertDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml", "projects", "snapshots"); } @@ -74,7 +74,7 @@ public class PurgeDaoTest { public void disable_resources_without_last_snapshot() { dbTester.prepareDbUnit(getClass(), "disable_resources_without_last_snapshot.xml"); when(system2.now()).thenReturn(1450000000000L); - sut.purge(newConfigurationWith30Days(system2), PurgeListener.EMPTY, new PurgeProfiler()); + underTest.purge(newConfigurationWith30Days(system2), PurgeListener.EMPTY, new PurgeProfiler()); dbTester.assertDbUnit(getClass(), "disable_resources_without_last_snapshot-result.xml", new String[] {"issue_close_date", "issue_update_date"}, "projects", "snapshots", "issues"); } @@ -82,14 +82,14 @@ public class PurgeDaoTest { @Test public void shouldDeleteSnapshots() { dbTester.prepareDbUnit(getClass(), "shouldDeleteSnapshots.xml"); - sut.deleteSnapshots(PurgeSnapshotQuery.create().setIslast(false).setResourceId(1L), new PurgeProfiler()); + underTest.deleteSnapshots(PurgeSnapshotQuery.create().setIslast(false).setResourceId(1L), new PurgeProfiler()); dbTester.assertDbUnit(getClass(), "shouldDeleteSnapshots-result.xml", "snapshots"); } @Test public void shouldSelectPurgeableSnapshots() { dbTester.prepareDbUnit(getClass(), "shouldSelectPurgeableSnapshots.xml"); - List<PurgeableSnapshotDto> snapshots = sut.selectPurgeableSnapshots(1L); + List<PurgeableSnapshotDto> snapshots = underTest.selectPurgeableSnapshots(1L); assertThat(snapshots).hasSize(3); assertThat(getById(snapshots, 1L).isLast()).isTrue(); @@ -103,7 +103,7 @@ public class PurgeDaoTest { @Test public void should_delete_project_and_associated_data() { dbTester.prepareDbUnit(getClass(), "shouldDeleteProject.xml"); - sut.deleteResourceTree(new IdUuidPair(1L, "A"), new PurgeProfiler()); + underTest.deleteResourceTree(new IdUuidPair(1L, "A"), new PurgeProfiler()); assertThat(dbTester.countRowsOfTable("projects")).isZero(); assertThat(dbTester.countRowsOfTable("snapshots")).isZero(); assertThat(dbTester.countRowsOfTable("action_plans")).isZero(); @@ -115,14 +115,14 @@ public class PurgeDaoTest { @Test public void should_delete_old_closed_issues() { dbTester.prepareDbUnit(getClass(), "should_delete_old_closed_issues.xml"); - sut.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler()); + underTest.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler()); dbTester.assertDbUnit(getClass(), "should_delete_old_closed_issues-result.xml", "issues", "issue_changes"); } @Test public void should_delete_all_closed_issues() { dbTester.prepareDbUnit(getClass(), "should_delete_all_closed_issues.xml"); - sut.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 0), PurgeListener.EMPTY, new PurgeProfiler()); + underTest.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 0), PurgeListener.EMPTY, new PurgeProfiler()); dbTester.assertDbUnit(getClass(), "should_delete_all_closed_issues-result.xml", "issues", "issue_changes"); } diff --git a/sonar-db/src/test/java/org/sonar/db/source/FileSourceDaoTest.java b/sonar-db/src/test/java/org/sonar/db/source/FileSourceDaoTest.java index bf1f0d2f332..1ea318ab10c 100644 --- a/sonar-db/src/test/java/org/sonar/db/source/FileSourceDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/source/FileSourceDaoTest.java @@ -40,13 +40,13 @@ public class FileSourceDaoTest { @Rule public DbTester dbTester = DbTester.create(System2.INSTANCE); - FileSourceDao sut = dbTester.getDbClient().fileSourceDao(); + FileSourceDao underTest = dbTester.getDbClient().fileSourceDao(); @Test public void select() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - FileSourceDto fileSourceDto = sut.selectSource("FILE1_UUID"); + FileSourceDto fileSourceDto = underTest.selectSource("FILE1_UUID"); assertThat(fileSourceDto.getBinaryData()).isNotEmpty(); assertThat(fileSourceDto.getDataHash()).isEqualTo("hash"); @@ -62,7 +62,7 @@ public class FileSourceDaoTest { dbTester.prepareDbUnit(getClass(), "shared.xml"); ReaderToStringFunction fn = new ReaderToStringFunction(); - sut.readLineHashesStream(dbTester.getSession(), "FILE1_UUID", fn); + underTest.readLineHashesStream(dbTester.getSession(), "FILE1_UUID", fn); assertThat(fn.result).isEqualTo("ABC\\nDEF\\nGHI"); } @@ -72,7 +72,7 @@ public class FileSourceDaoTest { dbTester.prepareDbUnit(getClass(), "shared.xml"); ReaderToStringFunction fn = new ReaderToStringFunction(); - sut.readLineHashesStream(dbTester.getSession(), "unknown", fn); + underTest.readLineHashesStream(dbTester.getSession(), "unknown", fn); assertThat(fn.result).isNull(); } @@ -82,7 +82,7 @@ public class FileSourceDaoTest { dbTester.prepareDbUnit(getClass(), "no_line_hashes_when_only_test_data.xml"); ReaderToStringFunction fn = new ReaderToStringFunction(); - sut.readLineHashesStream(dbTester.getSession(), "FILE1_UUID", fn); + underTest.readLineHashesStream(dbTester.getSession(), "FILE1_UUID", fn); assertThat(fn.result).isNull(); } @@ -91,7 +91,7 @@ public class FileSourceDaoTest { public void insert() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - sut.insert(new FileSourceDto() + underTest.insert(new FileSourceDto() .setProjectUuid("PRJ_UUID") .setFileUuid("FILE2_UUID") .setBinaryData("FILE2_BINARY_DATA".getBytes()) @@ -110,7 +110,7 @@ public class FileSourceDaoTest { public void update() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - sut.update(new FileSourceDto() + underTest.update(new FileSourceDto() .setId(101L) .setProjectUuid("PRJ_UUID") .setFileUuid("FILE1_UUID") @@ -129,7 +129,7 @@ public class FileSourceDaoTest { public void update_date_when_updated_date_is_zero() { dbTester.prepareDbUnit(getClass(), "update_date_when_updated_date_is_zero.xml"); - sut.updateDateWhenUpdatedDateIsZero(dbTester.getSession(), "ABCD", 1500000000002L); + underTest.updateDateWhenUpdatedDateIsZero(dbTester.getSession(), "ABCD", 1500000000002L); dbTester.getSession().commit(); dbTester.assertDbUnitTable(getClass(), "update_date_when_updated_date_is_zero-result.xml", "file_sources", diff --git a/sonar-db/src/test/java/org/sonar/db/source/FileSourceDtoTest.java b/sonar-db/src/test/java/org/sonar/db/source/FileSourceDtoTest.java index 624dd4262cb..34d78e12779 100644 --- a/sonar-db/src/test/java/org/sonar/db/source/FileSourceDtoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/source/FileSourceDtoTest.java @@ -40,10 +40,9 @@ public class FileSourceDtoTest { .build() ); - FileSourceDto sut = new FileSourceDto() - .setTestData(tests); + FileSourceDto underTest = new FileSourceDto().setTestData(tests); - assertThat(sut.getTestData()).hasSize(2); - assertThat(sut.getTestData().get(0).getName()).isEqualTo("name#1"); + assertThat(underTest.getTestData()).hasSize(2); + assertThat(underTest.getTestData().get(0).getName()).isEqualTo("name#1"); } } |