diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-07-23 14:06:44 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-07-23 14:06:44 +0200 |
commit | 2890a151e4fd3034ad13601b9d79120e248d6cdd (patch) | |
tree | 0261c3ea1438427b70ee7ca938aeb94ff11124c4 /sonar-db/src/test | |
parent | 056b4bdc63c2ef126d9f9d2e0526f60be930cb81 (diff) | |
download | sonarqube-2890a151e4fd3034ad13601b9d79120e248d6cdd.tar.gz sonarqube-2890a151e4fd3034ad13601b9d79120e248d6cdd.zip |
Rename methods in DAO layer to follow conventions
Diffstat (limited to 'sonar-db/src/test')
16 files changed, 104 insertions, 104 deletions
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 dde4347b69c..eccbc11f9d9 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 @@ -106,7 +106,7 @@ public class ComponentDaoTest { db.prepareDbUnit(getClass(), "shared.xml"); - underTest.selectNonNullByUuid(db.getSession(), "unknown"); + underTest.selectOrFailByUuid(db.getSession(), "unknown"); } @Test @@ -258,7 +258,7 @@ public class ComponentDaoTest { public void get_by_id() { db.prepareDbUnit(getClass(), "shared.xml"); - assertThat(underTest.selectNonNullById(db.getSession(), 4L)).isNotNull(); + assertThat(underTest.selectOrFailById(db.getSession(), 4L)).isNotNull(); } @Test @@ -274,7 +274,7 @@ public class ComponentDaoTest { public void fail_to_get_by_id_when_project_not_found() { db.prepareDbUnit(getClass(), "shared.xml"); - underTest.selectNonNullById(db.getSession(), 111L); + underTest.selectOrFailById(db.getSession(), 111L); } @Test 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 e9737aada6f..394038e9bb5 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 @@ -53,7 +53,7 @@ public class ResourceDaoTest { public void get_resource_by_uuid() { dbTester.prepareDbUnit(getClass(), "fixture.xml"); - ResourceDto resource = underTest.getResource("ABCD"); + ResourceDto resource = underTest.selectResource("ABCD"); assertThat(resource.getUuid()).isEqualTo("ABCD"); assertThat(resource.getProjectUuid()).isEqualTo("ABCD"); @@ -74,7 +74,7 @@ public class ResourceDaoTest { ResourceQuery query = ResourceQuery.create().setKey("org.struts:struts-core"); - assertThat(underTest.getResource(query).getKey()).isEqualTo("org.struts:struts-core"); + assertThat(underTest.selectResource(query).getKey()).isEqualTo("org.struts:struts-core"); } @Test @@ -114,11 +114,11 @@ public class ResourceDaoTest { public void should_find_component_by_key() { dbTester.prepareDbUnit(getClass(), "fixture.xml"); - assertThat(underTest.findByKey("org.struts:struts")).isNotNull(); - Component component = underTest.findByKey("org.struts:struts-core:src/org/struts/RequestContext.java"); + assertThat(underTest.selectByKey("org.struts:struts")).isNotNull(); + Component component = underTest.selectByKey("org.struts:struts-core:src/org/struts/RequestContext.java"); assertThat(component).isNotNull(); assertThat(component.path()).isEqualTo("src/org/struts/RequestContext.java"); - assertThat(underTest.findByKey("unknown")).isNull(); + assertThat(underTest.selectByKey("unknown")).isNull(); } @Test 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 f1afab1e9aa..815a3bd0e16 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 @@ -47,7 +47,7 @@ public class SnapshotDaoTest { public void get_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - SnapshotDto result = underTest.selectNullableById(db.getSession(), 3L); + SnapshotDto result = underTest.selectById(db.getSession(), 3L); assertThat(result).isNotNull(); assertThat(result.getId()).isEqualTo(3L); assertThat(result.getComponentId()).isEqualTo(3L); @@ -82,7 +82,7 @@ public class SnapshotDaoTest { assertThat(result.getCreatedAt()).isEqualTo(1228172400000L); assertThat(result.getBuildDate()).isEqualTo(1317247200000L); - assertThat(underTest.selectNullableById(db.getSession(), 999L)).isNull(); + assertThat(underTest.selectById(db.getSession(), 999L)).isNull(); } @Test diff --git a/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanDaoTest.java b/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanDaoTest.java index 3862cbd3a9a..2b95e08d5a4 100644 --- a/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanDaoTest.java @@ -78,7 +78,7 @@ public class ActionPlanDaoTest { public void should_find_by_key() { dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_by_key.xml"); - ActionPlanDto result = dao.findByKey("ABC"); + ActionPlanDto result = dao.selectByKey("ABC"); assertThat(result).isNotNull(); assertThat(result.getKey()).isEqualTo("ABC"); assertThat(result.getProjectKey()).isEqualTo("org.sonar.Sample"); @@ -88,7 +88,7 @@ public class ActionPlanDaoTest { public void should_find_by_keys() { dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_by_keys.xml"); - Collection<ActionPlanDto> result = dao.findByKeys(newArrayList("ABC", "ABD", "ABE")); + Collection<ActionPlanDto> result = dao.selectByKeys(newArrayList("ABC", "ABD", "ABE")); assertThat(result).hasSize(3); } @@ -100,7 +100,7 @@ public class ActionPlanDaoTest { for (int i = 0; i < 4500; i++) { hugeNbOKeys.add("ABCD" + i); } - List<ActionPlanDto> result = dao.findByKeys(hugeNbOKeys); + List<ActionPlanDto> result = dao.selectByKeys(hugeNbOKeys); // The goal of this test is only to check that the query do no fail, not to check the number of results assertThat(result).isEmpty(); @@ -110,7 +110,7 @@ public class ActionPlanDaoTest { public void should_find_open_by_project_id() { dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_open_by_project_id.xml"); - Collection<ActionPlanDto> result = dao.findOpenByProjectId(1l); + Collection<ActionPlanDto> result = dao.selectOpenByProjectId(1l); assertThat(result).hasSize(2); } @@ -118,7 +118,7 @@ public class ActionPlanDaoTest { public void should_find_by_name_and_project_id() { dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_by_name_and_project_id.xml"); - Collection<ActionPlanDto> result = dao.findByNameAndProjectId("SHORT_TERM", 1l); + Collection<ActionPlanDto> result = dao.selectByNameAndProjectId("SHORT_TERM", 1l); assertThat(result).hasSize(2); } } diff --git a/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanStatsDaoTest.java b/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanStatsDaoTest.java index 1439cff7017..e2c1f587dbc 100644 --- a/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanStatsDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanStatsDaoTest.java @@ -42,7 +42,7 @@ public class ActionPlanStatsDaoTest { public void should_find_by_project() { dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_by_project.xml"); - Collection<ActionPlanStatsDto> result = dao.findByProjectId(1l); + Collection<ActionPlanStatsDto> result = dao.selectByProjectId(1l); assertThat(result).isNotEmpty(); ActionPlanStatsDto actionPlanStatsDto = result.iterator().next(); 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 196f1cba010..5a8e42922b5 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 @@ -48,7 +48,7 @@ public class MeasureDaoTest { public void get_value_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); + MeasureDto result = underTest.selectByComponentKeyAndMetricKey(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 = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "authors_by_line"); + MeasureDto result = underTest.selectByComponentKeyAndMetricKey(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 = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "coverage_line_hits_data"); + MeasureDto result = underTest.selectByComponentKeyAndMetricKey(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 = underTest.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", + List<MeasureDto> results = underTest.selectByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc", "authors_by_line")); assertThat(results).hasSize(2); - results = underTest.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc")); + results = underTest.selectByComponentKeyAndMetricKeys(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 = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); + MeasureDto result = underTest.selectByComponentKeyAndMetricKey(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,7 +118,7 @@ public class MeasureDaoTest { assertThat(result.getVariation(4)).isEqualTo(4d); assertThat(result.getVariation(5)).isEqualTo(-5d); - assertThat(underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isNull(); + assertThat(underTest.selectByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isNull(); } @Test diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java index d48d00835b4..45c511ec26a 100644 --- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java @@ -37,7 +37,7 @@ public class MeasureFilterDaoTest { public void should_find_filter() { db.prepareDbUnit(getClass(), "shared.xml"); - MeasureFilterDto filter = dao.findSystemFilterByName("Projects"); + MeasureFilterDto filter = dao.selectSystemFilterByName("Projects"); assertThat(filter.getId()).isEqualTo(1L); assertThat(filter.getName()).isEqualTo("Projects"); @@ -47,7 +47,7 @@ public class MeasureFilterDaoTest { public void should_not_find_filter() { db.prepareDbUnit(getClass(), "shared.xml"); - assertThat(dao.findSystemFilterByName("Unknown")).isNull(); + assertThat(dao.selectSystemFilterByName("Unknown")).isNull(); } @Test 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 31307a148b4..7a0805d11d6 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 @@ -59,7 +59,7 @@ public class CustomMeasureDaoTest { underTest.insert(session, measure); - CustomMeasureDto result = underTest.selectById(session, measure.getId()); + CustomMeasureDto result = underTest.selectOrFail(session, measure.getId()); assertThat(result.getId()).isEqualTo(measure.getId()); assertThat(result.getMetricId()).isEqualTo(measure.getMetricId()); assertThat(result.getComponentUuid()).isEqualTo(measure.getComponentUuid()); @@ -75,11 +75,11 @@ public class CustomMeasureDaoTest { public void delete_by_metric_id() { CustomMeasureDto measure = newCustomMeasureDto(); underTest.insert(session, measure); - assertThat(underTest.selectNullableById(session, measure.getId())).isNotNull(); + assertThat(underTest.selectById(session, measure.getId())).isNotNull(); underTest.deleteByMetricIds(session, Arrays.asList(measure.getMetricId())); - assertThat(underTest.selectNullableById(session, measure.getId())).isNull(); + assertThat(underTest.selectById(session, measure.getId())).isNull(); } @Test @@ -90,7 +90,7 @@ public class CustomMeasureDaoTest { underTest.update(session, measure); - assertThat(underTest.selectNullableById(session, measure.getId()).getDescription()).isEqualTo("new-description"); + assertThat(underTest.selectById(session, measure.getId()).getDescription()).isEqualTo("new-description"); } @Test @@ -99,7 +99,7 @@ public class CustomMeasureDaoTest { underTest.insert(session, measure); underTest.delete(session, measure.getId()); - assertThat(underTest.selectNullableById(session, measure.getId())).isNull(); + assertThat(underTest.selectById(session, measure.getId())).isNull(); } @Test @@ -153,7 +153,7 @@ public class CustomMeasureDaoTest { public void select_by_id_fail_if_no_measure_found() { expectedException.expect(IllegalArgumentException.class); - underTest.selectById(session, 42L); + underTest.selectOrFail(session, 42L); } } diff --git a/sonar-db/src/test/java/org/sonar/db/metric/MetricDaoTest.java b/sonar-db/src/test/java/org/sonar/db/metric/MetricDaoTest.java index 162cb647e50..1e1c17b7e62 100644 --- a/sonar-db/src/test/java/org/sonar/db/metric/MetricDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/metric/MetricDaoTest.java @@ -58,7 +58,7 @@ public class MetricDaoTest { public void get_by_key() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - MetricDto result = dao.selectNullableByKey(session, "coverage"); + MetricDto result = dao.selectByKey(session, "coverage"); assertThat(result.getId()).isEqualTo(2); assertThat(result.getKey()).isEqualTo("coverage"); assertThat(result.getShortName()).isEqualTo("Coverage"); @@ -76,21 +76,21 @@ public class MetricDaoTest { assertThat(result.isEnabled()).isTrue(); // Disabled metrics are returned - result = dao.selectNullableByKey(session, "disabled"); + result = dao.selectByKey(session, "disabled"); assertThat(result.getId()).isEqualTo(3); assertThat(result.isEnabled()).isFalse(); } @Test(expected = IllegalStateException.class) public void get_nullable_by_key() { - dao.selectByKey(session, "unknown"); + dao.selectOrFailByKey(session, "unknown"); } @Test public void get_manual_metric() { dbTester.prepareDbUnit(getClass(), "manual_metric.xml"); - MetricDto result = dao.selectNullableByKey(session, "manual"); + MetricDto result = dao.selectByKey(session, "manual"); assertThat(result.getId()).isEqualTo(1); assertThat(result.getKey()).isEqualTo("manual"); assertThat(result.getShortName()).isEqualTo("Manual metric"); @@ -133,7 +133,7 @@ public class MetricDaoTest { .setDeleteHistoricalData(true) .setEnabled(true)); - MetricDto result = dao.selectNullableByKey(session, "coverage"); + MetricDto result = dao.selectByKey(session, "coverage"); assertThat(result.getId()).isNotNull(); assertThat(result.getKey()).isEqualTo("coverage"); assertThat(result.getShortName()).isEqualTo("Coverage"); diff --git a/sonar-db/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java b/sonar-db/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java index f509c63164e..5c8e937aa0d 100644 --- a/sonar-db/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java @@ -46,7 +46,7 @@ public class NotificationQueueDaoTest { dao.insert(Arrays.asList(notificationQueueDto)); assertThat(dao.count()).isEqualTo(1); - assertThat(dao.findOldest(1).get(0).toNotification().getType()).isEqualTo("email"); + assertThat(dao.selectOldest(1).get(0).toNotification().getType()).isEqualTo("email"); } @Test @@ -78,11 +78,11 @@ public class NotificationQueueDaoTest { public void should_findOldest() { db.prepareDbUnit(getClass(), "should_findOldest.xml"); - Collection<NotificationQueueDto> result = dao.findOldest(3); + Collection<NotificationQueueDto> result = dao.selectOldest(3); assertThat(result).hasSize(3); assertThat(result).extracting("id").containsOnly(1L, 2L, 3L); - result = dao.findOldest(6); + result = dao.selectOldest(6); assertThat(result).hasSize(4); } } diff --git a/sonar-db/src/test/java/org/sonar/db/permission/PermissionFacadeTest.java b/sonar-db/src/test/java/org/sonar/db/permission/PermissionFacadeTest.java index 7e61c09fbe2..fb880b68178 100644 --- a/sonar-db/src/test/java/org/sonar/db/permission/PermissionFacadeTest.java +++ b/sonar-db/src/test/java/org/sonar/db/permission/PermissionFacadeTest.java @@ -74,7 +74,7 @@ public class PermissionFacadeTest { assertThat(permissionFacade.selectUserPermissions(dbTester.getSession(), "marius", 123L)).containsOnly("admin"); - assertThat(dbTester.getDbClient().resourceDao().getResource(123L, dbTester.getSession()).getAuthorizationUpdatedAt()).isEqualTo(123456789L); + assertThat(dbTester.getDbClient().resourceDao().selectResource(123L, dbTester.getSession()).getAuthorizationUpdatedAt()).isEqualTo(123456789L); } @Test diff --git a/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java b/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java index 5ba59ca9351..fdb77f761d0 100644 --- a/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java @@ -52,7 +52,7 @@ public class PermissionTemplateDaoTest { Date now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2013-01-02 01:04:05"); when(system.now()).thenReturn(now.getTime()); - PermissionTemplateDto permissionTemplate = permissionTemplateDao.createPermissionTemplate("my template", "my description", "myregexp"); + PermissionTemplateDto permissionTemplate = permissionTemplateDao.insertPermissionTemplate("my template", "my description", "myregexp"); assertThat(permissionTemplate).isNotNull(); assertThat(permissionTemplate.getId()).isEqualTo(1L); @@ -66,7 +66,7 @@ public class PermissionTemplateDaoTest { Date now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2013-01-02 01:04:05"); when(system.now()).thenReturn(now.getTime()); - PermissionTemplateDto permissionTemplate = permissionTemplateDao.createPermissionTemplate("Môü Gnô Gnèçàß", "my description", null); + PermissionTemplateDto permissionTemplate = permissionTemplateDao.insertPermissionTemplate("Môü Gnô Gnèçàß", "my description", null); assertThat(permissionTemplate).isNotNull(); assertThat(permissionTemplate.getId()).isEqualTo(1L); @@ -86,7 +86,7 @@ public class PermissionTemplateDaoTest { when(myBatis.openSession(false)).thenReturn(session); permissionTemplateDao = new PermissionTemplateDao(myBatis, system); - PermissionTemplateDto permissionTemplate = permissionTemplateDao.createPermissionTemplate(PermissionTemplateDto.DEFAULT.getName(), null, null); + PermissionTemplateDto permissionTemplate = permissionTemplateDao.insertPermissionTemplate(PermissionTemplateDto.DEFAULT.getName(), null, null); verify(mapper).insert(permissionTemplate); verify(session).commit(); @@ -176,7 +176,7 @@ public class PermissionTemplateDaoTest { public void should_add_user_permission_to_template() { db.prepareDbUnit(getClass(), "addUserPermissionToTemplate.xml"); - permissionTemplateDao.addUserPermission(1L, 1L, "new_permission"); + permissionTemplateDao.insertUserPermission(1L, 1L, "new_permission"); checkTemplateTables("addUserPermissionToTemplate-result.xml"); } @@ -185,7 +185,7 @@ public class PermissionTemplateDaoTest { public void should_remove_user_permission_from_template() { db.prepareDbUnit(getClass(), "removeUserPermissionFromTemplate.xml"); - permissionTemplateDao.removeUserPermission(1L, 2L, "permission_to_remove"); + permissionTemplateDao.deleteUserPermission(1L, 2L, "permission_to_remove"); checkTemplateTables("removeUserPermissionFromTemplate-result.xml"); } @@ -194,7 +194,7 @@ public class PermissionTemplateDaoTest { public void should_add_group_permission_to_template() { db.prepareDbUnit(getClass(), "addGroupPermissionToTemplate.xml"); - permissionTemplateDao.addGroupPermission(1L, 1L, "new_permission"); + permissionTemplateDao.insertGroupPermission(1L, 1L, "new_permission"); checkTemplateTables("addGroupPermissionToTemplate-result.xml"); } @@ -203,7 +203,7 @@ public class PermissionTemplateDaoTest { public void should_remove_group_permission_from_template() { db.prepareDbUnit(getClass(), "removeGroupPermissionFromTemplate.xml"); - permissionTemplateDao.removeGroupPermission(1L, 2L, "permission_to_remove"); + permissionTemplateDao.deleteGroupPermission(1L, 2L, "permission_to_remove"); checkTemplateTables("removeGroupPermissionFromTemplate-result.xml"); } @@ -212,7 +212,7 @@ public class PermissionTemplateDaoTest { public void remove_by_group() { db.prepareDbUnit(getClass(), "remove_by_group.xml"); - permissionTemplateDao.removeByGroup(2L, db.getSession()); + permissionTemplateDao.deleteByGroup(db.getSession(), 2L); db.getSession().commit(); db.assertDbUnitTable(getClass(), "remove_by_group-result.xml", "permission_templates", "id", "name", "kee", "description"); @@ -222,7 +222,7 @@ public class PermissionTemplateDaoTest { public void should_add_group_permission_with_null_name() { db.prepareDbUnit(getClass(), "addNullGroupPermissionToTemplate.xml"); - permissionTemplateDao.addGroupPermission(1L, null, "new_permission"); + permissionTemplateDao.insertGroupPermission(1L, null, "new_permission"); checkTemplateTables("addNullGroupPermissionToTemplate-result.xml"); } @@ -231,7 +231,7 @@ public class PermissionTemplateDaoTest { public void should_remove_group_permission_with_null_name() { db.prepareDbUnit(getClass(), "removeNullGroupPermissionFromTemplate.xml"); - permissionTemplateDao.removeGroupPermission(1L, null, "permission_to_remove"); + permissionTemplateDao.deleteGroupPermission(1L, null, "permission_to_remove"); checkTemplateTables("removeNullGroupPermissionFromTemplate-result.xml"); } diff --git a/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java b/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java index a36d4846832..71dd8551c4b 100644 --- a/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java @@ -50,24 +50,24 @@ public class PropertiesDaoTest { public void shouldFindUsersForNotification() { dbTester.prepareDbUnit(getClass(), "shouldFindUsersForNotification.xml"); - List<String> users = dao.findUsersForNotification("NewViolations", "Email", null); + List<String> users = dao.selectUsersForNotification("NewViolations", "Email", null); assertThat(users).isEmpty(); - users = dao.findUsersForNotification("NewViolations", "Email", "uuid_78"); + users = dao.selectUsersForNotification("NewViolations", "Email", "uuid_78"); assertThat(users).isEmpty(); - users = dao.findUsersForNotification("NewViolations", "Email", "uuid_45"); + users = dao.selectUsersForNotification("NewViolations", "Email", "uuid_45"); assertThat(users).hasSize(1); assertThat(users).containsOnly("user2"); - users = dao.findUsersForNotification("NewViolations", "Twitter", null); + users = dao.selectUsersForNotification("NewViolations", "Twitter", null); assertThat(users).hasSize(1); assertThat(users).containsOnly("user3"); - users = dao.findUsersForNotification("NewViolations", "Twitter", "uuid_78"); + users = dao.selectUsersForNotification("NewViolations", "Twitter", "uuid_78"); assertThat(users).isEmpty(); - users = dao.findUsersForNotification("NewViolations", "Twitter", "uuid_56"); + users = dao.selectUsersForNotification("NewViolations", "Twitter", "uuid_56"); assertThat(users).hasSize(2); assertThat(users).containsOnly("user1", "user3"); } @@ -77,22 +77,22 @@ public class PropertiesDaoTest { dbTester.prepareDbUnit(getClass(), "findNotificationSubscribers.xml"); // Nobody is subscribed - List<String> users = dao.findNotificationSubscribers("NotSexyDispatcher", "Email", "org.apache:struts"); + List<String> users = dao.selectNotificationSubscribers("NotSexyDispatcher", "Email", "org.apache:struts"); assertThat(users).isEmpty(); // Global subscribers - users = dao.findNotificationSubscribers("DispatcherWithGlobalSubscribers", "Email", "org.apache:struts"); + users = dao.selectNotificationSubscribers("DispatcherWithGlobalSubscribers", "Email", "org.apache:struts"); assertThat(users).containsOnly("simon"); - users = dao.findNotificationSubscribers("DispatcherWithGlobalSubscribers", "Email", null); + users = dao.selectNotificationSubscribers("DispatcherWithGlobalSubscribers", "Email", null); assertThat(users).containsOnly("simon"); // Project subscribers - users = dao.findNotificationSubscribers("DispatcherWithProjectSubscribers", "Email", "org.apache:struts"); + users = dao.selectNotificationSubscribers("DispatcherWithProjectSubscribers", "Email", "org.apache:struts"); assertThat(users).containsOnly("eric"); // Global + Project subscribers - users = dao.findNotificationSubscribers("DispatcherWithGlobalAndProjectSubscribers", "Email", "org.apache:struts"); + users = dao.selectNotificationSubscribers("DispatcherWithGlobalAndProjectSubscribers", "Email", "org.apache:struts"); assertThat(users).containsOnly("eric", "simon"); } @@ -200,10 +200,10 @@ public class PropertiesDaoTest { public void setProperty_update() { dbTester.prepareDbUnit(getClass(), "update.xml"); - dao.setProperty(new PropertyDto().setKey("global.key").setValue("new_global")); - dao.setProperty(new PropertyDto().setKey("project.key").setResourceId(10L).setValue("new_project")); - dao.setProperty(new PropertyDto().setKey("user.key").setUserId(100L).setValue("new_user")); - dao.setProperty(new PropertyDto().setKey("null.value").setValue(null)); + dao.insertProperty(new PropertyDto().setKey("global.key").setValue("new_global")); + dao.insertProperty(new PropertyDto().setKey("project.key").setResourceId(10L).setValue("new_project")); + dao.insertProperty(new PropertyDto().setKey("user.key").setUserId(100L).setValue("new_user")); + dao.insertProperty(new PropertyDto().setKey("null.value").setValue(null)); dbTester.assertDbUnit(getClass(), "update-result.xml", "properties"); } @@ -212,9 +212,9 @@ public class PropertiesDaoTest { public void setProperty_insert() { dbTester.prepareDbUnit(getClass(), "insert.xml"); - dao.setProperty(new PropertyDto().setKey("global.key").setValue("new_global")); - dao.setProperty(new PropertyDto().setKey("project.key").setResourceId(10L).setValue("new_project")); - dao.setProperty(new PropertyDto().setKey("user.key").setUserId(100L).setValue("new_user")); + dao.insertProperty(new PropertyDto().setKey("global.key").setValue("new_global")); + dao.insertProperty(new PropertyDto().setKey("project.key").setResourceId(10L).setValue("new_project")); + dao.insertProperty(new PropertyDto().setKey("user.key").setUserId(100L).setValue("new_user")); dbTester.assertDbUnit(getClass(), "insert-result.xml", "properties"); } @@ -268,7 +268,7 @@ public class PropertiesDaoTest { public void insertGlobalProperties() { dbTester.prepareDbUnit(getClass(), "insertGlobalProperties.xml"); - dao.saveGlobalProperties(ImmutableMap.of("to_be_inserted", "inserted")); + dao.insertGlobalProperties(ImmutableMap.of("to_be_inserted", "inserted")); dbTester.assertDbUnitTable(getClass(), "insertGlobalProperties-result.xml", "properties", "prop_key", "text_value", "resource_id", "user_id"); } @@ -277,7 +277,7 @@ public class PropertiesDaoTest { public void updateGlobalProperties() { dbTester.prepareDbUnit(getClass(), "updateGlobalProperties.xml"); - dao.saveGlobalProperties(ImmutableMap.of("to_be_updated", "updated")); + dao.insertGlobalProperties(ImmutableMap.of("to_be_updated", "updated")); dbTester.assertDbUnitTable(getClass(), "updateGlobalProperties-result.xml", "properties", "prop_key", "text_value", "resource_id", "user_id"); } diff --git a/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java b/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java index 2343d2fd518..3702c6b5755 100644 --- a/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java @@ -92,7 +92,7 @@ public class QualityProfileDaoTest { public void find_all() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - List<QualityProfileDto> dtos = dao.findAll(dbTester.getSession()); + List<QualityProfileDto> dtos = dao.selectAll(dbTester.getSession()); assertThat(dtos).hasSize(2); @@ -113,7 +113,7 @@ public class QualityProfileDaoTest { public void find_all_is_sorted_by_profile_name() { dbTester.prepareDbUnit(getClass(), "select_all_is_sorted_by_profile_name.xml"); - List<QualityProfileDto> dtos = dao.findAll(); + List<QualityProfileDto> dtos = dao.selectAll(); assertThat(dtos).hasSize(3); assertThat(dtos.get(0).getName()).isEqualTo("First"); @@ -125,32 +125,32 @@ public class QualityProfileDaoTest { public void get_default_profile() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - QualityProfileDto java = dao.getDefaultProfile("java"); + QualityProfileDto java = dao.selectDefaultProfile("java"); assertThat(java).isNotNull(); assertThat(java.getKey()).isEqualTo("java_sonar_way"); - assertThat(dao.getDefaultProfile("js")).isNull(); + assertThat(dao.selectDefaultProfile("js")).isNull(); } @Test public void get_by_name_and_language() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - QualityProfileDto dto = dao.getByNameAndLanguage("Sonar Way", "java", dbTester.getSession()); + QualityProfileDto dto = dao.selectByNameAndLanguage("Sonar Way", "java", dbTester.getSession()); assertThat(dto.getId()).isEqualTo(1); assertThat(dto.getName()).isEqualTo("Sonar Way"); assertThat(dto.getLanguage()).isEqualTo("java"); assertThat(dto.getParentKee()).isNull(); - assertThat(dao.getByNameAndLanguage("Sonar Way", "java", dbTester.getSession())).isNotNull(); - assertThat(dao.getByNameAndLanguage("Sonar Way", "unknown", dbTester.getSession())).isNull(); + assertThat(dao.selectByNameAndLanguage("Sonar Way", "java", dbTester.getSession())).isNotNull(); + assertThat(dao.selectByNameAndLanguage("Sonar Way", "unknown", dbTester.getSession())).isNull(); } @Test public void find_by_language() { dbTester.prepareDbUnit(getClass(), "select_by_language.xml"); - List<QualityProfileDto> result = dao.findByLanguage("java"); + List<QualityProfileDto> result = dao.selectByLanguage("java"); assertThat(result).hasSize(2); assertThat(result.get(0).getName()).isEqualTo("Sonar Way 1"); assertThat(result.get(1).getName()).isEqualTo("Sonar Way 2"); @@ -160,20 +160,20 @@ public class QualityProfileDaoTest { public void get_by_id() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - QualityProfileDto dto = dao.getById(1); + QualityProfileDto dto = dao.selectById(1); assertThat(dto.getId()).isEqualTo(1); assertThat(dto.getName()).isEqualTo("Sonar Way"); assertThat(dto.getLanguage()).isEqualTo("java"); assertThat(dto.getParentKee()).isNull(); - assertThat(dao.getById(555)).isNull(); + assertThat(dao.selectById(555)).isNull(); } @Test public void get_parent_by_id() { dbTester.prepareDbUnit(getClass(), "inheritance.xml"); - QualityProfileDto dto = dao.getParentById(1); + QualityProfileDto dto = dao.selectParentById(1); assertThat(dto.getId()).isEqualTo(3); } @@ -181,7 +181,7 @@ public class QualityProfileDaoTest { public void find_children() { dbTester.prepareDbUnit(getClass(), "inheritance.xml"); - List<QualityProfileDto> dtos = dao.findChildren(dbTester.getSession(), "java_parent"); + List<QualityProfileDto> dtos = dao.selectChildren(dbTester.getSession(), "java_parent"); assertThat(dtos).hasSize(2); @@ -225,7 +225,7 @@ public class QualityProfileDaoTest { public void select_by_project_id_and_language() { dbTester.prepareDbUnit(getClass(), "projects.xml"); - QualityProfileDto dto = dao.getByProjectAndLanguage(1L, "java"); + QualityProfileDto dto = dao.selectByProjectAndLanguage(1L, "java"); assertThat(dto.getId()).isEqualTo(1); } @@ -233,10 +233,10 @@ public class QualityProfileDaoTest { public void select_by_project_key_and_language() { dbTester.prepareDbUnit(getClass(), "projects.xml"); - QualityProfileDto dto = dao.getByProjectAndLanguage("org.codehaus.sonar:sonar", "java", dbTester.getSession()); + QualityProfileDto dto = dao.selectByProjectAndLanguage(dbTester.getSession(), "org.codehaus.sonar:sonar", "java"); assertThat(dto.getId()).isEqualTo(1); - assertThat(dao.getByProjectAndLanguage("org.codehaus.sonar:sonar", "unkown", dbTester.getSession())).isNull(); - assertThat(dao.getByProjectAndLanguage("unknown", "java", dbTester.getSession())).isNull(); + assertThat(dao.selectByProjectAndLanguage(dbTester.getSession(), "org.codehaus.sonar:sonar", "unkown")).isNull(); + assertThat(dao.selectByProjectAndLanguage(dbTester.getSession(), "unknown", "java")).isNull(); } } diff --git a/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java b/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java index 4389dc9a5d6..003f0a46ff0 100644 --- a/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java @@ -62,7 +62,7 @@ public class GroupDaoTest { public void select_by_key() { dbTester.prepareDbUnit(getClass(), "select_by_key.xml"); - GroupDto group = new GroupDao(system2).selectByKey(session, "sonar-users"); + GroupDto group = new GroupDao(system2).selectOrFailByKey(session, "sonar-users"); assertThat(group).isNotNull(); assertThat(group.getId()).isEqualTo(1L); assertThat(group.getName()).isEqualTo("sonar-users"); @@ -75,7 +75,7 @@ public class GroupDaoTest { public void select_by_id() { dbTester.prepareDbUnit(getClass(), "select_by_key.xml"); - GroupDto group = new GroupDao(system2).selectById(session, 1L); + GroupDto group = new GroupDao(system2).selectOrFailById(session, 1L); assertThat(group).isNotNull(); assertThat(group.getId()).isEqualTo(1L); assertThat(group.getName()).isEqualTo("sonar-users"); @@ -88,8 +88,8 @@ public class GroupDaoTest { public void find_by_user_login() { dbTester.prepareDbUnit(getClass(), "find_by_user_login.xml"); - assertThat(dao.findByUserLogin(session, "john")).hasSize(2); - assertThat(dao.findByUserLogin(session, "max")).isEmpty(); + assertThat(dao.selectByUserLogin(session, "john")).hasSize(2); + assertThat(dao.selectByUserLogin(session, "max")).isEmpty(); } @Test diff --git a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java index f1f366f6446..de44fe8ba15 100644 --- a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java @@ -68,7 +68,7 @@ public class UserDaoTest { public void selectUserByLogin_ignore_inactive() { db.prepareDbUnit(getClass(), "selectActiveUserByLogin.xml"); - UserDto user = underTest.getUser(50); + UserDto user = underTest.selectUserById(50); assertThat(user.getLogin()).isEqualTo("inactive_user"); user = underTest.selectActiveUserByLogin("inactive_user"); @@ -233,7 +233,7 @@ public class UserDaoTest { underTest.update(db.getSession(), userDto); db.getSession().commit(); - UserDto user = underTest.getUser(1); + UserDto user = underTest.selectUserById(1); assertThat(user).isNotNull(); assertThat(user.getId()).isEqualTo(1L); assertThat(user.getLogin()).isEqualTo("john"); @@ -259,7 +259,7 @@ public class UserDaoTest { assertThat(underTest.selectActiveUserByLogin(login)).isNull(); - UserDto userDto = underTest.getUser(100); + UserDto userDto = underTest.selectUserById(100); assertThat(userDto.isActive()).isFalse(); assertThat(userDto.getUpdatedAt()).isEqualTo(1500000000000L); @@ -283,7 +283,7 @@ public class UserDaoTest { public void select_by_login() { db.prepareDbUnit(getClass(), "select_by_login.xml"); - UserDto dto = underTest.selectByLogin(session, "marius"); + UserDto dto = underTest.selectOrFailByLogin(session, "marius"); assertThat(dto.getId()).isEqualTo(101); assertThat(dto.getLogin()).isEqualTo("marius"); assertThat(dto.getName()).isEqualTo("Marius"); @@ -300,26 +300,26 @@ public class UserDaoTest { public void select_nullable_by_scm_account() { db.prepareDbUnit(getClass(), "select_nullable_by_scm_account.xml"); - List<UserDto> results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "ma"); + List<UserDto> results = underTest.selectByScmAccountOrLoginOrEmail(session, "ma"); assertThat(results).hasSize(1); assertThat(results.get(0).getLogin()).isEqualTo("marius"); - results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "marius"); + results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius"); assertThat(results).hasSize(1); assertThat(results.get(0).getLogin()).isEqualTo("marius"); - results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); + results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); assertThat(results).hasSize(1); assertThat(results.get(0).getLogin()).isEqualTo("marius"); - results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); + results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); assertThat(results).hasSize(1); assertThat(results.get(0).getLogin()).isEqualTo("marius"); - results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "m"); + results = underTest.selectByScmAccountOrLoginOrEmail(session, "m"); assertThat(results).isEmpty(); - results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "unknown"); + results = underTest.selectByScmAccountOrLoginOrEmail(session, "unknown"); assertThat(results).isEmpty(); } @@ -327,14 +327,14 @@ public class UserDaoTest { public void select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users() { db.prepareDbUnit(getClass(), "select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users.xml"); - List<UserDto> results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); + List<UserDto> results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); assertThat(results).hasSize(2); } @Test public void select_by_login_with_unknown_login() { try { - underTest.selectByLogin(session, "unknown"); + underTest.selectOrFailByLogin(session, "unknown"); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(RowNotFoundException.class).hasMessage("User with login 'unknown' has not been found"); @@ -345,8 +345,8 @@ public class UserDaoTest { public void select_nullable_by_login() { db.prepareDbUnit(getClass(), "select_by_login.xml"); - assertThat(underTest.selectNullableByLogin(session, "marius")).isNotNull(); + assertThat(underTest.selectByLogin(session, "marius")).isNotNull(); - assertThat(underTest.selectNullableByLogin(session, "unknown")).isNull(); + assertThat(underTest.selectByLogin(session, "unknown")).isNull(); } } |