aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedCatalogDbConfig.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedRequestDbConfig.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java236
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java55
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java113
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetailsTest.java71
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfoTest.java118
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskListTest.java247
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.java71
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValueTest.java113
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariablesTest.java69
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksBeansTest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/ValueTest.java)55
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponseTest.java69
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequestTest.java70
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/VariablesTest.java95
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java2
21 files changed, 371 insertions, 1030 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java
index 4072613d09..508277f745 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java
@@ -31,7 +31,7 @@ import org.junit.runner.RunWith;
import org.onap.so.logger.MsoLogger;
import org.onap.so.logger.MsoLogger.Catalog;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
@@ -53,7 +53,6 @@ import java.nio.file.Paths;
@ActiveProfiles("test")
@ContextConfiguration
@Transactional
-//@Sql(executionPhase=ExecutionPhase.AFTER_TEST_METHOD,scripts="classpath:InfraActiveRequestsReset.sql")
@AutoConfigureWireMock(port = 0)
public abstract class BaseTest {
protected MsoLogger logger = MsoLogger.getMsoLogger(Catalog.GENERAL, BaseTest.class);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
index a3d388a5c6..8d5539cf8a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
@@ -271,4 +271,4 @@ private final ObjectMapper mapper = new ObjectMapper();
RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
assertTrue(realResponse.getServiceException().getText().contains("Request Failed due to BPEL error with HTTP Status"));
}
-}
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedCatalogDbConfig.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedCatalogDbConfig.java
index f504d88008..1e4b99d4ff 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedCatalogDbConfig.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedCatalogDbConfig.java
@@ -25,7 +25,7 @@ import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedRequestDbConfig.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedRequestDbConfig.java
index d150fd773a..00efb6b410 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedRequestDbConfig.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/EmbeddedRequestDbConfig.java
@@ -25,7 +25,7 @@ import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java
new file mode 100644
index 0000000000..f7e605bcc5
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java
@@ -0,0 +1,236 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.anyString;
+import java.net.URI;
+import java.util.Collections;
+import java.util.List;
+
+import org.springframework.test.util.ReflectionTestUtils;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.json.JSONException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+
+public class GlobalHealthcheckHandlerTest {
+ @Mock
+ RestTemplate restTemplate;
+
+ @Mock
+ ContainerRequestContext requestContext;
+
+ @InjectMocks
+ @Spy
+ GlobalHealthcheckHandler globalhealth;
+
+ @Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
+
+ @Test
+ public void testQuerySubsystemHealthNullResult(){
+ ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage");
+ ReflectionTestUtils.setField(globalhealth, "endpointBpmn", "http://localhost:8080");
+
+ Mockito.when(restTemplate.exchange(Matchers.any(URI.class),
+ Matchers.any(HttpMethod.class),
+ Matchers.<HttpEntity<?>> any(),
+ Matchers.<Class<Object>> any())).thenReturn(null);
+
+ String result = globalhealth.querySubsystemHealth(MsoSubsystems.BPMN);
+ System.out.println(result);
+ assertEquals(HealthcheckStatus.DOWN.toString(),result);
+ }
+
+ @Test
+ public void testQuerySubsystemHealthNotNullResult(){
+ ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage");
+ ReflectionTestUtils.setField(globalhealth, "endpointAsdc", "http://localhost:8080");
+
+ SubsystemHealthcheckResponse subSystemResponse = new SubsystemHealthcheckResponse();
+ subSystemResponse.setStatus("UP");
+ ResponseEntity<Object> r = new ResponseEntity<>(subSystemResponse,HttpStatus.OK);
+
+ Mockito.when(restTemplate.exchange(Matchers.any(URI.class),
+ Matchers.any(HttpMethod.class),
+ Matchers.<HttpEntity<?>> any(),
+ Matchers.<Class<Object>> any())).thenReturn(r);
+
+ String result = globalhealth.querySubsystemHealth(MsoSubsystems.ASDC);
+ System.out.println(result);
+ assertEquals(HealthcheckStatus.UP.toString(),result);
+ }
+
+ private Response globalHealthcheck (String status){
+ ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage");
+ ReflectionTestUtils.setField(globalhealth, "endpointAsdc", "http://localhost:8080");
+ ReflectionTestUtils.setField(globalhealth, "endpointSdnc", "http://localhost:8081");
+ ReflectionTestUtils.setField(globalhealth, "endpointBpmn", "http://localhost:8082");
+ ReflectionTestUtils.setField(globalhealth, "endpointCatalogdb", "http://localhost:8083");
+ ReflectionTestUtils.setField(globalhealth, "endpointOpenstack", "http://localhost:8084");
+ ReflectionTestUtils.setField(globalhealth, "endpointRequestdb", "http://localhost:8085");
+ ReflectionTestUtils.setField(globalhealth, "endpointRequestdbAttsvc", "http://localhost:8086");
+
+ SubsystemHealthcheckResponse subSystemResponse = new SubsystemHealthcheckResponse();
+
+ subSystemResponse.setStatus(status);
+ ResponseEntity<Object> r = new ResponseEntity<>(subSystemResponse,HttpStatus.OK);
+ Mockito.when(restTemplate.exchange(Matchers.any(URI.class),
+ Matchers.any(HttpMethod.class),
+ Matchers.<HttpEntity<?>> any(),
+ Matchers.<Class<Object>> any())).thenReturn(r);
+
+ Mockito.when(requestContext.getProperty(anyString())).thenReturn("1234567890");
+ Response response = globalhealth.globalHealthcheck(true, requestContext);
+
+ return response;
+ }
+
+ @Test
+ public void globalHealthcheckAllUPTest() throws JSONException {
+ Response response = globalHealthcheck("UP");
+ assertEquals(Response.Status.OK.getStatusCode(),response.getStatus());
+ HealthcheckResponse root;
+ root = (HealthcheckResponse) response.getEntity();
+ String apistatus = root.getApih();
+ assertTrue(apistatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+
+ String bpmnstatus = root.getBpmn();
+ assertTrue(bpmnstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+
+ String sdncstatus = root.getSdncAdapter();
+ assertTrue(sdncstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+
+ String asdcstatus = root.getAsdcController();
+ assertTrue(asdcstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+
+ String catastatus = root.getCatalogdbAdapter();
+ assertTrue(catastatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+
+ String reqdbstatus = root.getRequestdbAdapter();
+ assertTrue(reqdbstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+
+ String openstatus = root.getOpenstackAdapter();
+ assertTrue(openstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+
+ String reqdbattstatus = root.getRequestdbAdapterAttsvc();
+ assertTrue(reqdbattstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+ }
+
+ @Test
+ public void globalHealthcheckAllDOWNTest() throws JSONException {
+ Response response = globalHealthcheck("DOWN");
+ assertEquals(Response.Status.OK.getStatusCode(),response.getStatus());
+ HealthcheckResponse root;
+ root = (HealthcheckResponse) response.getEntity();
+ String apistatus = root.getApih();
+ assertTrue(apistatus.equalsIgnoreCase(HealthcheckStatus.UP.toString()));
+
+ String bpmnstatus = root.getBpmn();
+ assertTrue(bpmnstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
+
+ String sdncstatus = root.getSdncAdapter();
+ assertTrue(sdncstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
+
+ String asdcstatus = root.getAsdcController();
+ assertTrue(asdcstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
+
+ String catastatus = root.getCatalogdbAdapter();
+ assertTrue(catastatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
+
+ String reqdbstatus = root.getRequestdbAdapter();
+ assertTrue(reqdbstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
+
+ String openstatus = root.getOpenstackAdapter();
+ assertTrue(openstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
+
+ String reqdbattstatus = root.getRequestdbAdapterAttsvc();
+ assertTrue(reqdbattstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString()));
+ }
+
+ @Test
+ public void buildHttpEntityForRequestTest(){
+ HttpEntity<String> he = globalhealth.buildHttpEntityForRequest();
+ assertEquals (MediaType.APPLICATION_JSON,he.getHeaders().getAccept().get(0));
+ assertEquals (MediaType.APPLICATION_JSON,he.getHeaders().getContentType());
+ }
+
+ @Test
+ public void getEndpointUrlForSubsystemEnumTest(){
+ ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage");
+ ReflectionTestUtils.setField(globalhealth, "endpointAsdc", "http://localhost:8080");
+ ReflectionTestUtils.setField(globalhealth, "endpointSdnc", "http://localhost:8081");
+ ReflectionTestUtils.setField(globalhealth, "endpointBpmn", "http://localhost:8082");
+ ReflectionTestUtils.setField(globalhealth, "endpointCatalogdb", "http://localhost:8083");
+ ReflectionTestUtils.setField(globalhealth, "endpointOpenstack", "http://localhost:8084");
+ ReflectionTestUtils.setField(globalhealth, "endpointRequestdb", "http://localhost:8085");
+ ReflectionTestUtils.setField(globalhealth, "endpointRequestdbAttsvc", "http://localhost:8086");
+
+ String result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.ASDC);
+ assertEquals("http://localhost:8080", result);
+ result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.SDNC);
+ assertEquals("http://localhost:8081", result);
+ result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.BPMN);
+ assertEquals("http://localhost:8082", result);
+ result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.CATALOGDB);
+ assertEquals("http://localhost:8083", result);
+ result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.OPENSTACK);
+ assertEquals("http://localhost:8084", result);
+ result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.REQUESTDB);
+ assertEquals("http://localhost:8085", result);
+ result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.REQUESTDBATT);
+ assertEquals("http://localhost:8086", result);
+ }
+
+ @Test
+ public void processResponseFromSubsystemTest(){
+ SubsystemHealthcheckResponse subSystemResponse = new SubsystemHealthcheckResponse();
+ subSystemResponse.setStatus("UP");
+ ResponseEntity<SubsystemHealthcheckResponse> r = new ResponseEntity<>(subSystemResponse,HttpStatus.OK);
+ String result = globalhealth.processResponseFromSubsystem(r,MsoSubsystems.BPMN);
+ assertEquals("UP",result);
+ }
+
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java
deleted file mode 100644
index 8b4d353a56..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.apihandlerinfra;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-import javax.ws.rs.core.Response;
-
-import org.json.JSONException;
-import org.junit.Test;
-import org.springframework.boot.test.web.client.TestRestTemplate;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-
-
-public class HealthCheckHandlerTest extends BaseTest{
-
- @Test
- public void testHealthcheckGet() throws JSONException {
- HttpHeaders headers = new HttpHeaders();
- HttpEntity<String> entity = new HttpEntity<String>(null, headers);
-
- ResponseEntity<String> response = restTemplate.exchange(
- createURLWithPort("/manage/health"),
- HttpMethod.GET, entity, String.class);
-
- assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
- assertThat(response.getBody(), containsString("UP"));
-
- }
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
index f4fede15e1..bb78c822f7 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
@@ -27,7 +27,8 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import java.io.IOException;
import java.util.Map;
@@ -44,6 +45,8 @@ import org.onap.so.apihandlerinfra.tasksbeans.TaskRequestReference;
import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest;
import org.onap.so.apihandlerinfra.tasksbeans.ValidResponses;
import org.onap.so.logger.MsoLogger;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.ServiceException;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -52,6 +55,7 @@ import org.springframework.web.util.UriComponentsBuilder;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.tomakehurst.wiremock.http.Fault;
import ch.qos.logback.classic.spi.ILoggingEvent;
@@ -134,4 +138,111 @@ public class ManualTasksTest extends BaseTest{
assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
}
}
+ @Test
+ public void completeTaskMappingError() throws IOException {
+ String invalidRequest = "test";
+ RequestError expectedResponse = new RequestError();
+ ServiceException se = new ServiceException();
+ se.setMessageId("SVC0002");
+ se.setText("Mapping of request to JSON object failed: Unrecognized token \'test\': "
+ + "was expecting \'null\', \'true\', \'false\' or NaN\n at [Source: (String)\"test\"; line: 1, column: 9]");
+ expectedResponse.setServiceException(se);
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ headers.set(MsoLogger.ECOMP_REQUEST_ID, "987654321");
+ headers.set(MsoLogger.CLIENT_ID, "VID");
+ HttpEntity<String> entity = new HttpEntity<String>(invalidRequest, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + "55" + "/complete");
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+ }
+ @Test
+ public void completeTaskValidationError() throws IOException {
+ String taskId = "55";
+ TasksRequest taskReq = new TasksRequest();
+ RequestDetails reqDetail = new RequestDetails();
+ RequestInfo reqInfo = new RequestInfo();
+ reqInfo.setSource("testSource");
+ reqInfo.setResponseValue(ValidResponses.skip);
+ reqDetail.setRequestInfo(reqInfo);
+ taskReq.setRequestDetails(reqDetail);
+
+ RequestError expectedResponse = new RequestError();
+ ServiceException se = new ServiceException();
+ se.setMessageId("SVC0002");
+ se.setText("Mapping of request to JSON Object failed. No valid requestorId is specified");
+ expectedResponse.setServiceException(se);
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ headers.set(MsoLogger.ECOMP_REQUEST_ID, "987654321");
+ headers.set(MsoLogger.CLIENT_ID, "VID");
+ HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete");
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+ }
+ @Test
+ public void completeTaskBpelResponseError() throws IOException {
+ stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withFault(Fault.EMPTY_RESPONSE)));
+
+ String taskId = "55";
+ TasksRequest taskReq = new TasksRequest();
+ RequestDetails reqDetail = new RequestDetails();
+ RequestInfo reqInfo = new RequestInfo();
+ reqInfo.setRequestorId("testId");
+ reqInfo.setSource("testSource");
+ reqInfo.setResponseValue(ValidResponses.skip);
+ reqDetail.setRequestInfo(reqInfo);
+ taskReq.setRequestDetails(reqDetail);
+
+ RequestError expectedResponse = new RequestError();
+ ServiceException se = new ServiceException();
+ se.setMessageId("SVC1000");
+ se.setText("Request Failed due to BPEL error with HTTP Status = 502");
+ expectedResponse.setServiceException(se);
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ headers.set(MsoLogger.ECOMP_REQUEST_ID, "987654321");
+ headers.set(MsoLogger.CLIENT_ID, "VID");
+ HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete");
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
index ea2261a94a..58d6b7f1c7 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -439,4 +439,4 @@ public class OrchestrationRequestsTest extends BaseTest {
.withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getRequestDetailsFilter.json"))))
.withStatus(HttpStatus.SC_OK)));
}
-}
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java
index fa323a12c2..c7b4cc0574 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java
@@ -120,4 +120,4 @@ public class TasksHandlerTest extends BaseTest{
assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
}
-}
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetailsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetailsTest.java
deleted file mode 100644
index 80cd0fac2f..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetailsTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-
-public class RequestDetailsTest {
-
- RequestDetails _requestDetails;
- RequestInfo _requestInfo;
-
- public RequestDetailsTest() {
- }
-
- @Before
- public void setUp() {
- _requestDetails = mock(RequestDetails.class);
- _requestInfo = new RequestInfo();
- when(_requestDetails.getRequestInfo()).thenReturn(_requestInfo);
- }
-
- @After
- public void tearDown() {
- _requestDetails = null;
- _requestInfo = null;
- }
-
- /**
- * Test of getRequestInfo method
- */
- @Test
- public void testGetRequestInfo() {
- _requestDetails.setRequestInfo(_requestInfo);
- assertTrue(_requestDetails.getRequestInfo().equals(_requestInfo));
-
- }
-
- /**
- * Test setRequestInfo
- */
- @Test
- public void testSetRequestInfo() {
- _requestDetails.setRequestInfo(_requestInfo);
- verify(_requestDetails).setRequestInfo(_requestInfo);
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfoTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfoTest.java
deleted file mode 100644
index 852376eb7a..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfoTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class RequestInfoTest {
-
- RequestInfo _requestInfo;
- String _source;
- ValidResponses _responseValue;
- String _requestorId;
-
- public RequestInfoTest() {
- }
-
- @Before
- public void setUp() {
- _requestInfo = mock(RequestInfo.class);
- _responseValue = ValidResponses.abort;
- _requestorId = "xxxxxx";
- _source = "VID";
- when(_requestInfo.getRequestorId()).thenReturn(_requestorId);
- when(_requestInfo.getSource()).thenReturn(_source);
- when(_requestInfo.getResponseValue()).thenReturn(_responseValue);
-
- }
-
- @After
- public void tearDown() {
- _requestInfo = null;
- _responseValue = null;
- }
-
- /**
- * Test of getSource method
- */
- @Test
- public void testGetSource() {
- String result = _requestInfo.getSource();
- assertEquals(_source, result);
-
- }
-
- /**
- * Test setSource
- */
- @Test
- public void testSetSource() {
- _requestInfo.setSource("VID");
- verify(_requestInfo).setSource(_source);
- }
-
- /**
- * Test of getRequestorId method
- */
- @Test
- public void testGetRequestorId() {
- String result = _requestInfo.getRequestorId();
- assertEquals(_requestorId, result);
-
- }
-
- /**
- * Test setRequestInfo
- */
- @Test
- public void testSetRequestorId() {
- _requestInfo.setRequestorId(_requestorId);
- verify(_requestInfo).setRequestorId(_requestorId);
- }
-
-
- /**
- * Test of getResponseValue method
- */
- @Test
- public void testGetResponseValue() {
- ValidResponses result = _requestInfo.getResponseValue();
- assertEquals(_responseValue, result);
-
- }
-
- /**
- * Test setResponseValues method
- */
- @Test
- public void testSetResponseValue() {
- _requestInfo.setResponseValue(ValidResponses.abort);
- verify(_requestInfo).setResponseValue(_responseValue);
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskListTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskListTest.java
deleted file mode 100644
index 62bfee989b..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskListTest.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.apihandlerinfra.tasksbeans;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class TaskListTest {
-
- TaskList _taskList;
- protected String _taskId;
- protected String _type;
- protected String _nfRole;
- protected String _subscriptionServiceType;
- protected String _originalRequestId;
- protected String _originalRequestorId;
- protected String _errorSource;
- protected String _errorCode;
- protected String _errorMessage;
- protected String _buildingBlockName;
- protected String _buildingBlockStep;
- protected List<String> _validResponses;
-
- public TaskListTest() {
- }
-
- @Before
- public void setUp() {
- _taskList = mock(TaskList.class);
- _taskId = "_taskid";
- _type = "type";
- _nfRole = "nfrole";
- _subscriptionServiceType = "subscriptionservicetype";
- _originalRequestId = "originalrequestid";
- _originalRequestorId = "originalrequestorid";
- _errorSource = "errorsource";
- _errorCode = "errorcode";
- _errorMessage = "errormessage";
- _buildingBlockName = "buildingblockname";
- _buildingBlockStep = "buildingblockstep";
- _validResponses = mock(List.class);
-
- when(_taskList.getTaskId()).thenReturn(_taskId);
- when(_taskList.getType()).thenReturn(_type);
- when(_taskList.getNfRole()).thenReturn(_nfRole);
- when(_taskList.getSubscriptionServiceType()).thenReturn(_subscriptionServiceType);
- when(_taskList.getOriginalRequestId()).thenReturn(_originalRequestId);
- when(_taskList.getOriginalRequestorId()).thenReturn(_originalRequestorId);
- when(_taskList.getErrorSource()).thenReturn(_errorSource);
- when(_taskList.getErrorCode()).thenReturn(_errorCode);
- when(_taskList.getErrorMessage()).thenReturn(_errorMessage);
- when(_taskList.getBuildingBlockName()).thenReturn(_buildingBlockName);
- when(_taskList.getBuildingBlockStep()).thenReturn(_buildingBlockStep);
- when(_taskList.getValidResponses()).thenReturn(_validResponses);
- }
-
- @After
- public void tearDown() {
- _taskList = null;
- _validResponses = null;
- }
-
- @Test
- public void testGetTaskId() {
- String result = _taskList.getTaskId();
- assertEquals(_taskId, result);
-
- }
-
- @Test
- public void testSetTaskId() {
- _taskList.setTaskId("_taskid");
- verify(_taskList).setTaskId(_taskId);
- }
-
- @Test
- public void testGetType() {
- String result = _taskList.getType();
- assertEquals(_type, result);
-
- }
-
- @Test
- public void testSetType() {
- _taskList.setType(_type);
- verify(_taskList).setType(_type);
- }
-
- @Test
- public void testGetNfRole() {
- String result = _taskList.getNfRole();
- assertEquals(_nfRole, result);
-
- }
-
- @Test
- public void testSetNfRole() {
- _taskList.setType(_nfRole);
- verify(_taskList).setType(_nfRole);
- }
-
- @Test
- public void testGetSubscriptionServiceType() {
- String result = _taskList.getSubscriptionServiceType();
- assertEquals(_subscriptionServiceType, result);
-
- }
-
- @Test
- public void testSetSubscriptionServiceType() {
- _taskList.setSubscriptionServiceType(_subscriptionServiceType);
- verify(_taskList).setSubscriptionServiceType(_subscriptionServiceType);
- }
-
- @Test
- public void testGetOriginalRequestId() {
- String result = _taskList.getOriginalRequestId();
- assertEquals(_originalRequestId, result);
-
- }
-
- @Test
- public void testSetOriginalRequestId() {
- _taskList.setOriginalRequestId(_originalRequestId);
- verify(_taskList).setOriginalRequestId(_originalRequestId);
- }
-
- @Test
- public void testGetOriginalRequestorId() {
- String result = _taskList.getOriginalRequestorId();
- assertEquals(_originalRequestorId, result);
-
- }
-
- @Test
- public void testSetOriginalRequestorId() {
- _taskList.setOriginalRequestorId(_originalRequestorId);
- verify(_taskList).setOriginalRequestorId(_originalRequestorId);
- }
-
- @Test
- public void testGetErrorSource() {
- String result = _taskList.getErrorSource();
- assertEquals(_errorSource, result);
-
- }
-
- @Test
- public void testSetErrorSource() {
- _taskList.setErrorSource(_errorSource);
- verify(_taskList).setErrorSource(_errorSource);
- }
-
- @Test
- public void testGetErrorCode() {
- String result = _taskList.getErrorCode();
- assertEquals(_errorCode, result);
-
- }
-
- @Test
- public void testSetErrorCode() {
- _taskList.setErrorCode(_errorCode);
- verify(_taskList).setErrorCode(_errorCode);
- }
-
- @Test
- public void testGetErrorMessage() {
- String result = _taskList.getErrorMessage();
- assertEquals(_errorMessage, result);
-
- }
-
- @Test
- public void testSetErrorMessage() {
- _taskList.setErrorMessage(_errorMessage);
- verify(_taskList).setErrorMessage(_errorMessage);
- }
-
- @Test
- public void testGetBuildingBlockName() {
- String result = _taskList.getBuildingBlockName();
- assertEquals(_buildingBlockName, result);
-
- }
-
- @Test
- public void testSetBuildingBlockName() {
- _taskList.setBuildingBlockName(_buildingBlockName);
- verify(_taskList).setBuildingBlockName(_buildingBlockName);
- }
-
- @Test
- public void testGetBuildingBlockStep() {
- String result = _taskList.getBuildingBlockStep();
- assertEquals(_buildingBlockStep, result);
-
- }
-
- @Test
- public void testSetBuildingBlockStep() {
- _taskList.setBuildingBlockStep(_buildingBlockStep);
- verify(_taskList).setBuildingBlockStep(_buildingBlockStep);
- }
-
- @Test
- public void testGetValidResponses() {
-
- List<String> result = _taskList.getValidResponses();
- assertEquals(_validResponses, result);
-
- }
-
- @Test
- public void testSetValidResponses() {
- _taskList.setValidResponses(_validResponses);
- verify(_taskList).setValidResponses(_validResponses);
- }
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.java
deleted file mode 100644
index 043f4ea93d..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReferenceTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class TaskRequestReferenceTest {
-
- TaskRequestReference _taskRequestReference;
-
- protected String _taskId;
- public TaskRequestReferenceTest() {
- }
-
- @Before
- public void setUp() {
- _taskRequestReference = mock(TaskRequestReference.class);
- _taskId = "taskid";
-
- when(_taskRequestReference.getTaskId()).thenReturn(_taskId);
- }
-
- @After
- public void tearDown() {
- _taskRequestReference = null;
- }
-
- /**
- * Test getTaskRequestReference
- */
- @Test
- public void taskGetRequestReference() {
- String result = _taskRequestReference.getTaskId();
- assertEquals(_taskId, result);
- }
-
- /**
- * Test setTaskRequestReference
- */
- @Test
- public void testSetRequestInfo() {
- _taskRequestReference.setTaskId(_taskId);
- verify(_taskRequestReference).setTaskId(_taskId);
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValueTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValueTest.java
deleted file mode 100644
index bc6a5ab890..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValueTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class TaskVariableValueTest {
- TaskVariableValue _taskVariableValue;
- protected String _name;
- protected String _value;
- protected String _operator;
-
- public TaskVariableValueTest() {
- }
-
- @Before
- public void setUp() {
- _taskVariableValue = mock(TaskVariableValue.class);
- _name = "name";
- _value = "value";
- _operator = "operator";
- when(_taskVariableValue.getName()).thenReturn(_name);
- when(_taskVariableValue.getValue()).thenReturn(_value);
- when(_taskVariableValue.getOperator()).thenReturn(_operator);
- }
-
- @After
- public void tearDown() {
- _taskVariableValue = null;
- }
-
- /**
- * Test of getName method
- */
- @Test
- public void testGetName() {
- _taskVariableValue.setName(_name);
- assertEquals(_taskVariableValue.getName(),_name);
-
- }
-
- /**
- * Test setName
- */
- @Test
- public void testSetName() {
- _taskVariableValue.setName(_name);
- verify(_taskVariableValue).setName(_name);
- }
-
- /**
- * Test of getName method
- */
- @Test
- public void testGetValue() {
- _taskVariableValue.setValue(_value);
- assertEquals(_taskVariableValue.getValue(),_value);
-
- }
-
- /**
- * Test setName
- */
- @Test
- public void testSetValue() {
- _taskVariableValue.setValue(_value);
- verify(_taskVariableValue).setValue(_value);
- }
-
- /**
- * Test of getName method
- */
- @Test
- public void testGetOperator() {
- _taskVariableValue.setOperator(_operator);
- assertEquals(_taskVariableValue.getOperator(),_operator);
-
- }
-
- /**
- * Test setName
- */
- @Test
- public void testSetRequestDetails() {
- _taskVariableValue.setOperator(_operator);
- verify(_taskVariableValue).setOperator(_operator);
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariablesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariablesTest.java
deleted file mode 100644
index 8e2c3ae7da..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariablesTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.List;
-
-public class TaskVariablesTest {
-
- TaskVariables _taskVariables;
- private List<TaskVariableValue> _taskVariableValueList;
-
- public TaskVariablesTest() {
- }
-
- @SuppressWarnings("unchecked")
- @Before
- public void setUp() {
- _taskVariables = mock(TaskVariables.class);
- _taskVariableValueList = mock(List.class);
- when(_taskVariables.getTaskVariables()).thenReturn(_taskVariableValueList);
- }
-
- @After
- public void tearDown() {
- _taskVariables = null;
- }
-
- @Test
- public void testGetTaskVariables() {
- List<TaskVariableValue> result = _taskVariables.getTaskVariables();
- assertEquals(_taskVariableValueList, result);
-
- }
-
- @Test
- public void testSetTaskVariables() {
- _taskVariables.setTaskVariables(_taskVariableValueList);
- verify(_taskVariables).setTaskVariables(_taskVariableValueList);
-
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/ValueTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksBeansTest.java
index dc5cf8ed39..cbdfe6b831 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/ValueTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksBeansTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,49 +20,22 @@
package org.onap.so.apihandlerinfra.tasksbeans;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import org.onap.so.apihandlerinfra.BaseTest;
-public class ValueTest {
- Value _valueInstance;
- protected String _value;
+import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
- public ValueTest() {
- }
-
- @Before
- public void setUp() {
- _valueInstance = mock(Value.class);
- _value = "_value";
- when(_valueInstance.getValue()).thenReturn(_value);
- }
-
- @After
- public void tearDown() {
- _valueInstance = null;
- }
-
- /**
- * Test of getValue method
- */
- @Test
- public void testGetValue() {
- _valueInstance.setValue(_value);
- assertEquals(_valueInstance.getValue(),_value);
-
- }
-
- /**
- * Test setValue
- */
+public class TasksBeansTest extends BaseTest{
@Test
- public void testSetValue() {
- _valueInstance.setValue(_value);
- verify(_valueInstance).setValue(_value);
+ public void validateGettersAndSetters() {
+ Validator validator = ValidatorBuilder.create().with(new SetterMustExistRule(), new GetterMustExistRule())
+ .with(new SetterTester(), new GetterTester()).build();
+ validator.validate("org.onap.so.apihandlerinfra.tasksbeans", new FilterPackageInfo());
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponseTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponseTest.java
deleted file mode 100644
index f4ec27e852..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponseTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.List;
-
-public class TasksGetResponseTest {
-
- TasksGetResponse _tasksGetResponse;
- private List<TaskList> _taskList;
-
- public TasksGetResponseTest() {
- }
-
- @SuppressWarnings("unchecked")
- @Before
- public void setUp() {
- _tasksGetResponse = mock(TasksGetResponse.class);
- _taskList = mock(List.class);
- when(_tasksGetResponse.getTaskList()).thenReturn(_taskList);
- }
-
- @After
- public void tearDown() {
- _tasksGetResponse = null;
- }
-
- @Test
- public void testGetTaskList() {
- List<TaskList> result = _tasksGetResponse.getTaskList();
- assertEquals(_taskList, result);
-
- }
-
- @Test
- public void testSetTaskList() {
- _tasksGetResponse.setTaskList(_taskList);
- verify(_tasksGetResponse).setTaskList(_taskList);
-
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequestTest.java
deleted file mode 100644
index 09af2b0a52..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequestTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-
-public class TasksRequestTest {
- TasksRequest _tasksRequest;
- private RequestDetails _requestDetails;
-
- public TasksRequestTest() {
- }
-
- @Before
- public void setUp() {
- _tasksRequest = mock(TasksRequest.class);
- _requestDetails = new RequestDetails();
- when(_tasksRequest.getRequestDetails()).thenReturn(_requestDetails);
- }
-
- @After
- public void tearDown() {
- _tasksRequest = null;
- }
-
- /**
- * Test of getRequestDetails method
- */
- @Test
- public void testGetRequestDetails() {
- _tasksRequest.setRequestDetails(_requestDetails);
- assertTrue(_tasksRequest.getRequestDetails().equals(_requestDetails));
-
- }
-
- /**
- * Test setRequestDetails
- */
- @Test
- public void testSetRequestDetails() {
- _tasksRequest.setRequestDetails(_requestDetails);
- verify(_tasksRequest).setRequestDetails(_requestDetails);
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/VariablesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/VariablesTest.java
deleted file mode 100644
index d79e5f6294..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tasksbeans/VariablesTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.apihandlerinfra.tasksbeans;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class VariablesTest {
-
- Variables _variables;
- protected Value _source;
- protected Value _responseValue;
- protected Value _requestorId;
-
- @Before
- public void setUp() {
- _variables = mock(Variables.class);
- _source = mock(Value.class);
- _responseValue = mock(Value.class);
- _requestorId = mock(Value.class);
-
- when(_variables.getSource()).thenReturn(_source);
- when(_variables.getRequestorId()).thenReturn(_requestorId);
- when(_variables.getResponseValue()).thenReturn(_responseValue);
-
- }
-
- @After
- public void tearDown() {
- _variables = null;
- _source = null;
- _responseValue = null;
- _requestorId = null;
- }
-
- @Test
- public void testGetSource() {
- _variables.setSource(_source);
- assertTrue(_variables.getSource().equals(_source));
- }
-
- @Test
- public void testSetSource(){
- _variables.setSource(_source);
- verify(_variables).setSource(_source);
- }
-
- @Test
- public void testGetResponseValue() {
- _variables.setResponseValue(_responseValue);
- assertTrue(_variables.getResponseValue().equals(_responseValue));
- }
-
- @Test
- public void testSetResponseValue(){
- _variables.setResponseValue(_responseValue);
- verify(_variables).setResponseValue(_responseValue);
- }
-
- @Test
- public void testGetRequestorId() {
- _variables.setRequestorId(_requestorId);
- assertTrue(_variables.getRequestorId().equals(_requestorId));
- }
-
- @Test
- public void testSetRequestorId(){
- _variables.setRequestorId(_requestorId);
- verify(_variables).setRequestorId(_requestorId);
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java
index 37ec14a0b5..afcf0f54c8 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java
@@ -25,7 +25,7 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.contains;
import static org.mockito.Mockito.doNothing;
@@ -43,7 +43,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandlerinfra.ApiHandlerApplication;
import org.onap.so.apihandlerinfra.BaseTest;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
index 9aa961c665..f9e3ec6498 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java
@@ -28,7 +28,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;