diff options
author | romaingimbert <romain.gimbert@orange.com> | 2018-08-22 10:00:22 +0200 |
---|---|---|
committer | romaingimbert <romain.gimbert@orange.com> | 2018-08-22 10:00:22 +0200 |
commit | 8c4f868a5417629c1be17d7b98307fb5ed575211 (patch) | |
tree | 07e266da1c127d41a6df22084c014acbb61f67f0 /src/test/java/org | |
parent | 9feae3a717ad1fc69700e59f7b3181fa78337138 (diff) |
Help NBI user to get information
-add orderMessage 105 (service name already exists)
-add tests
Change-Id: I62ead9c22af49ee14d3a99eb97dddbf4fcd91e3c
Issue-ID: EXTAPI-116
Signed-off-by: romaingimbert <romain.gimbert@orange.com>
Diffstat (limited to 'src/test/java/org')
-rw-r--r-- | src/test/java/org/onap/nbi/apis/ApiTest.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/test/java/org/onap/nbi/apis/ApiTest.java b/src/test/java/org/onap/nbi/apis/ApiTest.java index f18c5f8..3268bab 100644 --- a/src/test/java/org/onap/nbi/apis/ApiTest.java +++ b/src/test/java/org/onap/nbi/apis/ApiTest.java @@ -17,6 +17,8 @@ package org.onap.nbi.apis; import static org.assertj.core.api.Assertions.assertThat; + +import com.github.tomakehurst.wiremock.http.ResponseDefinition; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -128,10 +130,27 @@ public class ApiTest { if (mapping.getRequest().getUrl().equals(s)) { mappingToDelete = mapping; } + + } + wireMockServer.removeStubMapping(mappingToDelete); } + private void changeWireMockResponse(String s,int statusCode, String bodyContent) { + ListStubMappingsResult listStubMappingsResult = wireMockServer.listAllStubMappings(); + ResponseDefinition responseDefinition = new ResponseDefinition(statusCode,bodyContent); + List<StubMapping> mappings = listStubMappingsResult.getMappings(); + for (StubMapping mapping : mappings) { + if (mapping.getRequest().getUrl().equals(s)) { + mapping.setResponse(responseDefinition); + } + } + } + + + + // serviceCatalog @@ -1033,4 +1052,39 @@ public class ApiTest { assertThat(executionTaskRepository.count()).isEqualTo(0); } + + + @Test + public void testExecutionTaskFailedBadRequestSo() throws Exception { + + ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, + executionTaskRepository, ActionType.ADD); + + + changeWireMockResponse("/ecomp/mso/infra/serviceInstances/v6",400,"\"serviceException\": {\n" + + " \"messageId\": \"SVC0002\",\n" + + " \"text\": \"Error parsing request. org.openecomp.mso.apihandler.common.ValidationException: serviceInstance already existsd\"\n" + + " }"); + + + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); + } + + assertThat(executionTaskRepository.count()).isEqualTo(0); + + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + if(serviceOrderItem.getId().equals("A")) { + assertThat(serviceOrderItem.getOrderItemMessage().size()).isEqualTo(1); + assertThat(serviceOrderItem.getOrderItemMessage().get(0).getCode()).isEqualTo("105"); + assertThat(serviceOrderItem.getOrderItemMessage().get(0).getField()).isEqualTo("service.name"); + } + } + + } + + } |