Skip to content

Commit

Permalink
Fixed issue #886 build errors (#920)
Browse files Browse the repository at this point in the history
Fixes #886 build errors caused by bad assertion mapping in integration
test
  • Loading branch information
zack-rma authored Oct 21, 2024
1 parent e113280 commit 7020bfd
Showing 1 changed file with 37 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import static cwms.cda.api.Controllers.*;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.*;

@Tag("integration")
class LocationGroupControllerTestIT extends DataApiTestIT {
Expand Down Expand Up @@ -656,7 +657,7 @@ void test_CWMS_permissions() throws Exception {
.statusCode(is(HttpServletResponse.SC_OK));

// get the location group and assert that changes were made
given()
ExtractableResponse<Response> otherResponse = given()
.log().ifValidationFails(LogDetail.ALL,true)
.accept(Formats.JSON)
.contentType(Formats.JSON)
Expand All @@ -670,12 +671,22 @@ void test_CWMS_permissions() throws Exception {
.log().ifValidationFails(LogDetail.ALL,true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_OK))
.body("office-id", equalTo(group.getOfficeId()))
.body("id", equalTo(group.getId()))
.body("description", equalTo(newLocGroup.getDescription()))
.body("assigned-locations[0].location-id", equalTo(locationId))
.body("assigned-locations[0].alias-id", nullValue())
.body("assigned-locations[0].ref-location-id", nullValue());
.extract();

assertEquals(otherResponse.body().jsonPath().getString("office-id"), group.getOfficeId());
assertEquals(otherResponse.body().jsonPath().getString("id"), group.getId());
assertEquals(otherResponse.body().jsonPath().getString("description"), newLocGroup.getDescription());
List<AssignedLocation> assignedLocations = otherResponse.body().jsonPath().getList("assigned-locations", AssignedLocation.class);
boolean found = false;
for (AssignedLocation assignedLocation : assignedLocations) {
if (assignedLocation.getLocationId().equals(locationId)) {
assertEquals(assignedLocation.getLocationId(), locationId);
assertNull(assignedLocation.getAliasId());
assertNull(assignedLocation.getRefLocationId());
found = true;
}
}
assertTrue(found);

// patch the location group owned by CWMS office
given()
Expand Down Expand Up @@ -764,12 +775,12 @@ void test_CWMS_permissions_with_replacement() throws Exception {
.redirects().max(3)
.patch("/location/group/" + group.getId())
.then()
.assertThat()
.log().ifValidationFails(LogDetail.ALL,true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_OK));

// get the location group and assert that changes were made
given()
ExtractableResponse<Response> otherResponse = given()
.log().ifValidationFails(LogDetail.ALL,true)
.accept(Formats.JSON)
.contentType(Formats.JSON)
Expand All @@ -780,15 +791,25 @@ void test_CWMS_permissions_with_replacement() throws Exception {
.redirects().max(3)
.get("/location/group/" + group.getId())
.then()
.assertThat()
.log().ifValidationFails(LogDetail.ALL,true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_OK))
.body("office-id", equalTo(group.getOfficeId()))
.body("id", equalTo(group.getId()))
.body("description", equalTo(newLocGroup.getDescription()))
.body("assigned-locations[0].location-id", equalTo(locationId))
.body("assigned-locations[0].alias-id", nullValue())
.body("assigned-locations[0].ref-location-id", nullValue());
.extract();

assertEquals(otherResponse.body().jsonPath().getString("office-id"), group.getOfficeId());
assertEquals(otherResponse.body().jsonPath().getString("id"), group.getId());
assertEquals(otherResponse.body().jsonPath().getString("description"), newLocGroup.getDescription());
List<AssignedLocation> assignedLocations = otherResponse.body().jsonPath().getList("assigned-locations", AssignedLocation.class);
boolean found = false;
for (AssignedLocation assignedLocation : assignedLocations) {
if (assignedLocation.getLocationId().equals(locationId)) {
assertEquals(assignedLocation.getLocationId(), locationId);
assertNull(assignedLocation.getAliasId());
assertNull(assignedLocation.getRefLocationId());
found = true;
}
}
assertTrue(found);

// patch the location group owned by CWMS office
given()
Expand Down

0 comments on commit 7020bfd

Please sign in to comment.