X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=holmes-actions%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fholmes%2Fcommon%2Fdmaap%2FDmaapServiceTest.java;h=3f6181377614f41269fa16987d6912f9675f3958;hb=ece7abcfdf6d68a8f41732883435822ceb745c11;hp=72a0bc8892b164e5355b4645b16e3ca903c3aac3;hpb=b4e2bd572489d6fce49571b4c3e681d267ffcc57;p=holmes%2Fcommon.git diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/dmaap/DmaapServiceTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/dmaap/DmaapServiceTest.java index 72a0bc8..3f61813 100644 --- a/holmes-actions/src/test/java/org/onap/holmes/common/dmaap/DmaapServiceTest.java +++ b/holmes-actions/src/test/java/org/onap/holmes/common/dmaap/DmaapServiceTest.java @@ -21,7 +21,9 @@ import static org.junit.Assert.assertThat; import java.util.ArrayList; import java.util.List; +import org.easymock.EasyMock; import org.junit.runner.RunWith; +import org.omg.CORBA.Any; import org.onap.holmes.common.aai.AaiQuery; import org.onap.holmes.common.aai.entity.RelationshipList.Relationship; import org.onap.holmes.common.aai.entity.RelationshipList.RelationshipData; @@ -29,6 +31,7 @@ import org.onap.holmes.common.aai.entity.VmEntity; import org.onap.holmes.common.aai.entity.VnfEntity; import org.onap.holmes.common.api.stat.VesAlarm; import org.onap.holmes.common.exception.CorrelationException; +import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.junit.Before; @@ -47,8 +50,6 @@ public class DmaapServiceTest { @Rule public ExpectedException thrown = ExpectedException.none(); - private Publisher publisher; - private AaiQuery aaiQuery; private DmaapService dmaapService; @@ -56,34 +57,10 @@ public class DmaapServiceTest { @Before public void setUp() { dmaapService = new DmaapService(); - publisher = PowerMock.createMock(Publisher.class); - Whitebox.setInternalState(dmaapService, "publisher", publisher); aaiQuery = PowerMock.createMock(AaiQuery.class); Whitebox.setInternalState(dmaapService, "aaiQuery", aaiQuery); } - @Test - public void testDmaapService_publish_ok() throws Exception { - PowerMock.resetAll(); - PolicyMsg policyMsg = new PolicyMsg(); - PowerMock.expectPrivate(publisher, "publish", anyObject(PolicyMsg.class)).andReturn(true) - .anyTimes(); - PowerMock.replayAll(); - Whitebox.invokeMethod(dmaapService, "publishPolicyMsg", policyMsg); - PowerMock.verifyAll(); - } - - @Test - public void testDmaapService_publish_exception() throws Exception { - PowerMock.resetAll(); - final PolicyMsg policyMsg = new PolicyMsg(); - PowerMock.expectPrivate(publisher, "publish", policyMsg) - .andThrow(new CorrelationException("")).anyTimes(); - PowerMock.replayAll(); - Whitebox.invokeMethod(dmaapService, "publishPolicyMsg", policyMsg); - PowerMock.verifyAll(); - } - @Test public void testDmaapService_getDefaultPolicyMsg_ok() throws Exception { PowerMock.resetAll(); @@ -201,13 +178,14 @@ public class DmaapServiceTest { VesAlarm vesAlarm = new VesAlarm(); vesAlarm.setEventId("11111"); vesAlarm.setEventName("3333"); + vesAlarm.setSourceId("111"); PowerMock.expectPrivate(dmaapService, "getVnfEntity", anyObject(String.class), anyObject(String.class)).andReturn(null).anyTimes(); PowerMock.replayAll(); PolicyMsg actual = Whitebox - .invokeMethod(dmaapService, "getEnrichedPolicyMsg", vmEntity, vesAlarm, "loopName"); + .invokeMethod(dmaapService, "getEnrichedPolicyMsg", vmEntity, vesAlarm, vesAlarm, "loopName"); PowerMock.verifyAll(); assertThat(actual.getClosedLoopControlName(), equalTo(null));