diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dao/watersupply/WaterSupplyUtils.java b/cwms-data-api/src/main/java/cwms/cda/data/dao/watersupply/WaterSupplyUtils.java index 5c329ba8b..04dc9515d 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dao/watersupply/WaterSupplyUtils.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dao/watersupply/WaterSupplyUtils.java @@ -185,12 +185,13 @@ public static WaterUser map(WaterUserContractRefType contract, public static WaterSupplyPumpAccounting map(WAT_USR_CONTRACT_ACCT_OBJ_T watUsrContractAcctObjT) { WaterUserAccountingType accounting = WaterUserTypeUtil.toWaterUserAccountingType(watUsrContractAcctObjT); - return new WaterSupplyPumpAccounting(new WaterUser(accounting.getContractRefTUser() - .getWaterUserType().getEntityName(), - new CwmsId.Builder().withOfficeId(accounting.getContractRefTUser() - .getWaterUserType().getParentLocationRefType().getOfficeId()) - .withName(accounting.getContractRefTUser().getWaterUserType().getEntityName()) - .build(), accounting.getContractRefTUser().getWaterUserType().getWaterRight()), + return new WaterSupplyPumpAccounting(new WaterUser.Builder().withEntityName(accounting.getContractRefTUser() + .getWaterUserType().getEntityName()).withProjectId( + new CwmsId.Builder().withOfficeId(accounting.getContractRefTUser() + .getWaterUserType().getParentLocationRefType().getOfficeId()) + .withName(accounting.getContractRefTUser().getWaterUserType().getEntityName()) + .build()) + .withWaterRight(accounting.getContractRefTUser().getWaterUserType().getWaterRight()).build(), accounting.getContractRefTUser().getContractName(), new CwmsId.Builder().withOfficeId(accounting.getPumpLocationRefTUser().getOfficeId()) .withName(accounting.getPumpLocationRefTUser().getBaseLocationId()).build(), diff --git a/cwms-data-api/src/test/java/cwms/cda/data/dto/watersupply/WaterSupplyPumpAccountingTest.java b/cwms-data-api/src/test/java/cwms/cda/data/dto/watersupply/WaterSupplyPumpAccountingTest.java index 6a591a1fe..39094b816 100644 --- a/cwms-data-api/src/test/java/cwms/cda/data/dto/watersupply/WaterSupplyPumpAccountingTest.java +++ b/cwms-data-api/src/test/java/cwms/cda/data/dto/watersupply/WaterSupplyPumpAccountingTest.java @@ -45,11 +45,12 @@ class WaterSupplyPumpAccountingTest { @Test void testWaterSupplyPumpAccountingSerializationRoundTrip() { - WaterUser user = new WaterUser("Test Entity", new CwmsId.Builder() - .withOfficeId(OFFICE) - .withName("Test Location") - .build(), - "Test Water Right"); + WaterUser user = new WaterUser.Builder().withEntityName("Test Entity") + .withProjectId(new CwmsId.Builder() + .withOfficeId(OFFICE) + .withName("Test Location") + .build()) + .withWaterRight("Test Water Right").build(); WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(user, "Test Contract", new CwmsId.Builder().withOfficeId(OFFICE).withName("NAME").build(), @@ -64,8 +65,10 @@ void testWaterSupplyPumpAccountingSerializationRoundTrip() { @Test void testWaterSupplyPumpAccountingSerializationRoundTripFromFile() throws Exception { - WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser("Test Entity", - new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Location").build(), "Test Water Right"), + WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser.Builder() + .withEntityName("Test Entity").withProjectId(new CwmsId.Builder().withOfficeId(OFFICE) + .withName("Test Location").build()) + .withWaterRight("Test Water Right").build(), "Test Contract", new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Pump").build(), new LookupType.Builder().withActive(true).withTooltip("Test Tool Tip").withOfficeId(OFFICE) @@ -84,8 +87,10 @@ void testWaterSupplyPumpAccountingSerializationRoundTripFromFile() throws Except void testValidate() { assertAll( () -> { - WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser("Test Entity", - new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Location").build(), "Test Water Right"), + WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser.Builder() + .withEntityName("Test Entity").withProjectId(new CwmsId.Builder().withOfficeId(OFFICE) + .withName("Test Location").build()) + .withWaterRight("Test Water Right").build(), "Test Contract", new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Pump").build(), new LookupType.Builder().withActive(true).withTooltip("Test Tool Tip").withOfficeId(OFFICE) @@ -93,18 +98,23 @@ void testValidate() { assertDoesNotThrow(waterSupplyPumpAccounting::validate, "Expected validation to pass"); }, () -> { - WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser("Test Entity", - new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Location").build(), "Test Water Right"), + WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser.Builder() + .withEntityName("Test Entity").withProjectId(new CwmsId.Builder().withOfficeId(OFFICE) + .withName("Test Location").build()) + .withWaterRight("Test Water Right").build(), null, new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Pump").build(), new LookupType.Builder().withActive(true).withTooltip("Test Tool Tip").withOfficeId(OFFICE) - .withDisplayValue("Test Transfer Type").build(), 1.0, Instant.ofEpochSecond(10000012648112L), "Test Comment"); + .withDisplayValue("Test Transfer Type").build(), 1.0, + Instant.ofEpochSecond(10000012648112L), "Test Comment"); assertThrows(FieldException.class, waterSupplyPumpAccounting::validate, "Expected validation to " + "fail due to null contract name"); }, () -> { - WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser("Test Entity", - new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Location").build(), "Test Water Right"), + WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser.Builder() + .withEntityName("Test Entity").withProjectId(new CwmsId.Builder().withOfficeId(OFFICE) + .withName("Test Location").build()) + .withWaterRight("Test Water Right").build(), "Test Contract", null, new LookupType.Builder().withActive(true).withTooltip("Test Tool Tip").withOfficeId(OFFICE) @@ -113,8 +123,10 @@ void testValidate() { + "fail due to null location"); }, () -> { - WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser("Test Entity", - new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Location").build(), "Test Water Right"), + WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser.Builder() + .withEntityName("Test Entity").withProjectId(new CwmsId.Builder() + .withOfficeId(OFFICE).withName("Test Location").build()) + .withWaterRight("Test Water Right").build(), "Test Contract", new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Pump").build(), null, 1.0, Instant.ofEpochSecond(10000012648112L), "Test Comment"); @@ -122,18 +134,23 @@ void testValidate() { + "fail due to null transfer type"); }, () -> { - WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser("Test Entity", - new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Location").build(), "Test Water Right"), + WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser.Builder() + .withEntityName("Test Entity").withProjectId(new CwmsId.Builder().withOfficeId(OFFICE) + .withName("Test Location").build()) + .withWaterRight("Test Water Right").build(), null, new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Pump").build(), new LookupType.Builder().withActive(true).withTooltip("Test Tool Tip").withOfficeId(OFFICE) - .withDisplayValue("Test Transfer Type").build(), null, Instant.ofEpochSecond(10000012648112L), "Test Comment"); + .withDisplayValue("Test Transfer Type").build(), null, + Instant.ofEpochSecond(10000012648112L), "Test Comment"); assertThrows(FieldException.class, waterSupplyPumpAccounting::validate, "Expected validation to " + "fail due to null flow value"); }, () -> { - WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser("Test Entity", - new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Location").build(), "Test Water Right"), + WaterSupplyPumpAccounting waterSupplyPumpAccounting = new WaterSupplyPumpAccounting(new WaterUser.Builder() + .withEntityName("Test Entity").withProjectId(new CwmsId.Builder().withOfficeId(OFFICE) + .withName("Test Location").build()) + .withWaterRight("Test Water Right").build(), null, new CwmsId.Builder().withOfficeId(OFFICE).withName("Test Pump").build(), new LookupType.Builder().withActive(true).withTooltip("Test Tool Tip").withOfficeId(OFFICE)