aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller/src/test/java/org')
-rw-r--r--asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java31
-rw-r--r--asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java5
2 files changed, 35 insertions, 1 deletions
diff --git a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java
index 81977da278..b41fbaf658 100644
--- a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java
+++ b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java
@@ -22,7 +22,10 @@ package org.onap.asdc.activity;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static com.github.tomakehurst.wiremock.client.WireMock.verify;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import org.junit.Test;
@@ -73,4 +76,32 @@ public class DeployActivitySpecsITTest extends BaseTest {
deployActivitySpecs.deployActivities();
assertTrue(activitySpecCreateResponse.getId().equals("testActivityId"));
}
+
+ @Test
+ public void deployActivitySpecsIT_SDCEndpointDown_Test() throws Exception {
+ ActivitySpecCreateResponse activitySpecCreateResponse = new ActivitySpecCreateResponse();
+ activitySpecCreateResponse.setId("testActivityId");
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+
+ ObjectMapper mapper = new ObjectMapper();
+ String body = mapper.writeValueAsString(activitySpecCreateResponse);
+
+ wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withStatus(org.springframework.http.HttpStatus.OK.value()).withBody(body)));
+
+ when(env.getProperty("mso.asdc.config.activity.endpoint")).thenReturn("http://localhost:8090");
+
+ String urlPath = "/v1.0/activity-spec/testActivityId/versions/latest/actions";
+
+ wireMockServer.stubFor(
+ put(urlPathMatching(urlPath)).willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withStatus(org.springframework.http.HttpStatus.OK.value())));
+
+ deployActivitySpecs.deployActivities();
+ verify(0, putRequestedFor(urlEqualTo(urlPath)));
+ }
+
}
diff --git a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java
index aae5e5dc53..7a876a67a2 100644
--- a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java
+++ b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsTest.java
@@ -30,6 +30,7 @@ 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.so.asdc.activity.ActivitySpecsActions;
import org.onap.so.asdc.activity.DeployActivitySpecs;
@@ -54,6 +55,7 @@ public class DeployActivitySpecsTest {
protected ActivitySpecsActions activitySpecsActions;
@InjectMocks
+ @Spy
private DeployActivitySpecs deployActivitySpecs;
@Test
@@ -68,7 +70,8 @@ public class DeployActivitySpecsTest {
List<org.onap.so.db.catalog.beans.ActivitySpec> catalogActivitySpecList =
new ArrayList<org.onap.so.db.catalog.beans.ActivitySpec>();
catalogActivitySpecList.add(catalogActivitySpec);
- when(env.getProperty("mso.asdc.config.activity.endpoint")).thenReturn("testEndpoint");
+ when(env.getProperty("mso.asdc.config.activity.endpoint")).thenReturn("http://testEndpoint");
+ doReturn(true).when(deployActivitySpecs).checkHttpOk("http://testEndpoint");
when(activitySpecRepository.findAll()).thenReturn(catalogActivitySpecList);
doReturn("testActivityId").when(activitySpecsActions).createActivitySpec(Mockito.any(), Mockito.any());
doReturn(true).when(activitySpecsActions).certifyActivitySpec(Mockito.any(), Mockito.any());