Skip to content

Commit

Permalink
Fix failed test
Browse files Browse the repository at this point in the history
  • Loading branch information
tunacicek committed Jun 27, 2023
1 parent af17896 commit 505ad0f
Showing 1 changed file with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
public class ModelsApiTest extends AbstractModelsApiTest{

@BeforeAll
public void init() throws Exception {
public void init() {
deleteAllData();
}

Expand Down Expand Up @@ -323,6 +323,11 @@ public void testModelStatusTransitionForPost() throws Exception {
.andDo( MockMvcResultHandlers.print() )
.andExpect(status().isOk());

// Transition from draft to standardized is not allowed
mvc.perform(post( TestUtils.createValidModelRequest(urnPrefix),"STANDARDIZED") )
.andDo( MockMvcResultHandlers.print() )
.andExpect(status().isBadRequest());

// transition from draft to release is allowed, delete is not allowed
mvc.perform(post( TestUtils.createValidModelRequest(urnPrefix),"RELEASED") )
.andDo( MockMvcResultHandlers.print() )
Expand All @@ -337,10 +342,21 @@ public void testModelStatusTransitionForPost() throws Exception {
// transition from released to draft is not allowed
mvc.perform(post( TestUtils.createValidModelRequest(urnPrefix),"DRAFT") )
.andExpect( jsonPath( "$.error.message", is(
"The package urn:samm:org.eclipse.tractusx.model.status.transition.post:2.0.0# is already in status RELEASED and cannot be modified. Only a transition to DEPRECATED is possible." ) ) )
"The package urn:samm:org.eclipse.tractusx.model.status.transition.post:2.0.0# is already in status RELEASED and cannot be modified. Only a transition to STANDARDIZED or DEPRECATED is possible." ) ) )
.andExpect( status().isBadRequest() );

// transition from released to deprecated is allowed
// transition from released to standardized is allowed
mvc.perform(post( TestUtils.createValidModelRequest(urnPrefix),"STANDARDIZED") )
.andDo( MockMvcResultHandlers.print() )
.andExpect(status().isOk());

// transition from standardized to draft is not allowed
mvc.perform(post( TestUtils.createValidModelRequest(urnPrefix),"DRAFT") )
.andExpect( jsonPath( "$.error.message", is(
"The package urn:samm:org.eclipse.tractusx.model.status.transition.post:2.0.0# is already in status STANDARDIZED and cannot be modified. Only a transition to DEPRECATED is possible." ) ) )
.andExpect( status().isBadRequest() );

// transition from standardized to deprecated is allowed
mvc.perform(
post( TestUtils.createValidModelRequest(urnPrefix),"DEPRECATED")
)
Expand Down Expand Up @@ -385,10 +401,15 @@ public void testModelStatusTransitionForPut() throws Exception {
// transition from released to draft is not allowed
mvc.perform(put( TestUtils.createValidModelRequest(urnPrefix), "DRAFT") )
.andExpect( jsonPath( "$.error.message", is(
"The package urn:samm:org.eclipse.tractusx.model.status.transition.put:2.0.0# is already in status RELEASED and cannot be modified. Only a transition to DEPRECATED is possible." ) ) )
"The package urn:samm:org.eclipse.tractusx.model.status.transition.put:2.0.0# is already in status RELEASED and cannot be modified. Only a transition to STANDARDIZED or DEPRECATED is possible." ) ) )
.andExpect( status().isBadRequest() );

// transition from released to deprecated is allowed
// transition from released to standardized is allowed
mvc.perform(put( TestUtils.createValidModelRequest(urnPrefix),"STANDARDIZED") )
.andDo( MockMvcResultHandlers.print() )
.andExpect(status().isOk());

// transition from standardized to deprecated is allowed
mvc.perform(put( TestUtils.createValidModelRequest(urnPrefix),"DEPRECATED") )
.andDo( MockMvcResultHandlers.print() )
.andExpect(status().isOk());
Expand Down

0 comments on commit 505ad0f

Please sign in to comment.