modify unique bug
[holmes/common.git] / holmes-actions / src / test / java / org / onap / holmes / common / dmaap / DmaapServiceTest.java
index 72a0bc8..3f61813 100644 (file)
@@ -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));