diff options
author | Steve Smokowski <ss835w@att.com> | 2019-02-21 13:27:29 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-02-21 13:27:29 +0000 |
commit | b506a30ff5cf93a294995982ace7e1326764a713 (patch) | |
tree | 759dea2782a068f5e564fc3e0ff345ec300f7838 /bpmn | |
parent | c0c6449fef2aed05eda93b462bf9b8939151b9aa (diff) | |
parent | 7d0cd88c036612ff60d845d4561749cb9020f9d8 (diff) |
Merge "Updated as per review comments"
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()); } } |