Skip to content

Commit

Permalink
Added test for new format function.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeNeilson committed Oct 2, 2024
1 parent 97aea37 commit 73f2d5e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cwms-data-api/src/test/java/cwms/cda/formatters/FormatsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ void testParseHeader() {

}


@ParameterizedTest
@EnumSource(ParseQueryOrParamTest.class)
void test_header_or_query_parm(ParseQueryOrParamTest test) throws Exception {
ContentType ct = Formats.parseQueryOrHeaderParam(test.header, test.query, test.dto);
System.out.println(ct.toString());
assertTrue(ContentType.equivalent(ct.toString(), test.type), "In correct content type returned.");
}

@EnumSource(ParseQueryParamTest.class)
@ParameterizedTest
void testParseQueryParam(ParseQueryParamTest test) {
Expand Down Expand Up @@ -250,4 +259,27 @@ enum ParseQueryParamTest {
}
}


enum ParseQueryOrParamTest {
BOTH(Formats.XML, Formats.CSV_LEGACY, Office.class, Formats.CSV),
HEADER(Formats.JSON, null, Office.class, Formats.JSONV2),
QUERY(null, Formats.TAB_LEGACY, Office.class, Formats.TAB)
;

final String header;
final String query;
final Class<? extends CwmsDTOBase> dto;
final String type;


ParseQueryOrParamTest(String header, String query, Class<? extends CwmsDTOBase> dto, String type)
{
this.header = header;
this.query = query;
this.dto = dto;
this.type = type;
}


}
}

0 comments on commit 73f2d5e

Please sign in to comment.