diff options
author | BOSLET, CORY <cory.boslet@att.com> | 2021-03-10 17:22:28 -0500 |
---|---|---|
committer | AT&T Open Source <g22940@att.com> | 2021-03-10 17:22:29 -0500 |
commit | 39761146b77f58973612f8fdee3de9f987278edf (patch) | |
tree | ab96535b565898abf67e765b0141fb02fc0c6641 /adapters/mso-sdnc-adapter/src/test/java | |
parent | 1d316a3c50f978313eca360c1a1636de68afee9d (diff) |
add new sdnc interaction
Added Cors auth support option for sdnc interaction
Issue-ID: SO-3580
Signed-off-by: AT&T Open Source <g22940@att.com>
Change-Id: I54d17ea5e02a20114f5857940cc4dabc72854dea
Diffstat (limited to 'adapters/mso-sdnc-adapter/src/test/java')
-rw-r--r-- | adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/tasks/SDNCServiceTest.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/tasks/SDNCServiceTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/tasks/SDNCServiceTest.java new file mode 100644 index 0000000000..386d83f87d --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/tasks/SDNCServiceTest.java @@ -0,0 +1,72 @@ +package org.onap.so.adapters.sdnc.tasks; + +import java.io.IOException; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.GeneralSecurityException; +import java.util.HashMap; +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +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.so.logging.tasks.AuditMDCSetup; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +@RunWith(MockitoJUnitRunner.class) +public class SDNCServiceTest { + + private String RESOURCE_PATH = "src/test/resources"; + + @Mock + private ExternalTask mockExternalTask; + + @Mock + private ExternalTaskService mockExternalTaskService; + + @Mock + private AuditMDCSetup mdcSetup; + + @Mock + private RestTemplate restTemplate; + + @Mock + private ResponseEntity<Object> response; + + @Mock + private Environment env; + + @Spy + @InjectMocks + private SDNCService sdncService; + + @Test + public void testExecutePostTask() throws IOException, GeneralSecurityException { + String payload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/sdncRequest.json"))); + + Mockito.when(env.getProperty("org.onap.so.adapters.sdnc.sdncHost")).thenReturn("sdncHost"); + Mockito.when(mockExternalTask.getVariable("sdncRequest")).thenReturn(payload); + Mockito.when(mockExternalTask.getVariable("sdncUri")).thenReturn("/sdnc/action"); + Mockito.doReturn("Basic 123").when(sdncService).getAuth(); + Mockito.when(restTemplate.exchange(Mockito.any(URI.class), Mockito.eq(HttpMethod.POST), + Mockito.any(HttpEntity.class), Mockito.eq(Object.class))).thenReturn(response); + Mockito.when(response.getStatusCode()).thenReturn(HttpStatus.ACCEPTED); + Mockito.doNothing().when(mockExternalTaskService).complete(Mockito.any(), Mockito.any()); + + sdncService.executePostTask(mockExternalTask, mockExternalTaskService); + + Mockito.verify(mockExternalTaskService).complete(Mockito.eq(mockExternalTask), Mockito.eq(new HashMap<>())); + + } + +} |