Skip to content

Commit

Permalink
testcases are refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
bs-sili committed Nov 17, 2023
1 parent 0276b00 commit 28b07a1
Showing 1 changed file with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void testUpdateShellExpectSuccess() throws Exception {
shellPayload.setId( UUID.randomUUID().toString() );
performShellCreateRequest( mapper.writeValueAsString( shellPayload ) );

shellPayload.getDescription().get( 0 ).setLanguage( "fr" );
shellPayload.getDisplayName().get( 0 ).setLanguage( "fr" );

String shellId = shellPayload.getId();
shellPayload.setIdShort( RandomStringUtils.random(10, true, true) );
Expand All @@ -188,8 +188,8 @@ public void testUpdateShellExpectSuccess() throws Exception {
.with( jwtTokenFactory.allRoles() )
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isOk() );
//.andExpect(content().json(toJson(updateDescription)));
.andExpect( status().isOk() )
.andExpect( jsonPath( "$.displayName[0].language", is("fr") ) );
}

@Test
Expand Down Expand Up @@ -237,7 +237,6 @@ public void testUpdateShellWithDifferentIdInPayloadExpectPathIdIsTaken() throws
.andExpect( status().isNoContent() );

// verify that anything expect the identification can be updated
shellPayload.setId( UUID.randomUUID().toString() );
mvc.perform(
MockMvcRequestBuilders
.get( SINGLE_SHELL_BASE_PATH, getEncodedValue( shellId ) )
Expand All @@ -246,8 +245,8 @@ public void testUpdateShellWithDifferentIdInPayloadExpectPathIdIsTaken() throws
.with( jwtTokenFactory.allRoles() )
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isOk() );
//.andExpect(content().json(toJson(expectedShellAfterUpdate)));
.andExpect( status().isOk() )
.andExpect( jsonPath( "$.id", is( shellId ) ) );
}

@Test
Expand Down Expand Up @@ -314,8 +313,8 @@ public void testCreateShellWithSameSpecificAssetIdKeyButDifferentValuesExpectSuc
.with( jwtTokenFactory.allRoles() )
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isCreated() );
//.andExpect(content().json(mapper.writeValueAsString(shellPayload)));
.andExpect( status().isCreated() )
.andExpect(content().json(mapper.writeValueAsString(shellPayload)));
}
}

Expand Down Expand Up @@ -349,10 +348,10 @@ public void testCreateSpecificAssetIdsExpectSuccess() throws Exception {

/**
* The API method for creation of specificAssetIds accepts an array of objects.
* Invoking the API removes all existing specificAssetIds and adds the new ones.
* Invoking the API adds the new specificAssetIds to existing ones.
*/
@Test
public void testCreateSpecificAssetIdsReplacesAllExistingSpecificAssetIdsExpectSuccess() throws Exception {
public void testCreateSpecificAssetIdsAddToExistingSpecificAssetIdsExpectSuccess() throws Exception {
AssetAdministrationShellDescriptor shellPayload = TestUtil.createCompleteAasDescriptor();
shellPayload.setId( UUID.randomUUID().toString() );
performShellCreateRequest( mapper.writeValueAsString( shellPayload ) );
Expand All @@ -373,11 +372,10 @@ public void testCreateSpecificAssetIdsReplacesAllExistingSpecificAssetIdsExpectS
.with( jwtTokenFactory.allRoles() )
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isCreated() );
// .andExpect(content().json(toJson(specificAssetIds)));
.andExpect( status().isCreated() )
.andExpect(content().json(toJson(specificAssetIds)));

// verify that the shell payload does no longer contain the initial specificAssetIds that were provided at creation time
// ObjectNode expectedShellPayload = shellPayload.set("specificAssetIds", specificAssetIds);
mvc.perform(
MockMvcRequestBuilders
.get( SINGLE_SHELL_BASE_PATH, getEncodedValue( shellId ) )
Expand All @@ -386,8 +384,8 @@ public void testCreateSpecificAssetIdsReplacesAllExistingSpecificAssetIdsExpectS
.with( jwtTokenFactory.allRoles() )
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isOk() );
// .andExpect(content().json(toJson(expectedShellPayload)));
.andExpect( status().isOk() )
.andExpect(jsonPath("$.specificAssetIds", hasSize(4)));
}

@Test
Expand Down Expand Up @@ -424,8 +422,8 @@ public void testGetSpecificAssetIdsExpectSuccess() throws Exception {
.with( jwtTokenFactory.allRoles() )
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isOk() );
//.andExpect(content().json(toJson(shellPayload.get("specificAssetIds")));
.andExpect( status().isOk() )
.andExpect(content().json(mapper.writeValueAsString(shellPayload.getSpecificAssetIds())));
}

@Test
Expand Down Expand Up @@ -467,8 +465,8 @@ public void testCreateSubmodelExpectSuccess() throws Exception {
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isOk() )
.andExpect( jsonPath( "$.submodelDescriptors", hasSize( 2 ) ) );
// .andExpect(jsonPath("$.submodelDescriptors[*].identification", hasItem(getId(submodel))));
.andExpect( jsonPath( "$.submodelDescriptors", hasSize( 2 ) ) )
.andExpect(jsonPath("$.submodelDescriptors[*].id", hasItem(submodelDescriptor.getId())));
}

@Test
Expand Down Expand Up @@ -505,6 +503,7 @@ public void testUpdateSubModelExpectSuccess() throws Exception {
String submodelId = submodel.getId();

SubmodelDescriptor updatedSubmodel = TestUtil.createSubmodel();
updatedSubmodel.setId( submodelId );
updatedSubmodel.setIdShort( "updatedSubmodelId" );
LangStringTextType updateDescription = new LangStringTextType();
updateDescription.setLanguage( "cn" );
Expand All @@ -531,8 +530,8 @@ public void testUpdateSubModelExpectSuccess() throws Exception {
.with( jwtTokenFactory.allRoles() )
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isOk() );
//.andExpect(content().json(toJson(updatedSubmodel)));
.andExpect( status().isOk() )
.andExpect(content().json(mapper.writeValueAsString( updatedSubmodel )));
}

@Test
Expand Down Expand Up @@ -598,8 +597,8 @@ public void testUpdateSubmodelWithDifferentIdInPayloadExpectPathIdIsTaken() thro
.with( jwtTokenFactory.allRoles() )
)
.andDo( MockMvcResultHandlers.print() )
.andExpect( status().isOk() );
//.andExpect(content().json(mapper.writeValueAsString(submodel)));
.andExpect( status().isOk() )
.andExpect(content().json(mapper.writeValueAsString(submodel)));
}

@Test
Expand Down

0 comments on commit 28b07a1

Please sign in to comment.