diff options
Diffstat (limited to 'app/src/test/java/org/onap/portalng/bff/actions')
5 files changed, 60 insertions, 70 deletions
diff --git a/app/src/test/java/org/onap/portalng/bff/actions/ActionFixtures.java b/app/src/test/java/org/onap/portalng/bff/actions/ActionFixtures.java index 0acd0eb..0ca28bf 100644 --- a/app/src/test/java/org/onap/portalng/bff/actions/ActionFixtures.java +++ b/app/src/test/java/org/onap/portalng/bff/actions/ActionFixtures.java @@ -23,27 +23,27 @@ package org.onap.portalng.bff.actions; import java.time.OffsetDateTime; import java.time.temporal.ChronoUnit; -import org.onap.portalng.bff.openapi.client_portal_history.model.ActionResponsePortalHistoryDto; -import org.onap.portalng.bff.openapi.client_portal_history.model.ActionsListResponsePortalHistoryDto; -import org.onap.portalng.bff.openapi.client_portal_history.model.CreateActionRequestPortalHistoryDto; +import org.onap.portalng.bff.openapi.client_history.model.ActionResponseHistoryDto; +import org.onap.portalng.bff.openapi.client_history.model.ActionsListResponseHistoryDto; +import org.onap.portalng.bff.openapi.client_history.model.CreateActionRequestHistoryDto; import org.onap.portalng.bff.openapi.server.model.CreateActionRequestApiDto; public class ActionFixtures { - public static ActionsListResponsePortalHistoryDto generateActionsListResponse( + public static ActionsListResponseHistoryDto generateActionsListResponse( Integer numberOfActions, Integer totalCount, OffsetDateTime createdAt) { - ActionsListResponsePortalHistoryDto actionsListResponsePortalHistoryDto = - new ActionsListResponsePortalHistoryDto(); + ActionsListResponseHistoryDto actionsListResponseHistoryDto = + new ActionsListResponseHistoryDto(); for (Integer i = 0; i < numberOfActions; i++) { - actionsListResponsePortalHistoryDto.addActionsListItem( + actionsListResponseHistoryDto.addActionsListItem( generateActionResponse( "Instantiation", "create", null, i.toString(), "SO", i, createdAt)); } - actionsListResponsePortalHistoryDto.setTotalCount(totalCount); - return actionsListResponsePortalHistoryDto; + actionsListResponseHistoryDto.setTotalCount(totalCount); + return actionsListResponseHistoryDto; } - public static ActionResponsePortalHistoryDto generateActionResponse( + public static ActionResponseHistoryDto generateActionResponse( String type, String action, String message, @@ -58,12 +58,12 @@ public class ActionFixtures { actionDto.setDownStreamSystem(downStreamSystem); actionDto.setDownStreamId(id); - return new ActionResponsePortalHistoryDto() + return new ActionResponseHistoryDto() .action(actionDto) .actionCreatedAt(createdAt.minus(deltaHours, ChronoUnit.HOURS)); } - public static CreateActionRequestPortalHistoryDto generateActionRequestPortalHistoryDto( + public static CreateActionRequestHistoryDto generateActionRequestHistoryDto( String type, String action, String message, @@ -77,7 +77,7 @@ public class ActionFixtures { actionDto.setMessage(message); actionDto.setDownStreamSystem(downStreamSystem); actionDto.setDownStreamId(id); - return new CreateActionRequestPortalHistoryDto() + return new CreateActionRequestHistoryDto() .action(actionDto) .actionCreatedAt(createdAt) .userId(userId); diff --git a/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java b/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java index aa9e2f3..39fc3dc 100644 --- a/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java +++ b/app/src/test/java/org/onap/portalng/bff/actions/ActionsMocks.java @@ -27,9 +27,9 @@ import com.github.tomakehurst.wiremock.matching.EqualToPattern; import io.restassured.http.Header; import org.apache.http.HttpHeaders; import org.onap.portalng.bff.BaseIntegrationTest; -import org.onap.portalng.bff.openapi.client_portal_history.model.ActionResponsePortalHistoryDto; -import org.onap.portalng.bff.openapi.client_portal_history.model.ActionsListResponsePortalHistoryDto; -import org.onap.portalng.bff.openapi.client_portal_history.model.ProblemPortalHistoryDto; +import org.onap.portalng.bff.openapi.client_history.model.ActionResponseHistoryDto; +import org.onap.portalng.bff.openapi.client_history.model.ActionsListResponseHistoryDto; +import org.onap.portalng.bff.openapi.client_history.model.ProblemHistoryDto; import org.onap.portalng.bff.openapi.server.model.ActionsListResponseApiDto; import org.onap.portalng.bff.openapi.server.model.ActionsResponseApiDto; import org.onap.portalng.bff.openapi.server.model.CreateActionRequestApiDto; @@ -56,16 +56,15 @@ public class ActionsMocks extends BaseIntegrationTest { } // used for test thatActionsListCanBeRetrieved - protected void mockListActions( - ActionsListResponsePortalHistoryDto actionsListResponsePortalHistoryDto) throws Exception { + protected void mockListActions(ActionsListResponseHistoryDto actionsListResponseHistoryDto) + throws Exception { WireMock.stubFor( WireMock.get(WireMock.urlEqualTo("/v1/actions?page=1&pageSize=10")) .withHeader("X-Request-Id", new EqualToPattern(X_REQUEST_ID)) .willReturn( WireMock.aResponse() .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .withBody( - objectMapper.writeValueAsString(actionsListResponsePortalHistoryDto)))); + .withBody(objectMapper.writeValueAsString(actionsListResponseHistoryDto)))); } // used for test thatActionsListCanNotBeRetrieved @@ -84,8 +83,7 @@ public class ActionsMocks extends BaseIntegrationTest { } // used for test thatActionsListCanNotBeRetrieved - protected void mockListActionsProblem(ProblemPortalHistoryDto problemPortalHistoryDto) - throws Exception { + protected void mockListActionsProblem(ProblemHistoryDto problemHistoryDto) throws Exception { WireMock.stubFor( WireMock.get(WireMock.urlEqualTo("/v1/actions?page=1&pageSize=10")) .withHeader("X-Request-Id", new EqualToPattern(X_REQUEST_ID)) @@ -93,12 +91,12 @@ public class ActionsMocks extends BaseIntegrationTest { WireMock.aResponse() .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_PROBLEM_JSON_VALUE) .withStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()) - .withBody(objectMapper.writeValueAsString(problemPortalHistoryDto)))); + .withBody(objectMapper.writeValueAsString(problemHistoryDto)))); } // used for test thatActionCanBeRetrieved protected void mockGetActions( - ActionsListResponsePortalHistoryDto actionsListResponsePortalHistoryDto, + ActionsListResponseHistoryDto actionsListResponseHistoryDto, String userId, Integer showLastHours) throws Exception { @@ -114,8 +112,7 @@ public class ActionsMocks extends BaseIntegrationTest { .willReturn( WireMock.aResponse() .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .withBody( - objectMapper.writeValueAsString(actionsListResponsePortalHistoryDto)))); + .withBody(objectMapper.writeValueAsString(actionsListResponseHistoryDto)))); } // used for test thatActionCanBeRetrieved protected ActionsListResponseApiDto getActions(String userId) { @@ -134,16 +131,14 @@ public class ActionsMocks extends BaseIntegrationTest { // used for test thatActionCanBeRetrievedWithoutParameterShowLastHours protected void mockGetActionsWithoutParameterShowLastHours( - ActionsListResponsePortalHistoryDto actionsListResponsePortalHistoryDto, String userId) - throws Exception { + ActionsListResponseHistoryDto actionsListResponseHistoryDto, String userId) throws Exception { WireMock.stubFor( WireMock.get(WireMock.urlEqualTo("/v1/actions/" + userId + "?page=1&pageSize=10")) .withHeader("X-Request-Id", new EqualToPattern(X_REQUEST_ID)) .willReturn( WireMock.aResponse() .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .withBody( - objectMapper.writeValueAsString(actionsListResponsePortalHistoryDto)))); + .withBody(objectMapper.writeValueAsString(actionsListResponseHistoryDto)))); } // used for test thatActionCanBeRetrievedWithoutParameterShowLastHours protected ActionsListResponseApiDto getActionsWithoutParameterShowLastHours(String userId) { @@ -161,8 +156,7 @@ public class ActionsMocks extends BaseIntegrationTest { } // Used for thatActionCanBeCreated - protected void mockCreateActions( - String userId, ActionResponsePortalHistoryDto actionResponsePortalHistoryDto) + protected void mockCreateActions(String userId, ActionResponseHistoryDto actionResponseHistoryDto) throws Exception { WireMock.stubFor( WireMock.post(WireMock.urlEqualTo("/v1/actions/" + userId)) @@ -172,7 +166,7 @@ public class ActionsMocks extends BaseIntegrationTest { WireMock.aResponse() .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .withStatus(200) - .withBody(objectMapper.writeValueAsString(actionResponsePortalHistoryDto)))); + .withBody(objectMapper.writeValueAsString(actionResponseHistoryDto)))); } // Used for thatActionCanBeCreated @@ -194,8 +188,7 @@ public class ActionsMocks extends BaseIntegrationTest { } // Used for thatActionCanNotBeCreated - protected void mockCreateActionsProblem( - String userId, ProblemPortalHistoryDto problemPortalHistoryDto) + protected void mockCreateActionsProblem(String userId, ProblemHistoryDto problemHistoryDto) throws JsonProcessingException { WireMock.stubFor( WireMock.post(WireMock.urlEqualTo("/v1/actions/" + userId)) @@ -205,7 +198,7 @@ public class ActionsMocks extends BaseIntegrationTest { WireMock.aResponse() .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_PROBLEM_JSON_VALUE) .withStatus(500) - .withBody(objectMapper.writeValueAsString(problemPortalHistoryDto)))); + .withBody(objectMapper.writeValueAsString(problemHistoryDto)))); } // Used for thatActionCanNotBeCreated protected ProblemApiDto createActionProblem( diff --git a/app/src/test/java/org/onap/portalng/bff/actions/CreateActionsIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/actions/CreateActionsIntegrationTest.java index 3508f19..748d568 100644 --- a/app/src/test/java/org/onap/portalng/bff/actions/CreateActionsIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/actions/CreateActionsIntegrationTest.java @@ -26,8 +26,8 @@ import static org.assertj.core.api.Assertions.assertThat; import java.time.OffsetDateTime; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; -import org.onap.portalng.bff.openapi.client_portal_history.model.ActionResponsePortalHistoryDto; -import org.onap.portalng.bff.openapi.client_portal_history.model.ProblemPortalHistoryDto; +import org.onap.portalng.bff.openapi.client_history.model.ActionResponseHistoryDto; +import org.onap.portalng.bff.openapi.client_history.model.ProblemHistoryDto; import org.onap.portalng.bff.openapi.server.model.ActionsResponseApiDto; import org.onap.portalng.bff.openapi.server.model.CreateActionRequestApiDto; import org.onap.portalng.bff.openapi.server.model.ProblemApiDto; @@ -39,21 +39,21 @@ class CreateActionsIntegrationTest extends ActionsMocks { void thatActionCanBeCreated() throws Exception { String userId = "22-33-44-55"; OffsetDateTime createdAt = OffsetDateTime.now(); - ActionResponsePortalHistoryDto actionResponsePortalHistoryDto = + ActionResponseHistoryDto actionResponseHistoryDto = ActionFixtures.generateActionResponse( "Instantiation", "create", "no detail message", "223344", "SO", 0, createdAt); CreateActionRequestApiDto createActionDto = ActionFixtures.generateCreateActionRequestApiDto( "Instantiation", "create", "no detail message", "223344", "SO", userId, createdAt); - mockCreateActions(userId, actionResponsePortalHistoryDto); + mockCreateActions(userId, actionResponseHistoryDto); final ActionsResponseApiDto response = createAction(createActionDto, userId); assertThat(response.getActionCreatedAt()) - .isEqualTo(actionResponsePortalHistoryDto.getActionCreatedAt()); + .isEqualTo(actionResponseHistoryDto.getActionCreatedAt()); Assertions.assertThat(objectMapper.writeValueAsString(response.getAction())) - .isEqualTo(objectMapper.writeValueAsString(actionResponsePortalHistoryDto.getAction())); + .isEqualTo(objectMapper.writeValueAsString(actionResponseHistoryDto.getAction())); } @Test @@ -61,18 +61,18 @@ class CreateActionsIntegrationTest extends ActionsMocks { String userId = "22-33-44-55"; OffsetDateTime createdAt = OffsetDateTime.now(); - ProblemPortalHistoryDto problemPortalHistoryDto = - new ProblemPortalHistoryDto() + ProblemHistoryDto problemHistoryDto = + new ProblemHistoryDto() .status(HttpStatus.INTERNAL_SERVER_ERROR.value()) .detail("Internal database error") .title("Internal Server Error") - .instance("portal-history"); + .instance("history"); CreateActionRequestApiDto createActionDto = ActionFixtures.generateCreateActionRequestApiDto( "Instantiation", "create", "no detail message", "223344", "SO", userId, createdAt); - mockCreateActionsProblem(userId, problemPortalHistoryDto); + mockCreateActionsProblem(userId, problemHistoryDto); final ProblemApiDto response = createActionProblem(createActionDto, userId); @@ -80,6 +80,6 @@ class CreateActionsIntegrationTest extends ActionsMocks { .isEqualTo(ProblemApiDto.DownstreamSystemEnum.PORTAL_HISTORY); assertThat(response.getDownstreamStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value()); - assertThat(response.getDetail()).isEqualTo(problemPortalHistoryDto.getDetail()); + assertThat(response.getDetail()).isEqualTo(problemHistoryDto.getDetail()); } } diff --git a/app/src/test/java/org/onap/portalng/bff/actions/GetActionsIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/actions/GetActionsIntegrationTest.java index 489a8d3..90c065e 100644 --- a/app/src/test/java/org/onap/portalng/bff/actions/GetActionsIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/actions/GetActionsIntegrationTest.java @@ -25,7 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.time.OffsetDateTime; import org.junit.jupiter.api.Test; -import org.onap.portalng.bff.openapi.client_portal_history.model.ActionsListResponsePortalHistoryDto; +import org.onap.portalng.bff.openapi.client_history.model.ActionsListResponseHistoryDto; import org.onap.portalng.bff.openapi.server.model.ActionsListResponseApiDto; class GetActionsIntegrationTest extends ActionsMocks { @@ -36,22 +36,21 @@ class GetActionsIntegrationTest extends ActionsMocks { Integer showLastHours = 2; String userId = "22-33-44-55"; OffsetDateTime createdAt = OffsetDateTime.now(); - ActionsListResponsePortalHistoryDto actionsListResponsePortalHistoryDto = + ActionsListResponseHistoryDto actionsListResponseHistoryDto = ActionFixtures.generateActionsListResponse(numberOfActions, 30, createdAt); - mockGetActions(actionsListResponsePortalHistoryDto, userId, showLastHours); + mockGetActions(actionsListResponseHistoryDto, userId, showLastHours); final ActionsListResponseApiDto response = getActions(userId); assertThat(response.getTotalCount()).isEqualTo(30); assertThat(response.getItems()).hasSize(numberOfActions); assertThat(response.getItems().get(0).getActionCreatedAt()) - .isEqualTo( - actionsListResponsePortalHistoryDto.getActionsList().get(0).getActionCreatedAt()); + .isEqualTo(actionsListResponseHistoryDto.getActionsList().get(0).getActionCreatedAt()); assertThat(objectMapper.writeValueAsString(response.getItems().get(0).getAction())) .isEqualTo( objectMapper.writeValueAsString( - actionsListResponsePortalHistoryDto.getActionsList().get(0).getAction())); + actionsListResponseHistoryDto.getActionsList().get(0).getAction())); } @Test @@ -59,21 +58,20 @@ class GetActionsIntegrationTest extends ActionsMocks { int numberOfActions = 10; String userId = "22-33-44-55"; OffsetDateTime createdAt = OffsetDateTime.now(); - ActionsListResponsePortalHistoryDto actionsListResponsePortalHistoryDto = + ActionsListResponseHistoryDto actionsListResponseHistoryDto = ActionFixtures.generateActionsListResponse(numberOfActions, 30, createdAt); - mockGetActionsWithoutParameterShowLastHours(actionsListResponsePortalHistoryDto, userId); + mockGetActionsWithoutParameterShowLastHours(actionsListResponseHistoryDto, userId); final ActionsListResponseApiDto response = getActionsWithoutParameterShowLastHours(userId); assertThat(response.getTotalCount()).isEqualTo(30); assertThat(response.getItems()).hasSize(numberOfActions); assertThat(response.getItems().get(0).getActionCreatedAt()) - .isEqualTo( - actionsListResponsePortalHistoryDto.getActionsList().get(0).getActionCreatedAt()); + .isEqualTo(actionsListResponseHistoryDto.getActionsList().get(0).getActionCreatedAt()); assertThat(objectMapper.writeValueAsString(response.getItems().get(0).getAction())) .isEqualTo( objectMapper.writeValueAsString( - actionsListResponsePortalHistoryDto.getActionsList().get(0).getAction())); + actionsListResponseHistoryDto.getActionsList().get(0).getAction())); } } diff --git a/app/src/test/java/org/onap/portalng/bff/actions/ListActionsIntegrationTest.java b/app/src/test/java/org/onap/portalng/bff/actions/ListActionsIntegrationTest.java index 8451641..5acc4f4 100644 --- a/app/src/test/java/org/onap/portalng/bff/actions/ListActionsIntegrationTest.java +++ b/app/src/test/java/org/onap/portalng/bff/actions/ListActionsIntegrationTest.java @@ -26,8 +26,8 @@ import static org.assertj.core.api.Assertions.assertThat; import java.time.OffsetDateTime; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; -import org.onap.portalng.bff.openapi.client_portal_history.model.ActionsListResponsePortalHistoryDto; -import org.onap.portalng.bff.openapi.client_portal_history.model.ProblemPortalHistoryDto; +import org.onap.portalng.bff.openapi.client_history.model.ActionsListResponseHistoryDto; +import org.onap.portalng.bff.openapi.client_history.model.ProblemHistoryDto; import org.onap.portalng.bff.openapi.server.model.ActionsListResponseApiDto; import org.onap.portalng.bff.openapi.server.model.ProblemApiDto; import org.springframework.http.HttpStatus; @@ -38,41 +38,40 @@ class ListActionsIntegrationTest extends ActionsMocks { void thatActionsListCanBeRetrieved() throws Exception { int numberOfActions = 10; OffsetDateTime createdAt = OffsetDateTime.now(); - ActionsListResponsePortalHistoryDto actionsListResponsePortalHistoryDto = + ActionsListResponseHistoryDto actionsListResponseHistoryDto = ActionFixtures.generateActionsListResponse(numberOfActions, 1000, createdAt); - mockListActions(actionsListResponsePortalHistoryDto); + mockListActions(actionsListResponseHistoryDto); final ActionsListResponseApiDto response = listActions(); assertThat(response.getTotalCount()).isEqualTo(1000); assertThat(response.getItems()).hasSize(numberOfActions); assertThat(response.getItems().get(0).getActionCreatedAt()) - .isEqualTo( - actionsListResponsePortalHistoryDto.getActionsList().get(0).getActionCreatedAt()); + .isEqualTo(actionsListResponseHistoryDto.getActionsList().get(0).getActionCreatedAt()); Assertions.assertThat(objectMapper.writeValueAsString(response.getItems().get(0).getAction())) .isEqualTo( objectMapper.writeValueAsString( - actionsListResponsePortalHistoryDto.getActionsList().get(0).getAction())); + actionsListResponseHistoryDto.getActionsList().get(0).getAction())); } @Test void thatActionsListCanNotBeRetrieved() throws Exception { - ProblemPortalHistoryDto problemPortalHistoryDto = - new ProblemPortalHistoryDto() + ProblemHistoryDto problemHistoryDto = + new ProblemHistoryDto() .status(HttpStatus.INTERNAL_SERVER_ERROR.value()) .detail("Internal database error") .title("Internal Server Error") - .instance("portal-history"); + .instance("history"); - mockListActionsProblem(problemPortalHistoryDto); + mockListActionsProblem(problemHistoryDto); final ProblemApiDto response = listActionsProblem(); assertThat(response.getDownstreamSystem()) .isEqualTo(ProblemApiDto.DownstreamSystemEnum.PORTAL_HISTORY); assertThat(response.getDownstreamStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value()); - assertThat(response.getDetail()).isEqualTo(problemPortalHistoryDto.getDetail()); + assertThat(response.getDetail()).isEqualTo(problemHistoryDto.getDetail()); } } |