From 842ad772c962eba68b9ba2dfcce00f8cdf2d0cfc Mon Sep 17 00:00:00 2001 From: rma-rripken Date: Wed, 3 Jul 2024 17:41:05 -0700 Subject: [PATCH] Renamed children to childLocations --- .../src/main/java/cwms/cda/ApiServlet.java | 4 +- ....java => ProjectChildLocationHandler.java} | 24 +++--- ...nDao.java => ProjectChildLocationDao.java} | 58 +++++++-------- ...ildren.java => ProjectChildLocations.java} | 14 ++-- ...ava => ProjectChildLocationHandlerIT.java} | 4 +- ...st.java => ProjectChildLocationsTest.java} | 73 +++++++++---------- 6 files changed, 86 insertions(+), 91 deletions(-) rename cwms-data-api/src/main/java/cwms/cda/api/project/{ProjectChildrenHandler.java => ProjectChildLocationHandler.java} (85%) rename cwms-data-api/src/main/java/cwms/cda/data/dao/project/{ProjectChildrenDao.java => ProjectChildLocationDao.java} (79%) rename cwms-data-api/src/main/java/cwms/cda/data/dto/project/{ProjectChildren.java => ProjectChildLocations.java} (90%) rename cwms-data-api/src/test/java/cwms/cda/api/project/{ProjectChildrenHandlerIT.java => ProjectChildLocationHandlerIT.java} (98%) rename cwms-data-api/src/test/java/cwms/cda/data/dto/project/{ProjectChildrenTest.java => ProjectChildLocationsTest.java} (73%) diff --git a/cwms-data-api/src/main/java/cwms/cda/ApiServlet.java b/cwms-data-api/src/main/java/cwms/cda/ApiServlet.java index 676012fe5..b1852699e 100644 --- a/cwms-data-api/src/main/java/cwms/cda/ApiServlet.java +++ b/cwms-data-api/src/main/java/cwms/cda/ApiServlet.java @@ -100,7 +100,7 @@ import cwms.cda.api.errors.JsonFieldsException; import cwms.cda.api.errors.NotFoundException; import cwms.cda.api.errors.RequiredQueryParameterException; -import cwms.cda.api.project.ProjectChildrenHandler; +import cwms.cda.api.project.ProjectChildLocationHandler; import cwms.cda.api.location.kind.VirtualOutletCreateController; import cwms.cda.data.dao.JooqDao; import cwms.cda.formatters.Formats; @@ -520,7 +520,7 @@ protected void configureRoutes() { cdaCrudCache(virtualOutletPath, new VirtualOutletController(metrics), requiredRoles, 1, TimeUnit.DAYS); post(virtualOutletCreatePath, new VirtualOutletCreateController(metrics)); - get("/projects/children/", new ProjectChildrenHandler(metrics)); + get("/projects/child-locations/", new ProjectChildLocationHandler(metrics)); cdaCrudCache(format("/projects/{%s}", Controllers.NAME), new ProjectController(metrics), requiredRoles,5, TimeUnit.MINUTES); cdaCrudCache(format("/properties/{%s}", Controllers.NAME), diff --git a/cwms-data-api/src/main/java/cwms/cda/api/project/ProjectChildrenHandler.java b/cwms-data-api/src/main/java/cwms/cda/api/project/ProjectChildLocationHandler.java similarity index 85% rename from cwms-data-api/src/main/java/cwms/cda/api/project/ProjectChildrenHandler.java rename to cwms-data-api/src/main/java/cwms/cda/api/project/ProjectChildLocationHandler.java index 25c5267ae..e8349bf16 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/project/ProjectChildrenHandler.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/project/ProjectChildLocationHandler.java @@ -37,8 +37,8 @@ import com.codahale.metrics.Timer; import cwms.cda.api.Controllers; import cwms.cda.data.dao.JooqDao; -import cwms.cda.data.dao.project.ProjectChildrenDao; -import cwms.cda.data.dto.project.ProjectChildren; +import cwms.cda.data.dao.project.ProjectChildLocationDao; +import cwms.cda.data.dto.project.ProjectChildLocations; import cwms.cda.formatters.ContentType; import cwms.cda.formatters.Formats; import io.javalin.core.util.Header; @@ -54,9 +54,9 @@ import org.jetbrains.annotations.NotNull; -public class ProjectChildrenHandler implements Handler { +public class ProjectChildLocationHandler implements Handler { public static final String TAGS = "Projects"; - public static final String PATH = "/projects/children"; + public static final String PATH = "/projects/child-locations/"; private final MetricRegistry metrics; private final Histogram requestResultSize; @@ -64,9 +64,9 @@ private Timer.Context markAndTime(String subject) { return Controllers.markAndTime(metrics, getClass().getName(), subject); } - public ProjectChildrenHandler(MetricRegistry metrics) { + public ProjectChildLocationHandler(MetricRegistry metrics) { this.metrics = metrics; - requestResultSize = this.metrics.histogram((name(ProjectChildrenHandler.class, Controllers.RESULTS, + requestResultSize = this.metrics.histogram((name(ProjectChildLocationHandler.class, Controllers.RESULTS, Controllers.SIZE))); } @@ -80,14 +80,14 @@ public ProjectChildrenHandler(MetricRegistry metrics) { @OpenApiParam(name = LOCATION_KIND_LIKE, description = "Posix regular expression matching against the " + "location kind. The pattern will be matched against " - + "the valid location-kinds for Project Children:" + + "the valid location-kinds for Project child locations:" + "{\"EMBANKMENT\", \"TURBINE\", \"OUTLET\", \"LOCK\", \"GATE\"}. " + "Multiple kinds can be matched by using Regular Expression " + "OR clauses. For example: \"(TURBINE|OUTLET)\"") }, responses = { @OpenApiResponse(status = STATUS_200, content = { - @OpenApiContent(type = Formats.JSON, from = ProjectChildren.class, isArray = true)}) + @OpenApiContent(type = Formats.JSON, from = ProjectChildLocations.class, isArray = true)}) }, tags = {TAGS}, path = PATH, @@ -97,14 +97,14 @@ public ProjectChildrenHandler(MetricRegistry metrics) { public void handle(@NotNull Context ctx) throws Exception { String office = requiredParam(ctx, OFFICE); try (Timer.Context ignored = markAndTime(GET_ALL)) { - ProjectChildrenDao lockDao = new ProjectChildrenDao(JooqDao.getDslContext(ctx)); + ProjectChildLocationDao lockDao = new ProjectChildLocationDao(JooqDao.getDslContext(ctx)); String projLike = ctx.queryParamAsClass(PROJECT_LIKE, String.class).getOrDefault(null); String kindLike = ctx.queryParamAsClass(LOCATION_KIND_LIKE, String.class).getOrDefault(null); - List children = lockDao.children(office, projLike, kindLike); + List childLocations = lockDao.retrieveProjectChildLocations(office, projLike, kindLike); String formatHeader = ctx.header(Header.ACCEPT); - ContentType contentType = Formats.parseHeader(formatHeader, ProjectChildren.class); - String result = Formats.format(contentType, children, ProjectChildren.class); + ContentType contentType = Formats.parseHeader(formatHeader, ProjectChildLocations.class); + String result = Formats.format(contentType, childLocations, ProjectChildLocations.class); ctx.result(result).contentType(contentType.toString()); requestResultSize.update(result.length()); ctx.status(HttpServletResponse.SC_OK); diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dao/project/ProjectChildrenDao.java b/cwms-data-api/src/main/java/cwms/cda/data/dao/project/ProjectChildLocationDao.java similarity index 79% rename from cwms-data-api/src/main/java/cwms/cda/data/dao/project/ProjectChildrenDao.java rename to cwms-data-api/src/main/java/cwms/cda/data/dao/project/ProjectChildLocationDao.java index 74331d451..8d97702cf 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dao/project/ProjectChildrenDao.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dao/project/ProjectChildLocationDao.java @@ -26,7 +26,7 @@ import cwms.cda.data.dao.JooqDao; import cwms.cda.data.dto.CwmsId; -import cwms.cda.data.dto.project.ProjectChildren; +import cwms.cda.data.dto.project.ProjectChildLocations; import java.util.*; import java.util.stream.Collectors; @@ -37,29 +37,29 @@ import usace.cwms.db.jooq.codegen.tables.AV_OUTLET; import usace.cwms.db.jooq.codegen.tables.AV_TURBINE; -public class ProjectChildrenDao extends JooqDao { +public class ProjectChildLocationDao extends JooqDao { - public ProjectChildrenDao(DSLContext dsl) { + public ProjectChildLocationDao(DSLContext dsl) { super(dsl); } - public List children(String office, String projLike, String kindRegex) { - return children(office, projLike, ProjectKind.getMatchingKinds(kindRegex)); + public List retrieveProjectChildLocations(String office, String projLike, String kindRegex) { + return retrieveProjectChildLocations(office, projLike, ProjectKind.getMatchingKinds(kindRegex)); } - private List children(String office, String projLike, Set kinds) { + private List retrieveProjectChildLocations(String office, String projLike, Set kinds) { - Map builderMap = new LinkedHashMap<>(); // proj-id-> + Map builderMap = new LinkedHashMap<>(); // proj-id-> for (ProjectKind kind : kinds) { - Map> locsOfKind = getChildrenOfKind(office, projLike, kind); + Map> locsOfKind = getChildLocationsOfKind(office, projLike, kind); if (locsOfKind != null) { for (Map.Entry> entry : locsOfKind.entrySet()) { String projId = entry.getKey(); List locs = entry.getValue(); - ProjectChildren.Builder builder = builderMap.computeIfAbsent(projId, k -> - new ProjectChildren.Builder() + ProjectChildLocations.Builder builder = builderMap.computeIfAbsent(projId, k -> + new ProjectChildLocations.Builder() .withProject(new CwmsId.Builder() .withOfficeId(office) .withName(projId) @@ -83,38 +83,35 @@ private List children(String office, String projLike, Set> getChildrenOfKind(String office, String projLike, ProjectKind kind) { + private Map> getChildLocationsOfKind(String office, String projRegex, ProjectKind kind) { switch (kind) { - case EMBANKMENT: - return getEmbankmentChildren(office, projLike); + return getEmbankmentChildLocations(office, projRegex); case TURBINE: - return getTurbineChildren(office, projLike); + return getTurbineChildLocations(office, projRegex); case OUTLET: - return getOutletChildren(office, projLike); + return getOutletChildLocations(office, projRegex); case LOCK: - return getLockChildren(office, projLike); + return getLockChildLocations(office, projRegex); case GATE: - return getGateChildren(office, projLike); + return getGateChildLocations(office, projRegex); default: return null; } } - private Map> getGateChildren(String office, @Nullable String projLike) { + private Map> getGateChildLocations(String office, @Nullable String projRegex) { Map> retval = new LinkedHashMap<>(); // AV_GATE is apparently not used. AV_OUTLET view = AV_OUTLET.AV_OUTLET; @@ -123,7 +120,7 @@ private Map> getGateChildren(String office, @Nullable Strin .where(view.OFFICE_ID.eq(office) .and(view.OPENING_UNIT_EN.isNotNull().or(view.OPENING_UNIT_SI.isNotNull())) ) - .and(caseInsensitiveLikeRegexNullTrue(view.PROJECT_ID, projLike)) + .and(caseInsensitiveLikeRegexNullTrue(view.PROJECT_ID, projRegex)) .orderBy(view.OFFICE_ID, view.PROJECT_ID, view.OUTLET_ID) .forEach(row -> { String projId = row.get(view.PROJECT_ID); @@ -137,13 +134,13 @@ private Map> getGateChildren(String office, @Nullable Strin return retval; } - private Map> getLockChildren(String office, String projLike) { + private Map> getLockChildLocations(String office, @Nullable String projRegex) { Map> retval = new LinkedHashMap<>(); AV_LOCK view = AV_LOCK.AV_LOCK; dsl.selectDistinct(view.DB_OFFICE_ID, view.LOCK_ID, view.PROJECT_ID) .from(view) .where(view.DB_OFFICE_ID.eq(office)) - .and(caseInsensitiveLikeRegexNullTrue(view.PROJECT_ID, projLike)) + .and(caseInsensitiveLikeRegexNullTrue(view.PROJECT_ID, projRegex)) .orderBy(view.DB_OFFICE_ID, view.PROJECT_ID, view.LOCK_ID) .forEach(row -> { String projId = row.get(view.PROJECT_ID); @@ -157,13 +154,13 @@ private Map> getLockChildren(String office, String projLike return retval; } - private Map> getOutletChildren(String office, String projLike) { + private Map> getOutletChildLocations(String office, @Nullable String projRegex) { Map> retval = new LinkedHashMap<>(); AV_OUTLET view = AV_OUTLET.AV_OUTLET; dsl.selectDistinct(view.OFFICE_ID, view.OUTLET_ID, view.PROJECT_ID) .from(view) .where(view.OFFICE_ID.eq(office)) - .and(caseInsensitiveLikeRegexNullTrue(view.PROJECT_ID, projLike)) + .and(caseInsensitiveLikeRegexNullTrue(view.PROJECT_ID, projRegex)) .orderBy(view.OFFICE_ID, view.PROJECT_ID, view.OUTLET_ID) .forEach(row -> { String projId = row.get(view.PROJECT_ID); @@ -177,13 +174,13 @@ private Map> getOutletChildren(String office, String projLi return retval; } - private Map> getTurbineChildren(String office, String projLike) { + private Map> getTurbineChildLocations(String office, @Nullable String projRegex) { Map> retval = new LinkedHashMap<>(); AV_TURBINE view = AV_TURBINE.AV_TURBINE; dsl.selectDistinct(view.OFFICE_ID, view.TURBINE_ID, view.PROJECT_ID) .from(view) .where(view.OFFICE_ID.eq(office)) - .and(caseInsensitiveLikeRegexNullTrue(view.PROJECT_ID, projLike)) + .and(caseInsensitiveLikeRegexNullTrue(view.PROJECT_ID, projRegex)) .orderBy(view.OFFICE_ID, view.PROJECT_ID, view.TURBINE_ID) .forEach(row -> { String projId = row.get(view.PROJECT_ID); @@ -197,14 +194,14 @@ private Map> getTurbineChildren(String office, String projL return retval; } - private Map> getEmbankmentChildren(String office, String projLike) { + private Map> getEmbankmentChildLocations(String office, @Nullable String projRegex) { Map> retval = new LinkedHashMap<>(); AV_EMBANKMENT view = AV_EMBANKMENT.AV_EMBANKMENT; dsl.selectDistinct(view.OFFICE_ID, view.EMBANKMENT_LOCATION_ID, view.PROJECT_ID) .from(view) .where(view.OFFICE_ID.eq(office) .and(view.UNIT_SYSTEM.eq("SI"))) - .and(caseInsensitiveLikeRegexNullTrue(view.PROJECT_ID, projLike)) + .and(caseInsensitiveLikeRegexNullTrue(view.PROJECT_ID, projRegex)) .orderBy(view.OFFICE_ID, view.PROJECT_ID, view.EMBANKMENT_LOCATION_ID) .forEach(row -> { String projId = row.get(view.PROJECT_ID); @@ -218,5 +215,4 @@ private Map> getEmbankmentChildren(String office, String pr return retval; } - } diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dto/project/ProjectChildren.java b/cwms-data-api/src/main/java/cwms/cda/data/dto/project/ProjectChildLocations.java similarity index 90% rename from cwms-data-api/src/main/java/cwms/cda/data/dto/project/ProjectChildren.java rename to cwms-data-api/src/main/java/cwms/cda/data/dto/project/ProjectChildLocations.java index 2434ab8c2..9c34e5a89 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dto/project/ProjectChildren.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dto/project/ProjectChildLocations.java @@ -39,13 +39,13 @@ import org.jetbrains.annotations.Nullable; /** - * This class holds a project and lists of the project children by kind. + * This class holds a project and lists of the project child locations by kind. */ -@JsonDeserialize(builder = ProjectChildren.Builder.class) +@JsonDeserialize(builder = ProjectChildLocations.Builder.class) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class) -@FormattableWith(contentType = Formats.JSON, formatter = JsonV2.class) -public class ProjectChildren implements CwmsDTOBase { +@FormattableWith(contentType = Formats.JSONV2, aliases = {Formats.JSON}, formatter = JsonV2.class) +public class ProjectChildLocations implements CwmsDTOBase { private final CwmsId project; @@ -55,7 +55,7 @@ public class ProjectChildren implements CwmsDTOBase { private final List turbines; private final List gates; - private ProjectChildren(Builder builder) { + private ProjectChildLocations(Builder builder) { this.project = builder.project; this.embankments = builder.embankments; this.locks = builder.locks; @@ -142,8 +142,8 @@ private static List wrapList(@Nullable List embankments) { return retval; } - public ProjectChildren build() { - return new ProjectChildren(this); + public ProjectChildLocations build() { + return new ProjectChildLocations(this); } } } diff --git a/cwms-data-api/src/test/java/cwms/cda/api/project/ProjectChildrenHandlerIT.java b/cwms-data-api/src/test/java/cwms/cda/api/project/ProjectChildLocationHandlerIT.java similarity index 98% rename from cwms-data-api/src/test/java/cwms/cda/api/project/ProjectChildrenHandlerIT.java rename to cwms-data-api/src/test/java/cwms/cda/api/project/ProjectChildLocationHandlerIT.java index 3f6883763..d618d56bf 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/project/ProjectChildrenHandlerIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/project/ProjectChildLocationHandlerIT.java @@ -59,7 +59,7 @@ import org.junit.jupiter.api.Test; @Tag("integration") -public class ProjectChildrenHandlerIT extends DataApiTestIT { +public class ProjectChildLocationHandlerIT extends DataApiTestIT { public static final String OFFICE = "SPK"; @@ -121,7 +121,7 @@ void test_get_embankment() throws Exception { .when() .redirects().follow(true) .redirects().max(3) - .get("/projects/children/") + .get("/projects/child-locations/") .then() .log().ifValidationFails(LogDetail.ALL, true) .assertThat() diff --git a/cwms-data-api/src/test/java/cwms/cda/data/dto/project/ProjectChildrenTest.java b/cwms-data-api/src/test/java/cwms/cda/data/dto/project/ProjectChildLocationsTest.java similarity index 73% rename from cwms-data-api/src/test/java/cwms/cda/data/dto/project/ProjectChildrenTest.java rename to cwms-data-api/src/test/java/cwms/cda/data/dto/project/ProjectChildLocationsTest.java index c3e8b808e..3ac794246 100644 --- a/cwms-data-api/src/test/java/cwms/cda/data/dto/project/ProjectChildrenTest.java +++ b/cwms-data-api/src/test/java/cwms/cda/data/dto/project/ProjectChildLocationsTest.java @@ -40,7 +40,7 @@ import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; -class ProjectChildrenTest { +class ProjectChildLocationsTest { public static final String OFFICE = "SPK"; @@ -66,7 +66,7 @@ void test_ctor(){ List outlets = new ArrayList<>(); outlets.add(buildId(OFFICE, "TestOutlet1")); - ProjectChildren projectChildren = new ProjectChildren.Builder() + ProjectChildLocations projectChildLocations = new ProjectChildLocations.Builder() .withProject(proj) .withEmbankments(embanks) .withLocks(locks) @@ -74,20 +74,20 @@ void test_ctor(){ .withTurbines(turbines) .withOutlets(outlets) .build(); - assertNotNull(projectChildren); + assertNotNull(projectChildLocations); - assertEquals(proj, projectChildren.getProject()); - assertEquals(embanks, projectChildren.getEmbankments()); - assertEquals(locks, projectChildren.getLocks()); + assertEquals(proj, projectChildLocations.getProject()); + assertEquals(embanks, projectChildLocations.getEmbankments()); + assertEquals(locks, projectChildLocations.getLocks()); - String json = Formats.format(new ContentType(Formats.JSON), projectChildren); + String json = Formats.format(new ContentType(Formats.JSON), projectChildLocations); assertNotNull(json); } - private ProjectChildren buildTestProjectChildren(String office, String projectName) { + private ProjectChildLocations buildTestProjectChildLocations(String office, String projectName) { CwmsId proj = buildId(office, projectName); List embanks = new ArrayList<>(); @@ -108,7 +108,7 @@ private ProjectChildren buildTestProjectChildren(String office, String projectNa List outlets = new ArrayList<>(); outlets.add(buildId(office, "TestOutlet1")); - return new ProjectChildren.Builder() + return new ProjectChildLocations.Builder() .withProject(proj) .withEmbankments(embanks) .withLocks(locks) @@ -120,12 +120,12 @@ private ProjectChildren buildTestProjectChildren(String office, String projectNa @Test void test_list_serialization(){ - List list = new ArrayList<>(); + List list = new ArrayList<>(); - list.add(buildTestProjectChildren(OFFICE, "TestProject1")); - list.add(buildTestProjectChildren(OFFICE, "TestProject2")); + list.add(buildTestProjectChildLocations(OFFICE, "TestProject1")); + list.add(buildTestProjectChildLocations(OFFICE, "TestProject2")); - String json = Formats.format(new ContentType(Formats.JSON), list, ProjectChildren.class); + String json = Formats.format(new ContentType(Formats.JSON), list, ProjectChildLocations.class); assertNotNull(json); assertFalse(json.isEmpty()); assertTrue(json.contains("TestProject1")); @@ -140,7 +140,7 @@ void test_list_deserialization() throws IOException { String input = IOUtils.toString(stream, StandardCharsets.UTF_8); ObjectMapper om = JsonV2.buildObjectMapper(); - List list = om.readValue(input, new TypeReference>(){}); + List list = om.readValue(input, new TypeReference>(){}); assertNotNull(list); assertFalse(list.isEmpty()); @@ -155,15 +155,15 @@ void testDeserialize() throws IOException { String input = IOUtils.toString(stream, StandardCharsets.UTF_8); ObjectMapper om = JsonV2.buildObjectMapper(); - ProjectChildren projectChildren = om.readValue(input, ProjectChildren.class); - assertNotNull(projectChildren); + ProjectChildLocations projectChildLocations = om.readValue(input, ProjectChildLocations.class); + assertNotNull(projectChildLocations); - CwmsId project = projectChildren.getProject(); + CwmsId project = projectChildLocations.getProject(); assertNotNull(project); assertEquals("SPK", project.getOfficeId()); assertEquals("TestProject", project.getName()); - List embankments = projectChildren.getEmbankments(); + List embankments = projectChildLocations.getEmbankments(); assertNotNull(embankments); assertEquals(2, embankments.size()); assertEquals("SPK", embankments.get(0).getOfficeId()); @@ -171,7 +171,7 @@ void testDeserialize() throws IOException { assertEquals("SPK", embankments.get(1).getOfficeId()); assertEquals("TestEmbankment2", embankments.get(1).getName()); - List locks = projectChildren.getLocks(); + List locks = projectChildLocations.getLocks(); assertNotNull(locks); assertEquals(3, locks.size()); assertEquals("SPK", locks.get(0).getOfficeId()); @@ -181,19 +181,19 @@ void testDeserialize() throws IOException { assertEquals("SPK", locks.get(2).getOfficeId()); assertEquals("TestLock3", locks.get(2).getName()); - List outlets = projectChildren.getOutlets(); + List outlets = projectChildLocations.getOutlets(); assertNotNull(outlets); assertEquals(1, outlets.size()); assertEquals("SPK", outlets.get(0).getOfficeId()); assertEquals("TestOutlet1", outlets.get(0).getName()); - List turbines = projectChildren.getTurbines(); + List turbines = projectChildLocations.getTurbines(); assertNotNull(turbines); assertEquals(1, turbines.size()); assertEquals("SPK", turbines.get(0).getOfficeId()); assertEquals("TestTurbine1", turbines.get(0).getName()); - List gates = projectChildren.getGates(); + List gates = projectChildLocations.getGates(); assertNotNull(gates); assertEquals(1, gates.size()); assertEquals("SPK", gates.get(0).getOfficeId()); @@ -208,25 +208,24 @@ void testRoundtrip() throws IOException { String input = IOUtils.toString(stream, StandardCharsets.UTF_8); ObjectMapper om = JsonV2.buildObjectMapper(); - ProjectChildren projectChildren1 = om.readValue(input, ProjectChildren.class); - assertNotNull(projectChildren1); + ProjectChildLocations projectChildLocations1 = om.readValue(input, ProjectChildLocations.class); + assertNotNull(projectChildLocations1); - String json = om.writeValueAsString(projectChildren1); - ProjectChildren projectChildren2 = om.readValue(json, ProjectChildren.class); - assertNotNull(projectChildren2); - - assertProjectChildrenEqual(projectChildren1, projectChildren2); + String json = om.writeValueAsString(projectChildLocations1); + ProjectChildLocations projectChildLocations2 = om.readValue(json, ProjectChildLocations.class); + assertNotNull(projectChildLocations2); + assertProjectChildLocationsEqual(projectChildLocations1, projectChildLocations2); } - private static void assertProjectChildrenEqual(ProjectChildren projectChildren1, ProjectChildren projectChildren2) { - assertAll("ProjectChildren", - () -> assertCwmsIdEqual(projectChildren1.getProject(), projectChildren2.getProject()), - () -> assertListEqual(projectChildren1.getEmbankments(), projectChildren2.getEmbankments()), - () -> assertListEqual(projectChildren1.getLocks(), projectChildren2.getLocks()), - () -> assertListEqual(projectChildren1.getGates(), projectChildren2.getGates()), - () -> assertListEqual(projectChildren1.getTurbines(), projectChildren2.getTurbines()), - () -> assertListEqual(projectChildren1.getOutlets(), projectChildren2.getOutlets()) + private static void assertProjectChildLocationsEqual(ProjectChildLocations projectChildLocations1, ProjectChildLocations projectChildLocations2) { + assertAll("ProjectChildLocations", + () -> assertCwmsIdEqual(projectChildLocations1.getProject(), projectChildLocations2.getProject()), + () -> assertListEqual(projectChildLocations1.getEmbankments(), projectChildLocations2.getEmbankments()), + () -> assertListEqual(projectChildLocations1.getLocks(), projectChildLocations2.getLocks()), + () -> assertListEqual(projectChildLocations1.getGates(), projectChildLocations2.getGates()), + () -> assertListEqual(projectChildLocations1.getTurbines(), projectChildLocations2.getTurbines()), + () -> assertListEqual(projectChildLocations1.getOutlets(), projectChildLocations2.getOutlets()) ); }