Skip to content

Commit

Permalink
Updated indenting on LookupType Controller IT. Added require=true to …
Browse files Browse the repository at this point in the history
…requried params.
  • Loading branch information
rma-bryson committed Jun 7, 2024
1 parent b24b2e6 commit 7076eec
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 99 deletions.
20 changes: 10 additions & 10 deletions cwms-data-api/src/main/java/cwms/cda/api/LookupTypeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ private Timer.Context markAndTime(String subject) {

@OpenApi(
queryParams = {
@OpenApiParam(name = CATEGORY, description = "Filters lookup types to the specified category"),
@OpenApiParam(name = PREFIX, description = "Filters lookup types to the specified prefix"),
@OpenApiParam(name = OFFICE, description = "Filters lookup types to the specified office ID"),
@OpenApiParam(name = CATEGORY, required = true, description = "Filters lookup types to the specified category"),
@OpenApiParam(name = PREFIX, required = true, description = "Filters lookup types to the specified prefix"),
@OpenApiParam(name = OFFICE, required = true, description = "Filters lookup types to the specified office ID"),
},
responses = {
@OpenApiResponse(status = STATUS_200, content = {
Expand Down Expand Up @@ -112,8 +112,8 @@ public void getOne(@NotNull Context context, @NotNull String s) {

@OpenApi(
queryParams = {
@OpenApiParam(name = CATEGORY, description = "Specifies the category id of the lookup type to be created."),
@OpenApiParam(name = PREFIX, description = "Specifies the prefix of the lookup type to be created."),
@OpenApiParam(name = CATEGORY, required = true, description = "Specifies the category id of the lookup type to be created."),
@OpenApiParam(name = PREFIX, required = true, description = "Specifies the prefix of the lookup type to be created."),
},
requestBody = @OpenApiRequestBody(
content = {
Expand Down Expand Up @@ -146,8 +146,8 @@ public void create(Context ctx) {

@OpenApi(
queryParams = {
@OpenApiParam(name = CATEGORY, description = "Specifies the category id of the lookup type to be updated."),
@OpenApiParam(name = PREFIX, description = "Specifies the prefix of the lookup type to be updated."),
@OpenApiParam(name = CATEGORY, required = true, description = "Specifies the category id of the lookup type to be updated."),
@OpenApiParam(name = PREFIX, required = true, description = "Specifies the prefix of the lookup type to be updated."),
},
requestBody = @OpenApiRequestBody(
content = {
Expand Down Expand Up @@ -180,9 +180,9 @@ public void update(Context ctx, String name) {

@OpenApi(
queryParams = {
@OpenApiParam(name = CATEGORY, description = "Specifies the category id of the lookup type to be deleted."),
@OpenApiParam(name = PREFIX, description = "Specifies the prefix of the lookup type to be deleted."),
@OpenApiParam(name = OFFICE, description = "Specifies the owning office of the lookup type to be deleted."),
@OpenApiParam(name = CATEGORY, required = true, description = "Specifies the category id of the lookup type to be deleted."),
@OpenApiParam(name = PREFIX, required = true, description = "Specifies the prefix of the lookup type to be deleted."),
@OpenApiParam(name = OFFICE, required = true, description = "Specifies the owning office of the lookup type to be deleted."),
},
description = "Delete CWMS Lookup Type",
method = HttpMethod.DELETE,
Expand Down
178 changes: 89 additions & 89 deletions cwms-data-api/src/test/java/cwms/cda/api/LookupTypeControllerIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,78 +66,78 @@ void test_get_create_delete() throws IOException {

//Create the lookup type
given()
.log().ifValidationFails(LogDetail.ALL, true)
.accept(Formats.JSON)
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.contentType(Formats.JSON)
.body(json)
.header(AUTH_HEADER, user.toHeaderValue())
.when()
.redirects().follow(true)
.redirects().max(3)
.post("/lookup-types/")
.then()
.log().ifValidationFails(LogDetail.ALL, true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_CREATED))
.log().ifValidationFails(LogDetail.ALL, true)
.accept(Formats.JSON)
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.contentType(Formats.JSON)
.body(json)
.header(AUTH_HEADER, user.toHeaderValue())
.when()
.redirects().follow(true)
.redirects().max(3)
.post("/lookup-types/")
.then()
.log().ifValidationFails(LogDetail.ALL, true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_CREATED))
;
String office = user.getOperatingOffice();
// Retrieve the lookup type and assert that it exists
given()
.log().ifValidationFails(LogDetail.ALL,true)
.accept(Formats.JSON)
.queryParam(Controllers.OFFICE, office)
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.when()
.redirects().follow(true)
.redirects().max(3)
.get("lookup-types/")
.then()
.log().ifValidationFails(LogDetail.ALL,true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_OK))
.body("find { it.'display-value' == '%s' }.office-id", withArgs(lookupType.getDisplayValue()), equalTo(office))
.body("find { it.'display-value' == '%s' }.tooltip", withArgs(lookupType.getDisplayValue()), equalTo(lookupType.getTooltip()))
.body("find { it.'display-value' == '%s' }.active", withArgs(lookupType.getDisplayValue()), equalTo(lookupType.getActive()))
.body("find { it.'display-value' == '%s' }.display-value", withArgs(lookupType.getDisplayValue()), equalTo(lookupType.getDisplayValue()))
.log().ifValidationFails(LogDetail.ALL,true)
.accept(Formats.JSON)
.queryParam(Controllers.OFFICE, office)
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.when()
.redirects().follow(true)
.redirects().max(3)
.get("lookup-types/")
.then()
.log().ifValidationFails(LogDetail.ALL,true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_OK))
.body("find { it.'display-value' == '%s' }.office-id", withArgs(lookupType.getDisplayValue()), equalTo(office))
.body("find { it.'display-value' == '%s' }.tooltip", withArgs(lookupType.getDisplayValue()), equalTo(lookupType.getTooltip()))
.body("find { it.'display-value' == '%s' }.active", withArgs(lookupType.getDisplayValue()), equalTo(lookupType.getActive()))
.body("find { it.'display-value' == '%s' }.display-value", withArgs(lookupType.getDisplayValue()), equalTo(lookupType.getDisplayValue()))
;

// Delete the lookup type
given()
.log().ifValidationFails(LogDetail.ALL,true)
.accept(Formats.JSON)
.queryParam(Controllers.OFFICE, office)
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.header(AUTH_HEADER, user.toHeaderValue())
.when()
.redirects().follow(true)
.redirects().max(3)
.delete("lookup-types/" + lookupType.getDisplayValue())
.then()
.log().ifValidationFails(LogDetail.ALL,true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_NO_CONTENT))
.log().ifValidationFails(LogDetail.ALL,true)
.accept(Formats.JSON)
.queryParam(Controllers.OFFICE, office)
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.header(AUTH_HEADER, user.toHeaderValue())
.when()
.redirects().follow(true)
.redirects().max(3)
.delete("lookup-types/" + lookupType.getDisplayValue())
.then()
.log().ifValidationFails(LogDetail.ALL,true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_NO_CONTENT))
;

// Retrieve the lookup type and assert that it does not exist
given()
.log().ifValidationFails(LogDetail.ALL,true)
.accept(Formats.JSON)
.queryParam(Controllers.OFFICE, office)
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.when()
.redirects().follow(true)
.redirects().max(3)
.get("lookup-types/")
.then()
.log().ifValidationFails(LogDetail.ALL,true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_OK))
.body("find { it.'display-value' == '%s' }", withArgs(lookupType.getDisplayValue()), nullValue())
.log().ifValidationFails(LogDetail.ALL,true)
.accept(Formats.JSON)
.queryParam(Controllers.OFFICE, office)
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.when()
.redirects().follow(true)
.redirects().max(3)
.get("lookup-types/")
.then()
.log().ifValidationFails(LogDetail.ALL,true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_OK))
.body("find { it.'display-value' == '%s' }", withArgs(lookupType.getDisplayValue()), nullValue())
;
}

Expand All @@ -152,21 +152,21 @@ void test_update_does_not_exist() throws IOException {

// Try to update a lookup type that does not exist
given()
.log().ifValidationFails(LogDetail.ALL, true)
.accept(Formats.JSON)
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.contentType(Formats.JSON)
.body(json)
.header(AUTH_HEADER, user.toHeaderValue())
.when()
.redirects().follow(true)
.redirects().max(3)
.patch("/lookup-types/" + lookupType.getDisplayValue())
.then()
.log().ifValidationFails(LogDetail.ALL, true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_NOT_FOUND))
.log().ifValidationFails(LogDetail.ALL, true)
.accept(Formats.JSON)
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.contentType(Formats.JSON)
.body(json)
.header(AUTH_HEADER, user.toHeaderValue())
.when()
.redirects().follow(true)
.redirects().max(3)
.patch("/lookup-types/" + lookupType.getDisplayValue())
.then()
.log().ifValidationFails(LogDetail.ALL, true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_NOT_FOUND))
;
}

Expand All @@ -175,20 +175,20 @@ void test_delete_does_not_exist() throws IOException {
TestAccounts.KeyUser user = TestAccounts.KeyUser.SPK_NORMAL;
// Try to delete a lookup type that does not exist
given()
.log().ifValidationFails(LogDetail.ALL,true)
.accept(Formats.JSON)
.queryParam(Controllers.OFFICE, user.getOperatingOffice())
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.header(AUTH_HEADER, user.toHeaderValue())
.when()
.redirects().follow(true)
.redirects().max(3)
.delete("/lookup-types/" + "Non-ExistentLookupType3891029381fhsd")
.then()
.log().ifValidationFails(LogDetail.ALL,true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_NOT_FOUND))
.log().ifValidationFails(LogDetail.ALL,true)
.accept(Formats.JSON)
.queryParam(Controllers.OFFICE, user.getOperatingOffice())
.queryParam(Controllers.CATEGORY, CATEGORY_IT)
.queryParam(Controllers.PREFIX, PREFIX_IT)
.header(AUTH_HEADER, user.toHeaderValue())
.when()
.redirects().follow(true)
.redirects().max(3)
.delete("/lookup-types/" + "Non-ExistentLookupType3891029381fhsd")
.then()
.log().ifValidationFails(LogDetail.ALL,true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_NOT_FOUND))
;
}
}

0 comments on commit 7076eec

Please sign in to comment.