diff --git a/cwms-data-api/src/main/java/cwms/cda/api/OfficeController.java b/cwms-data-api/src/main/java/cwms/cda/api/OfficeController.java index 55d765716..8266286ab 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/OfficeController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/OfficeController.java @@ -22,6 +22,7 @@ import cwms.cda.formatters.OfficeFormatV1; import cwms.cda.formatters.csv.CsvV1Office; import cwms.cda.formatters.tab.TabV1Office; +import cwms.cda.formatters.xml.XMLv1Office; import io.javalin.apibuilder.CrudHandler; import io.javalin.core.util.Header; import io.javalin.http.Context; @@ -83,9 +84,7 @@ private Timer.Context markAndTime(String subject) { @OpenApiContent(from = OfficeFormatV1.class, type = ""), @OpenApiContent(from = Office.class, isArray = true, type = Formats.JSONV2), @OpenApiContent(from = OfficeFormatV1.class, type = Formats.JSON), - @OpenApiContent(from = TabV1Office.class, type = Formats.TAB), - @OpenApiContent(from = CsvV1Office.class, type = Formats.CSV), - @OpenApiContent(from = CsvV1Office.class, type = Formats.XML) + @OpenApiContent(from = XMLv1Office.class, type = Formats.XML) }), }, tags = { "Offices" } ) @@ -128,13 +127,10 @@ public void getAll(Context ctx) { description = "A list of offices.", content = { @OpenApiContent(from = OfficeFormatV1.class, type = ""), - @OpenApiContent(from = Office.class, - isArray = true, - type = Formats.JSONV2), + @OpenApiContent(from = Office.class, isArray = true, type = Formats.JSONV2), @OpenApiContent(from = OfficeFormatV1.class, type = Formats.JSON), - @OpenApiContent(from = TabV1Office.class, type = Formats.TAB), - @OpenApiContent(from = CsvV1Office.class, type = Formats.CSV), - @OpenApiContent(from = CsvV1Office.class, type = Formats.XML) + @OpenApiContent(from = Office.class, type = Formats.XML), + @OpenApiContent(from = Office.class, type = Formats.XMLV2) }) }, tags = { "Offices" }) @Override diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dto/Office.java b/cwms-data-api/src/main/java/cwms/cda/data/dto/Office.java index ce2ccbeb0..d8fc2dbdd 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dto/Office.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dto/Office.java @@ -14,12 +14,14 @@ import cwms.cda.formatters.json.JsonV2; import cwms.cda.formatters.tab.TabV1; import cwms.cda.formatters.xml.XMLv1; +import cwms.cda.formatters.xml.XMLv2; import io.swagger.v3.oas.annotations.media.Schema; @Schema(description = "A representation of a CWMS office") @XmlRootElement(name="office") @XmlAccessorType(XmlAccessType.FIELD) @FormattableWith(contentType = Formats.XML, formatter = XMLv1.class) +@FormattableWith(contentType = Formats.XMLV2, formatter = XMLv2.class) @FormattableWith(contentType = Formats.JSON, formatter = JsonV1.class) @FormattableWith(contentType = Formats.JSONV2, formatter = JsonV2.class) @FormattableWith(contentType = Formats.CSV, formatter = CsvV1.class) diff --git a/cwms-data-api/src/test/java/cwms/cda/api/OfficeControllerIT.java b/cwms-data-api/src/test/java/cwms/cda/api/OfficeControllerIT.java index ddda4cc73..8ac39d08a 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/OfficeControllerIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/OfficeControllerIT.java @@ -86,4 +86,47 @@ void test_get_one() { ; } + + @Test + void test_get_one_xmlv2() { + + given() + .log().ifValidationFails(LogDetail.ALL,true) + .accept(Formats.XMLV2) + .contentType(Formats.XMLV2) + .when() + .redirects().follow(true) + .redirects().max(3) + .get("/offices/" + OFFICE) + .then() + .assertThat() + .log().ifValidationFails(LogDetail.ALL,true) + .statusCode(is(HttpServletResponse.SC_OK)) + .header(Header.ETAG, not(isEmptyOrNullString())) + .headers(Header.CACHE_CONTROL.toLowerCase(), containsString("max-age=")) + .body("office.long-name", containsString("Sacramento")) + ; + } + + @Test + void test_get_one_xmlv1() { + + given() + .log().ifValidationFails(LogDetail.ALL,true) + .accept(Formats.XML) + .contentType(Formats.XML) + .when() + .redirects().follow(true) + .redirects().max(3) + .get("/offices/" + OFFICE) + .then() + .assertThat() + .log().ifValidationFails(LogDetail.ALL,true) + .statusCode(is(HttpServletResponse.SC_OK)) + .header(Header.ETAG, not(isEmptyOrNullString())) + .headers(Header.CACHE_CONTROL.toLowerCase(), containsString("max-age=")) + .body("office.long-name", containsString("Sacramento")) + ; + + } }