summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzm330 <zhangminyj@chinamobile.com>2020-03-09 16:46:06 +0800
committerZhang Min <zhangminyj@chinamobile.com>2020-03-10 06:02:47 +0000
commit2fe0c87c49bab2c409a7c57c62b680816be96b12 (patch)
tree89e637a1c93ce6cbf806650a9f4c246a294eb46a
parenta66c2e4aa0742e368393317bdbad48377d82113d (diff)
Update test for deleting communication service
Issue-ID: SO-2368 Signed-off-by: zm330 <zhangminyj@chinamobile.com> Change-Id: Ib762da956041cab73082cdd355d59c3cf6dd29ee
-rw-r--r--adapters/mso-nssmf-adapter/pom.xml2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy52
3 files changed, 50 insertions, 6 deletions
diff --git a/adapters/mso-nssmf-adapter/pom.xml b/adapters/mso-nssmf-adapter/pom.xml
index bad9c5a81f..3e9c2fe6d7 100644
--- a/adapters/mso-nssmf-adapter/pom.xml
+++ b/adapters/mso-nssmf-adapter/pom.xml
@@ -28,7 +28,7 @@
<artifactId>adapters</artifactId>
<version>1.6.0-SNAPSHOT</version>
</parent>
- <groupId>org.onap.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-nssmf-adapter</artifactId>
<packaging>jar</packaging>
<name>mso-nssmf-adapter</name>
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
index 71026f1fa6..b121083954 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
@@ -214,7 +214,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor {
requestBody.replaceAll("\\s+", "")
String basicAuthValue = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
- HttpClient httpClient = new HttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO)
+ HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO)
httpClient.addAdditionalHeader("Authorization", basicAuthValue)
httpClient.addAdditionalHeader("Accept", "application/json")
Response httpResponse = httpClient.delete(requestBody)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy
index 29a976a72c..8c08e51efe 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy
@@ -25,14 +25,18 @@ import org.junit.Test
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito
+import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.entities.AAIResultWrapper
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import javax.ws.rs.NotFoundException
+import javax.ws.rs.core.Response
import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertNotNull
@@ -41,6 +45,9 @@ import static org.mockito.Mockito.*
class DeleteCommunicationServiceTest extends MsoGroovyTest {
+ private HttpClientFactory httpClientFactoryMock
+ private HttpClient httpClientMock
+
@Before
void init() throws IOException {
super.init("DeleteCommunicationServiceTest")
@@ -186,6 +193,47 @@ class DeleteCommunicationServiceTest extends MsoGroovyTest {
assertNotNull(updateOperationStatus)
}
+ @Test
+ void testSendRequest2NSMFWF(){
+ httpClientMock = mock(HttpClient.class)
+ httpClientFactoryMock = mock(HttpClientFactory.class)
+ String url ="http://so.onap:8080/onap/so/infra/e2eServiceInstances/v3/5G-777"
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0")
+ when(mockExecution.getVariable("progress")).thenReturn("20")
+ when(mockExecution.getVariable("operationContent")).thenReturn("waiting nsmf service delete finished")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://so.onap:8080/onap/so/infra")
+ when(mockExecution.getVariable("e2eSliceServiceInstanceId")).thenReturn("5G-777")
+ when(mockExecution.getVariable("e2eOperationId")).thenReturn("e151059a-d924-4629-845f-264db19e50b3")
+ when(httpClientFactoryMock.newJsonClient(new URL(url), ONAPComponents.SO)).thenReturn(httpClientMock)
+ DeleteCommunicationService obj = spy(DeleteCommunicationService.class)
+
+ Response responseMock = mock(Response.class)
+ when(responseMock.getStatus()).thenReturn(200)
+ when(responseMock.hasEntity()).thenReturn(true)
+ when(responseMock.getEntity()).thenReturn(getNSSMFResponse())
+ when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock)
+ when(httpClientMock.delete(anyString())).thenReturn(responseMock)
+
+ obj.sendRequest2NSMFWF(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String updateOperationStatus= captor.getValue()
+ assertNotNull(updateOperationStatus)
+ }
+
+ private String getNSSMFResponse(){
+ String response = """{
+ "service":{
+ "serviceId":"e151059a-d924-4629-845f-264db19e50b4",
+ "operationId":"e151059a-d924-4629-845f-264db19e50b3"
+ }
+ }"""
+ return response
+ }
+
+
+
private String mockQueryCommunicationServiceReturn()
{
@@ -257,8 +305,4 @@ class DeleteCommunicationServiceTest extends MsoGroovyTest {
}"""
return expect
}
-
-
-
-
}