summaryrefslogtreecommitdiffstats
path: root/adapters/so-appc-orchestrator/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/so-appc-orchestrator/src/test')
-rw-r--r--adapters/so-appc-orchestrator/src/test/java/org/onap/so/TestApplication.java43
-rw-r--r--adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallbackTest.java113
-rw-r--r--adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupportTest.java79
-rw-r--r--adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/beans/BeansTest.java20
-rw-r--r--adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java88
-rw-r--r--adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java236
-rw-r--r--adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskTest.java76
-rw-r--r--adapters/so-appc-orchestrator/src/test/resources/application-test.yaml17
-rw-r--r--adapters/so-appc-orchestrator/src/test/resources/logback-test.xml31
9 files changed, 703 insertions, 0 deletions
diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/TestApplication.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/TestApplication.java
new file mode 100644
index 0000000000..fe965b4444
--- /dev/null
+++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/TestApplication.java
@@ -0,0 +1,43 @@
+package org.onap.so;
+/*-
+ * ============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=========================================================
+ */
+
+
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.context.annotation.Profile;
+
+@SpringBootApplication
+@Profile("test")
+@ComponentScan(basePackages = {"org.onap.so"},
+ excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
+public class TestApplication {
+ public static void main(String... args) {
+ SpringApplication.run(TestApplication.class, args);
+ System.getProperties().setProperty("mso.db", "MARIADB");
+ System.getProperties().setProperty("server.name", "Springboot");
+
+
+ }
+}
diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallbackTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallbackTest.java
new file mode 100644
index 0000000000..90f5a44752
--- /dev/null
+++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallbackTest.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017-2019 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.adapters.appc.orchestrator.client;
+
+import static org.hamcrest.CoreMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import org.camunda.bpm.client.task.ExternalTask;
+import org.camunda.bpm.client.task.ExternalTaskService;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback;
+import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport;
+import org.onap.appc.client.lcm.model.Status;
+import org.onap.appc.client.lcm.exceptions.AppcClientException;
+import org.onap.appc.client.lcm.model.ResumeTrafficOutput;
+
+public class ApplicationControllerCallbackTest {
+
+ @InjectMocks
+ ApplicationControllerCallback appcTaskCallback;
+
+ @Mock
+ ApplicationControllerSupport applicationControllerSupport;
+
+ @Mock
+ ExternalTask mockExternalTask;
+
+ @Mock
+ ExternalTaskService mockExternalTaskService;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ appcTaskCallback = new ApplicationControllerCallback(mockExternalTask, mockExternalTaskService,
+ applicationControllerSupport);
+ }
+
+ @Test
+ public void onResponse_appcCallback_success_Test() throws Exception {
+ Status status = new Status();
+ status.setCode(400);
+ ResumeTrafficOutput response = new ResumeTrafficOutput();
+ response.setStatus(status);
+ doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response);
+ doReturn(true).when(applicationControllerSupport).getFinalityOf(status);
+ doReturn(StatusCategory.NORMAL).when(applicationControllerSupport).getCategoryOf(status);
+ appcTaskCallback.onResponse(response);
+ Mockito.verify(mockExternalTaskService).complete(mockExternalTask);
+ }
+
+ @Test
+ public void onResponse_appcCallback_intermediateResponse_Test() throws Exception {
+ Status status = new Status();
+ status.setCode(100);
+ ResumeTrafficOutput response = new ResumeTrafficOutput();
+ response.setStatus(status);
+ doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response);
+ appcTaskCallback.onResponse(response);
+ Mockito.verifyZeroInteractions(mockExternalTaskService);
+ }
+
+ @Test
+ public void onResponse_appcCallback_failure_Test() throws Exception {
+ String testFailure = "test failure";
+ Status status = new Status();
+ status.setCode(200);
+ status.setMessage(testFailure);
+ ResumeTrafficOutput response = new ResumeTrafficOutput();
+ response.setStatus(status);
+ doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response);
+ doReturn(true).when(applicationControllerSupport).getFinalityOf(status);
+ doReturn(StatusCategory.ERROR).when(applicationControllerSupport).getCategoryOf(status);
+ appcTaskCallback.onResponse(response);
+ Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, "MSOWorkflowException", testFailure);
+ }
+
+ @Test
+ public void onException_appcCallback_failure_Test() throws Exception {
+ String testFailure = "test failure";
+ AppcClientException appcException = new AppcClientException(testFailure);
+ Status status = new Status();
+ status.setCode(200);
+ String exceptionMessage = "Exception on APPC request: " + testFailure;
+ status.setMessage(exceptionMessage);
+ doReturn(status).when(applicationControllerSupport).buildStatusFromAppcException(appcException);
+ doReturn(StatusCategory.ERROR).when(applicationControllerSupport).getCategoryOf(status);
+ appcTaskCallback.onException(appcException);
+ Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, "MSOWorkflowException",
+ exceptionMessage);
+ }
+}
diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupportTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupportTest.java
new file mode 100644
index 0000000000..2dd2fd7ac8
--- /dev/null
+++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupportTest.java
@@ -0,0 +1,79 @@
+/*-
+ * ============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.adapters.appc.orchestrator.client;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.appc.client.lcm.exceptions.AppcClientException;
+import org.onap.appc.client.lcm.model.Status;
+import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport;
+import org.onap.so.adapters.appc.orchestrator.client.StatusCategory;
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+
+@RunWith(JUnitParamsRunner.class)
+public class ApplicationControllerSupportTest {
+ private ApplicationControllerSupport applicationControllerSupport = new ApplicationControllerSupport();
+
+ public static Object[][] statusesAndCategories() {
+ return new Object[][] {{100, StatusCategory.NORMAL}, {200, StatusCategory.ERROR}, {300, StatusCategory.ERROR},
+ {400, StatusCategory.NORMAL}, {401, StatusCategory.ERROR}, {500, StatusCategory.NORMAL},
+ {501, StatusCategory.ERROR}, {502, StatusCategory.WARNING}, {800, StatusCategory.WARNING},};
+ }
+
+ public static Object[][] statusesAndFinalities() {
+ return new Object[][] {{100, false}, {200, true}, {300, true}, {400, true}, {500, false}, {800, true},};
+ }
+
+ @Test
+ @Parameters(method = "statusesAndCategories")
+ public void shouldReturnCategoryForCode(int code, StatusCategory category) throws Exception {
+ // when
+ StatusCategory detectedCategory = applicationControllerSupport.getCategoryOf(createStatus(code));
+ // then
+ assertThat(detectedCategory).isEqualTo(category);
+ }
+
+ @Test
+ @Parameters(method = "statusesAndFinalities")
+ public void shouldReturnFinalityForCode(int code, boolean expectedFinality) throws Exception {
+ // when
+ boolean finality = applicationControllerSupport.getFinalityOf(createStatus(code));
+ // then
+ assertThat(finality).isEqualTo(expectedFinality);
+ }
+
+ @Test
+ public void buildStatusFromAppcException_Test() {
+ String errorMessage = "errormessage";
+ AppcClientException exception = new AppcClientException(errorMessage);
+ Status status = applicationControllerSupport.buildStatusFromAppcException(exception);
+ assertThat(status.getCode() == 200);
+ assertThat((status.getMessage()).equals(("Exception on APPC request: " + errorMessage)));
+ }
+
+ private Status createStatus(int code) {
+ Status status = new Status();
+ status.setCode(code);
+ return status;
+ }
+}
diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/beans/BeansTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/beans/BeansTest.java
new file mode 100644
index 0000000000..76b5efacb3
--- /dev/null
+++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/beans/BeansTest.java
@@ -0,0 +1,20 @@
+package org.onap.so.adapters.appc.orchestrator.client.beans;
+
+import org.junit.Test;
+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 class BeansTest {
+
+ @Test
+ public void validateGettersAndSetters() {
+ Validator validator = ValidatorBuilder.create().with(new SetterMustExistRule(), new GetterMustExistRule())
+ .with(new SetterTester(), new GetterTester()).build();
+ validator.validate("org.onap.so.adapters.appc.orchestrator.client.beans", new FilterPackageInfo());
+ }
+}
diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java
new file mode 100644
index 0000000000..3eac851f13
--- /dev/null
+++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java
@@ -0,0 +1,88 @@
+package org.onap.so.adapters.appc.orchestrator.service;
+
+import java.util.List;
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.appc.client.lcm.model.Status;
+import org.onap.so.TestApplication;
+import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback;
+import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerClient;
+import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException;
+import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport;
+import org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters;
+import org.onap.so.adapters.appc.orchestrator.client.beans.Identity;
+import org.onap.so.adapters.appc.orchestrator.client.beans.Parameters;
+import org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters;
+import org.onap.so.adapters.appc.orchestrator.service.ApplicationControllerTaskImpl;
+import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest;
+import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf;
+import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.camunda.bpm.client.task.ExternalTask;
+import org.camunda.bpm.client.task.ExternalTaskService;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.onap.appc.client.lcm.model.Action;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+@ContextConfiguration
+@AutoConfigureWireMock(port = 0)
+public class ApplicationControllerTaskImplITTest {
+
+ @Autowired
+ private ApplicationControllerTaskImpl applicationControllerTaskImpl;
+
+ @Mock
+ ExternalTask externalTask;
+
+ @Mock
+ ExternalTaskService externalTaskService;
+
+ @Mock
+ ApplicationControllerSupport appCSupport;
+
+ ApplicationControllerTaskRequest request;
+
+ ApplicationControllerCallback listener;
+
+ GraphInventoryCommonObjectMapperProvider mapper = new GraphInventoryCommonObjectMapperProvider();
+
+ @Before
+ public void setup() {
+ request = new ApplicationControllerTaskRequest();
+ request.setBookName("testBookName");
+ request.setControllerType("testControllerType");
+ request.setFileParameters("testFileParams");
+ request.setIdentityUrl("testIdentityUrl");
+ request.setNewSoftwareVersion("2.0");
+ request.setExistingSoftwareVersion("1.0");
+ request.setOperationsTimeout("30");
+ ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf();
+ applicationControllerVnf.setVnfHostIpAddress("100.100");
+ applicationControllerVnf.setVnfId("testVnfId");
+ applicationControllerVnf.setVnfName("testVnfName");
+ request.setApplicationControllerVnf(applicationControllerVnf);
+ listener = new ApplicationControllerCallback(null, externalTaskService, appCSupport);
+ }
+
+
+ @Test
+ public void testListener() throws Exception {
+ request.setAction(Action.QuiesceTraffic);
+ Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
+ }
+
+}
diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java
new file mode 100644
index 0000000000..640e2dbd6e
--- /dev/null
+++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java
@@ -0,0 +1,236 @@
+package org.onap.so.adapters.appc.orchestrator.service;
+
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.appc.client.lcm.model.Status;
+import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback;
+import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerClient;
+import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException;
+import org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters;
+import org.onap.so.adapters.appc.orchestrator.client.beans.Identity;
+import org.onap.so.adapters.appc.orchestrator.client.beans.Parameters;
+import org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters;
+import org.onap.so.adapters.appc.orchestrator.service.ApplicationControllerTaskImpl;
+import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest;
+import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf;
+import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.onap.appc.client.lcm.model.Action;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ApplicationControllerTaskImplTest {
+
+ @Mock
+ ApplicationControllerClient applicationControllerClient;
+
+ @InjectMocks
+ @Spy
+ ApplicationControllerTaskImpl applicationControllerTaskImpl;
+
+ ApplicationControllerTaskRequest request;
+
+ ApplicationControllerCallback listener;
+
+ GraphInventoryCommonObjectMapperProvider mapper = new GraphInventoryCommonObjectMapperProvider();
+
+ @Before
+ public void setup() {
+ request = new ApplicationControllerTaskRequest();
+ request.setBookName("testBookName");
+ request.setControllerType("testControllerType");
+ request.setFileParameters("testFileParams");
+ request.setIdentityUrl("testIdentityUrl");
+ request.setNewSoftwareVersion("2.0");
+ request.setExistingSoftwareVersion("1.0");
+ request.setOperationsTimeout("30");
+ ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf();
+ applicationControllerVnf.setVnfHostIpAddress("100.100");
+ applicationControllerVnf.setVnfId("testVnfId");
+ applicationControllerVnf.setVnfName("testVnfName");
+ request.setApplicationControllerVnf(applicationControllerVnf);
+ listener = new ApplicationControllerCallback(null, null, null);
+
+ }
+
+ @Test
+ public void testExcute_healthCheck() throws JsonProcessingException, ApplicationControllerOrchestratorException {
+ request.setAction(Action.HealthCheck);
+
+ Parameters parameters = new Parameters();
+ RequestParameters requestParams = new RequestParameters();
+ requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress());
+ parameters.setRequestParameters(requestParams);
+ Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
+
+ Mockito.when(applicationControllerClient.vnfCommand(Action.HealthCheck, "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener)).thenReturn(new Status());
+
+ Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
+
+ Mockito.verify(applicationControllerClient).vnfCommand(Action.HealthCheck, "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener);
+
+ }
+
+ @Test
+ public void testExcute_resumeTraffic() throws JsonProcessingException, ApplicationControllerOrchestratorException {
+ request.setAction(Action.ResumeTraffic);
+
+ Parameters parameters = new Parameters();
+ ConfigurationParameters configParams = new ConfigurationParameters();
+ configParams.setVnfName(request.getApplicationControllerVnf().getVnfName());
+ parameters.setConfigurationParameters(configParams);
+ Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
+
+ Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener)).thenReturn(new Status());
+
+ Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
+
+ Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener);
+ }
+
+ @Test
+ public void testExcute_stop() throws JsonProcessingException, ApplicationControllerOrchestratorException {
+ request.setAction(Action.Stop);
+
+ Identity identity = new Identity();
+ identity.setIdentityUrl(request.getIdentityUrl());
+ Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(identity)));
+
+ Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener)).thenReturn(new Status());
+
+ Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
+
+ Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener);
+ }
+
+ @Test
+ public void testExcute_lock() throws JsonProcessingException, ApplicationControllerOrchestratorException {
+ request.setAction(Action.Lock);
+
+ Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(),
+ "testControllerType", listener)).thenReturn(new Status());
+
+ Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
+
+ Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(),
+ "testControllerType", listener);
+ }
+
+ @Test
+ public void testExcute_quiesceTraffic() throws JsonProcessingException, ApplicationControllerOrchestratorException {
+ request.setAction(Action.QuiesceTraffic);
+
+
+ Parameters parameters = new Parameters();
+ parameters.setOperationsTimeout(request.getOperationsTimeout());
+ Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
+ System.out.println("PAYLOAD is: " + payload.get());
+
+ Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener)).thenReturn(new Status());
+
+ Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
+
+ Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener);
+ }
+
+ @Test
+ public void testExcute_distributeTraffic()
+ throws JsonProcessingException, ApplicationControllerOrchestratorException {
+ request.setAction(Action.DistributeTraffic);
+
+ Parameters parameters = new Parameters();
+ ConfigurationParameters configParams = new ConfigurationParameters();
+ configParams.setBookName(request.getBookName());
+ configParams.setNodeList(request.getNodeList());
+ configParams.setFileParameterContent(request.getFileParameters());
+ configParams.setVnfName(request.getApplicationControllerVnf().getVnfName());
+ parameters.setConfigurationParameters(configParams);
+ Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
+
+ Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener)).thenReturn(new Status());
+
+ Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
+
+ Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener);
+ }
+
+ @Test
+ public void testExcute_distributeTrafficCheck()
+ throws JsonProcessingException, ApplicationControllerOrchestratorException {
+ request.setAction(Action.DistributeTrafficCheck);
+
+ Parameters parameters = new Parameters();
+ ConfigurationParameters configParams = new ConfigurationParameters();
+ configParams.setBookName(request.getBookName());
+ configParams.setNodeList(request.getNodeList());
+ configParams.setFileParameterContent(request.getFileParameters());
+ configParams.setVnfName(request.getApplicationControllerVnf().getVnfName());
+ parameters.setConfigurationParameters(configParams);
+ Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
+
+ Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener)).thenReturn(new Status());
+
+ Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
+
+ Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener);
+ }
+
+ @Test
+ public void testExcute_upgradeBackup() throws JsonProcessingException, ApplicationControllerOrchestratorException {
+ request.setAction(Action.UpgradeBackup);
+
+ Parameters parameters = new Parameters();
+ parameters.setExistingSoftwareVersion(request.getExistingSoftwareVersion());
+ parameters.setNewSoftwareVersion(request.getNewSoftwareVersion());
+ Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
+
+ Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener)).thenReturn(new Status());
+
+ Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
+
+ Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId",
+ request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType",
+ listener);
+ }
+
+ @Test
+ public void testListener() throws Exception {
+ request.setAction(Action.QuiesceTraffic);
+ Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
+ }
+
+}
diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskTest.java
new file mode 100644
index 0000000000..228ee90107
--- /dev/null
+++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017-2019 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.adapters.appc.orchestrator.service;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import org.camunda.bpm.client.task.ExternalTask;
+import org.camunda.bpm.client.task.ExternalTaskService;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.so.externaltasks.logging.AuditMDCSetup;
+import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback;
+import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest;
+import org.onap.appc.client.lcm.model.Status;
+
+public class ApplicationControllerTaskTest extends ApplicationControllerTask {
+
+ @InjectMocks
+ ApplicationControllerTask appcTaskService = new ApplicationControllerTask();
+
+ @Mock
+ ApplicationControllerTaskImpl applicationControllerTaskImpl;
+
+ @Mock
+ ExternalTask mockExternalTask;
+
+ @Mock
+ ExternalTaskService mockExternalTaskService;
+
+ @Mock
+ private AuditMDCSetup mdcSetup;
+
+ private ApplicationControllerTaskRequest request = new ApplicationControllerTaskRequest();
+ private String msoRequestId = "testRequestId";
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ doNothing().when(mdcSetup).setupMDC(mockExternalTask);
+ doReturn(request).when(mockExternalTask).getVariable("appcOrchestratorRequest");
+ doReturn(msoRequestId).when(mockExternalTask).getVariable("mso-request-id");
+ }
+
+ @Test
+ public void executeExternalTask_appc_success_Test() throws Exception {
+ Status status = new Status();
+ doReturn(status).when(applicationControllerTaskImpl).execute(any(String.class),
+ any(ApplicationControllerTaskRequest.class), any(ApplicationControllerCallback.class));
+ appcTaskService.executeExternalTask(mockExternalTask, mockExternalTaskService);
+ Mockito.verify(applicationControllerTaskImpl).execute(any(String.class),
+ any(ApplicationControllerTaskRequest.class), any(ApplicationControllerCallback.class));
+ }
+}
diff --git a/adapters/so-appc-orchestrator/src/test/resources/application-test.yaml b/adapters/so-appc-orchestrator/src/test/resources/application-test.yaml
new file mode 100644
index 0000000000..eb693a263e
--- /dev/null
+++ b/adapters/so-appc-orchestrator/src/test/resources/application-test.yaml
@@ -0,0 +1,17 @@
+
+appc:
+ client:
+ key: LSl8QKolmKcC0yJR
+ response:
+ timeout: '60000'
+ secret: lgjXraD1HutKxv8jEN6tVouu
+ poolMembers: localhost:3904,localhost:3904
+ service: ueb
+ topic:
+ read:
+ name: APPC-1902-SHDEV-WRITE
+ timeout: '120000'
+ write: APPC-1902-SHDEV-READ
+ sdnc:
+ read: SDNC-LCM-READ
+ write: SDNC-LCM-WRITE \ No newline at end of file
diff --git a/adapters/so-appc-orchestrator/src/test/resources/logback-test.xml b/adapters/so-appc-orchestrator/src/test/resources/logback-test.xml
new file mode 100644
index 0000000000..8a9e705ca6
--- /dev/null
+++ b/adapters/so-appc-orchestrator/src/test/resources/logback-test.xml
@@ -0,0 +1,31 @@
+<configuration>
+
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+ <logger name="com.att.ecomp.audit" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="com.att.eelf.metrics" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="com.att.eelf.error" level="trace" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="org.onap" level="${so.log.level:-WARN}" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration> \ No newline at end of file