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;
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;
@Rule
public ExpectedException thrown = ExpectedException.none();
- private Publisher publisher;
-
private AaiQuery aaiQuery;
+ private DmaapService dmaapService;
+
@Before
public void setUp() {
- publisher = PowerMock.createMock(Publisher.class);
- Whitebox.setInternalState(DmaapService.class, "publisher", publisher);
+ dmaapService = new DmaapService();
aaiQuery = PowerMock.createMock(AaiQuery.class);
- Whitebox.setInternalState(DmaapService.class, "aaiQuery", aaiQuery);
- PowerMock.replayAll();
- }
-
- @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.class, "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.class, "publishPolicyMsg", policyMsg);
- PowerMock.verifyAll();
+ Whitebox.setInternalState(dmaapService, "aaiQuery", aaiQuery);
}
@Test
PowerMock.replayAll();
PolicyMsg policyMsg = Whitebox
- .invokeMethod(DmaapService.class, "getDefaultPolicyMsg", "tetss");
+ .invokeMethod(dmaapService, "getDefaultPolicyMsg", "tetss");
PowerMock.verifyAll();
assertThat(policyMsg.getTarget(), equalTo("vserver.vserver-name"));
anyObject(String.class)).andReturn(expect).anyTimes();
PowerMock.replayAll();
VnfEntity actual = Whitebox
- .invokeMethod(DmaapService.class, "getVnfEntity", "tset", "test");
+ .invokeMethod(dmaapService, "getVnfEntity", "tset", "test");
PowerMock.verifyAll();
assertThat(actual.getVnfName(), equalTo("test"));
PowerMock.expectPrivate(aaiQuery, "getAaiVnfData", anyObject(String.class),
anyObject(String.class)).andThrow(new CorrelationException("")).anyTimes();
PowerMock.replayAll();
- VnfEntity actual = Whitebox.invokeMethod(DmaapService.class, "getVnfEntity", "tset", "test");
+ VnfEntity actual = Whitebox.invokeMethod(dmaapService, "getVnfEntity", "tset", "test");
PowerMock.verifyAll();
assertThat(actual == null, equalTo(true));
anyObject(String.class)).andReturn(expect).anyTimes();
PowerMock.replayAll();
VmEntity actual = Whitebox
- .invokeMethod(DmaapService.class, "getVmEntity", "tset", "test");
+ .invokeMethod(dmaapService, "getVmEntity", "tset", "test");
PowerMock.verifyAll();
assertThat(actual.getVserverId(), equalTo("11111"));
PowerMock.expectPrivate(aaiQuery, "getAaiVmData", anyObject(String.class),
anyObject(String.class)).andThrow(new CorrelationException("")).anyTimes();
PowerMock.replayAll();
- VnfEntity actual = Whitebox.invokeMethod(DmaapService.class, "getVmEntity", "tset", "test");
+ VnfEntity actual = Whitebox.invokeMethod(dmaapService, "getVmEntity", "tset", "test");
PowerMock.verifyAll();
assertThat(actual == null, equalTo(true));
vnfEntity.getRelationshipList().setRelationships(relationships);
PowerMock.replayAll();
- String actual = Whitebox.invokeMethod(DmaapService.class, "getVserverInstanceId", vnfEntity);
+ String actual = Whitebox.invokeMethod(dmaapService, "getVserverInstanceId", vnfEntity);
PowerMock.verifyAll();
assertThat(actual, equalTo("USUCP0PCOIL0110UJZZ01"));
VnfEntity vnfEntity = null;
PowerMock.replayAll();
- String actual = Whitebox.invokeMethod(DmaapService.class, "getVserverInstanceId", vnfEntity);
+ String actual = Whitebox.invokeMethod(dmaapService, "getVserverInstanceId", vnfEntity);
PowerMock.verifyAll();
assertThat(actual, equalTo(""));
VesAlarm vesAlarm = new VesAlarm();
vesAlarm.setEventId("11111");
vesAlarm.setEventName("3333");
+ vesAlarm.setSourceId("111");
- PowerMock.expectPrivate(DmaapService.class, "getVnfEntity", anyObject(String.class),
+ PowerMock.expectPrivate(dmaapService, "getVnfEntity", anyObject(String.class),
anyObject(String.class)).andReturn(null).anyTimes();
PowerMock.replayAll();
PolicyMsg actual = Whitebox
- .invokeMethod(DmaapService.class, "getEnrichedPolicyMsg", vmEntity, vesAlarm);
+ .invokeMethod(dmaapService, "getEnrichedPolicyMsg", vmEntity, vesAlarm, vesAlarm, "loopName");
PowerMock.verifyAll();
- assertThat(actual.getPolicyName(), equalTo("vLoadBalancer"));
+ assertThat(actual.getClosedLoopControlName(), equalTo(null));
assertThat(actual.getAai().get("vserver.prov-status"), equalTo("prov"));
assertThat(actual.getAai().get("vserver.vserver-name2") == null, equalTo(true));
assertThat(actual.getAai().get("generic-vnf.service-instance-id"), equalTo(""));