Skip to content

Commit

Permalink
Incorporated changed Water Supply DTOs (changed constructors to build…
Browse files Browse the repository at this point in the history
…ers)
  • Loading branch information
zack-rma committed Jul 24, 2024
1 parent 2b5318c commit e9f2cf9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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)
Expand All @@ -84,27 +87,34 @@ 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)
.withDisplayValue("Test Transfer Type").build(), 1.0, Instant.ofEpochSecond(10000012648112L), "Test Comment");
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)
Expand All @@ -113,27 +123,34 @@ 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");
assertThrows(FieldException.class, waterSupplyPumpAccounting::validate, "Expected validation to "
+ "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)
Expand Down

0 comments on commit e9f2cf9

Please sign in to comment.