Skip to content

Commit

Permalink
Added parameter format check before splitting text with test
Browse files Browse the repository at this point in the history
  • Loading branch information
zack-rma committed Dec 9, 2024
1 parent 228f7e2 commit d372cb2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ public void renameLocationLevel(String oldLocationLevelName, String newLocationL
public LocationLevel retrieveLocationLevel(String locationLevelName, String pUnits,
ZonedDateTime effectiveDate, String officeId) {
Timestamp date = Timestamp.from(effectiveDate.toInstant());
if (locationLevelName.split("\\.").length <= 2) {
throw new IllegalArgumentException("Location level name is in an invalid format, must be separated by '.'");
}
return connectionResult(dsl, c -> {
String units = pUnits;
Configuration configuration = getDslContext(c, officeId).configuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,25 @@ void test_get_all_earliest_time() throws Exception {
assertThat(actual1, closeTo(2466.9636f, 1.0));
}

@Test
void testRetrievalInvalidLevelName()
{
given()
.log().ifValidationFails(LogDetail.ALL, true)
.accept(Formats.JSONV2)
.contentType(Formats.JSONV2)
.queryParam(Controllers.OFFICE, OFFICE)
.queryParam(EFFECTIVE_DATE, "2023-06-01T00:00:00Z")
.when()
.redirects().follow(true)
.redirects().max(3)
.get("/levels/invalid.level_name")
.then()
.assertThat()
.log().ifValidationFails(LogDetail.ALL, true)
.statusCode(is(HttpServletResponse.SC_BAD_REQUEST));
}

@ParameterizedTest
@EnumSource(GetAllTestNewAliases.class)
void test_get_all_aliases_new(GetAllTestNewAliases test)
Expand Down

0 comments on commit d372cb2

Please sign in to comment.