From cf77e72ced2f815b3d011afcba17b91ae45d1858 Mon Sep 17 00:00:00 2001 From: "Bonkur, Venkat (vb8416)" Date: Mon, 9 Sep 2019 11:18:36 -0400 Subject: Add SO Update Check if SDC activities deployment end point for custom worlflows is alive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make changes to verify if SDC activities deployment end point(mso.asdc.config.activity.endpoint)  for custom worlflows is alive Issue-ID: SO-2294 Signed-off-by: Bonkur, Venkat (vb8416) Change-Id: Iff916a33b403d507a383cebf8d668bb5cbf9fb55 --- .../asdc/activity/DeployActivitySpecsITTest.java | 31 ++++++++++++++++++++++ .../asdc/activity/DeployActivitySpecsTest.java | 5 +++- 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'asdc-controller/src/test/java/org/onap/asdc') 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 catalogActivitySpecList = new ArrayList(); 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()); -- cgit 1.2.3-korg