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=76c4a45530daeb3f74a49823127e5688f09fff39;hb=490fc3c1fafe50d5fb0e23db5cfd10730be96866;hp=6494cd87ea7f0715191587da48c472d58109d9cc;hpb=81edfdbaffd9c450f37d2418bb444473ee3bbe77;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 6494cd8..76c4a45 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 @@ -1,5 +1,5 @@ /** - * Copyright 2017 ZTE Corporation. + * Copyright 2017-2020 ZTE Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,20 +15,6 @@ */ package org.onap.holmes.common.dmaap; -import static org.easymock.EasyMock.anyObject; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import java.io.*; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - import org.easymock.EasyMock; import org.junit.Before; import org.junit.Rule; @@ -45,12 +31,26 @@ import org.onap.holmes.common.dcae.DcaeConfigurationsCache; import org.onap.holmes.common.dcae.utils.DcaeConfigurationParser; import org.onap.holmes.common.dmaap.entity.PolicyMsg; import org.onap.holmes.common.dmaap.entity.PolicyMsg.EVENT_STATUS; +import org.onap.holmes.common.dmaap.store.ClosedLoopControlNameCache; +import org.onap.holmes.common.dmaap.store.UniqueRequestIdCache; import org.onap.holmes.common.exception.CorrelationException; import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; +import java.io.*; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import static org.easymock.EasyMock.anyObject; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + @PrepareForTest({DmaapService.class, Publisher.class, AaiQuery.class}) @RunWith(PowerMockRunner.class) public class DmaapServiceTest { @@ -62,17 +62,24 @@ public class DmaapServiceTest { private DmaapService dmaapService; + private ClosedLoopControlNameCache closedLoopControlNameCache = new ClosedLoopControlNameCache(); + + private UniqueRequestIdCache uniqueRequestIdCache = new UniqueRequestIdCache(); + @Before public void setUp() { - dmaapService = new DmaapService(); aaiQuery = PowerMock.createMock(AaiQuery.class); - Whitebox.setInternalState(dmaapService, "aaiQuery", aaiQuery); + + dmaapService = new DmaapService(); + dmaapService.setClosedLoopControlNameCache(closedLoopControlNameCache); + dmaapService.setUniqueRequestIdCache(uniqueRequestIdCache); + dmaapService.setAaiQuery(aaiQuery); } @Test public void testDmaapService_getDefaultPolicyMsg_ok() throws Exception { String packageName = "org.onap.holmes.rule"; - DmaapService.loopControlNames.put(packageName, "Control-loop-VoLTE"); + closedLoopControlNameCache.put(packageName, "Control-loop-VoLTE"); long startTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis() + 1000000; VesAlarm vesAlarm = new VesAlarm(); @@ -274,7 +281,7 @@ public class DmaapServiceTest { PolicyMsg policyMsg = new PolicyMsg(); policyMsg.setClosedLoopEventStatus(EVENT_STATUS.ABATED); policyMsg.setRequestID("testRequestid"); - DmaapService.alarmUniqueRequestID.put("testAlarmId", "testRequestid"); + uniqueRequestIdCache.put("testAlarmId", "testRequestid"); PowerMock.expectNew(Publisher.class).andReturn(publisher); EasyMock.expect(publisher.publish(policyMsg)).andReturn(true);