From 7076eecf721344f965f62a1692253b816f5814af Mon Sep 17 00:00:00 2001 From: Bryson Spilman Date: Fri, 7 Jun 2024 12:51:29 -0700 Subject: [PATCH] Updated indenting on LookupType Controller IT. Added require=true to requried params. --- .../cwms/cda/api/LookupTypeController.java | 20 +- .../cwms/cda/api/LookupTypeControllerIT.java | 178 +++++++++--------- 2 files changed, 99 insertions(+), 99 deletions(-) diff --git a/cwms-data-api/src/main/java/cwms/cda/api/LookupTypeController.java b/cwms-data-api/src/main/java/cwms/cda/api/LookupTypeController.java index 288cf9b61..fbcf9bb0f 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/LookupTypeController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/LookupTypeController.java @@ -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 = { @@ -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 = { @@ -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 = { @@ -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, diff --git a/cwms-data-api/src/test/java/cwms/cda/api/LookupTypeControllerIT.java b/cwms-data-api/src/test/java/cwms/cda/api/LookupTypeControllerIT.java index 52f278141..dcc19b155 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/LookupTypeControllerIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/LookupTypeControllerIT.java @@ -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()) ; } @@ -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)) ; } @@ -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)) ; } } \ No newline at end of file