Skip to content

Commit

Permalink
added test case for regex pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
agg3fe committed Oct 8, 2023
1 parent d4cd807 commit 7e6e899
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@ public void testCreateShellExpectSuccess() throws Exception {

}

@Test
public void testCreateShellExpectRegexError() throws Exception {
AssetAdministrationShellDescriptor shellPayload = TestUtil.createCompleteAasDescriptor();
shellPayload.setId( UUID.randomUUID().toString() );

//set assetType wrong value according to regex pattern
shellPayload.setAssetType( "AssetType \u0000" );

mvc.perform(
MockMvcRequestBuilders
.post(SHELL_BASE_PATH)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.content(mapper.writeValueAsString( shellPayload ))
.with(jwtTokenFactory.allRoles())
)
.andDo(MockMvcResultHandlers.print())
.andExpect(status().isBadRequest())
.andExpect( jsonPath( "$.messages[0].text", is( "must match \"^[\\x09\\x0A\\x0D\\x20-\\uD7FF\\uE000-\\uFFFD\\x{00010000}-\\x{0010FFFF}]*$\"" ) ) );
}

@Test
public void testCreateShellWithExistingIdExpectBadRequest() throws Exception {
AssetAdministrationShellDescriptor shellPayload = TestUtil.createCompleteAasDescriptor();
Expand Down

0 comments on commit 7e6e899

Please sign in to comment.