diff options
author | Prema Bhatt <pb6115@att.com> | 2019-02-20 16:50:10 -0800 |
---|---|---|
committer | Prema Bhatt <pb6115@att.com> | 2019-02-20 16:50:10 -0800 |
commit | 7d0cd88c036612ff60d845d4561749cb9020f9d8 (patch) | |
tree | e09908cfd1fd3c00e9f75b9b4f1eb0d3f8febcb1 /bpmn | |
parent | ac892330d55c6a33f376f217fa6ec4464e361b02 (diff) |
Updated as per review comments
This git review replaces https://gerrit.onap.org/r/#/c/78430/. As I had
some issues updating the existing git review, I'm creating a new one.
Issue-ID: SO-1391
Change-Id: Ida3f94ad7e2249a30a99d67a071930323ba743b5
Signed-off-by: Prema Bhatt <pb6115@att.com>
Diffstat (limited to 'bpmn')
2 files changed, 37 insertions, 16 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java index c50a6db178..886025cb51 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java @@ -20,27 +20,30 @@ package org.onap.so.client.dmaapproperties; -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.urlEqualTo; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import java.io.File; import java.io.IOException; -import org.apache.http.HttpStatus; +import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.so.BaseTest; import org.onap.so.client.avpn.dmaap.beans.AVPNDmaapBean; import org.onap.so.client.exception.MapperException; -import org.onap.so.BaseTest; +import org.onap.so.client.dmaapproperties.GlobalDmaapPublisher; import org.springframework.beans.factory.annotation.Autowired; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import static com.github.tomakehurst.wiremock.client.WireMock.*; public class DmaapPropertiesClientTest extends BaseTest{ @@ -75,10 +78,24 @@ public class DmaapPropertiesClientTest extends BaseTest{ @Test public void testDmaapPublishRequest() throws JsonProcessingException, MapperException { - stubFor(post(urlEqualTo("/events/com.att.mso.asyncStatusUpdate?timeout=60000")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED))); - - dmaapPropertiesClient.dmaapPublishRequest(requestId, clientSource, correlator, serviceInstanceId, startTime, finishTime, requestScope, - requestType, timestamp, requestState, statusMessage, percentProgress, false); + DmaapPropertiesClient client = Mockito.spy(DmaapPropertiesClient.class); + GlobalDmaapPublisher mockedClientDmaapPublisher = Mockito.mock(GlobalDmaapPublisher.class); + AVPNDmaapBean mockedDmaapBean = Mockito.mock(AVPNDmaapBean.class); + String request = "test"; + + doReturn(mockedDmaapBean).when(client).buildRequestJson(requestId, clientSource, correlator, serviceInstanceId, startTime, finishTime, requestScope, + requestType, timestamp, requestState, statusMessage, percentProgress, false); + + AVPNDmaapBean actualDmaapBean = client.buildRequestJson(requestId, clientSource, correlator, serviceInstanceId, startTime, finishTime, requestScope, + requestType, timestamp, requestState, statusMessage, percentProgress, false); + mockedClientDmaapPublisher.send(request); + + doNothing().when(mockedClientDmaapPublisher).send(anyString()); + + verify(client, times(1)).buildRequestJson(requestId, clientSource, correlator, serviceInstanceId, startTime, + finishTime, requestScope, requestType, timestamp, requestState, statusMessage, percentProgress, false); + verify(mockedClientDmaapPublisher, times(1)).send(request); + + assertNotNull(actualDmaapBean); } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java index fc69f812be..088b01873c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java @@ -21,23 +21,27 @@ package org.onap.so.client.dmaapproperties; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.BeforeClass; import org.junit.Test; import org.onap.so.BaseTest; import org.springframework.beans.factory.annotation.Autowired; public class GlobalDmaapPublisherTest extends BaseTest{ + @BeforeClass + public static void setUp() throws Exception { + System.setProperty("mso.global.dmaap.host", "http://test:1234"); + } + @Autowired private GlobalDmaapPublisher globalDmaapPublisher; - - + @Test public void testGetters() { assertEquals("81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54", globalDmaapPublisher.getAuth()); assertEquals("07a7159d3bf51a0e53be7a8f89699be7", globalDmaapPublisher.getKey()); assertEquals("com.att.mso.asyncStatusUpdate", globalDmaapPublisher.getTopic()); - assertEquals("http://localhost:" + wireMockPort, globalDmaapPublisher.getHost().get()); + assertEquals("http://test:1234", globalDmaapPublisher.getHost().get()); } } |