summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/dcae/common/EventProcessorTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/onap/dcae/common/EventProcessorTest.java')
-rw-r--r--src/test/java/org/onap/dcae/common/EventProcessorTest.java157
1 files changed, 83 insertions, 74 deletions
diff --git a/src/test/java/org/onap/dcae/common/EventProcessorTest.java b/src/test/java/org/onap/dcae/common/EventProcessorTest.java
index 04a2952..e86af85 100644
--- a/src/test/java/org/onap/dcae/common/EventProcessorTest.java
+++ b/src/test/java/org/onap/dcae/common/EventProcessorTest.java
@@ -17,14 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcae.common;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.concurrent.LinkedBlockingQueue;
import org.json.JSONObject;
import org.junit.Before;
-
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -38,25 +42,9 @@ import org.onap.dcae.controller.AccessController;
import org.onap.dcae.controller.PersistentEventConnection;
import org.slf4j.LoggerFactory;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.concurrent.LinkedBlockingQueue;
-
-
-
-import static io.vavr.API.Map;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.when;
-import static org.onap.dcae.common.publishing.DMaaPConfigurationParser.parseToDomainMapping;
-
@RunWith(MockitoJUnitRunner.Silent.class)
public class EventProcessorTest {
-
-
@Mock
private ApplicationSettings properties;
@@ -72,10 +60,13 @@ public class EventProcessorTest {
protected static final Path RCC_KEYSTORE_PASSWORD_FILE = Paths.get(RESOURCES.toString(), "rcc_passwordfile");
protected static final Path RCC_KEYSTORE = Paths.get(RESOURCES.toString(), "sdnc.p12");
+ /**
+ * set up before testcase.
+ */
@Before
public void setUp() {
- eventPublisher = EventPublisher.createPublisher(LoggerFactory.getLogger("some_log"), DMaaPConfigurationParser.
- parseToDomainMapping(path).get());
+ eventPublisher = EventPublisher.createPublisher(LoggerFactory.getLogger("some_log"),
+ DMaaPConfigurationParser.parseToDomainMapping(path).get());
streamMap = RestConfCollector.parseStreamIdToStreamHashMapping("notification=device-registration");
}
@@ -83,59 +74,77 @@ public class EventProcessorTest {
@Test
public void testEventProcessorRunException() {
try {
- when(properties.truststoreFileLocation()).thenReturn(TRUSTSTORE.toString());
-
- when(properties.truststorePasswordFileLocation()).thenReturn(TRUSTSTORE_PASSWORD_FILE.toString());
- when(properties.keystoreFileLocation()).thenReturn(KEYSTORE.toString());
- when(properties.keystorePasswordFileLocation()).thenReturn(KEYSTORE_PASSWORD_FILE.toString());
- when(properties.rccKeystoreFileLocation()).thenReturn(RCC_KEYSTORE.toString());
- when(properties.rccKeystorePasswordFileLocation()).thenReturn(RCC_KEYSTORE_PASSWORD_FILE.toString());
- when(properties.controllerConfigFileLocation()).thenReturn(Paths.get("etc/ont_config.json").toAbsolutePath().toString());
-
- RestapiCallNode restApiCallNode = Mockito.mock(RestapiCallNode.class);
- Mockito.doNothing().when(restApiCallNode).sendRequest(any(), any(), any());
-
-
- JSONObject controller = new JSONObject(
- "{\"controller_name\":\"AccessM&C\",\"controller_restapiUrl\":\"10.118.191.43:26335\",\"controller_restapiUser\":\"access\",\"controller_restapiPassword\":\"Huawei@123\",\"controller_accessTokenUrl\":\"/rest/plat/smapp/v1/oauth/token\",\"controller_accessTokenFile\":\"./etc/access-token.json\",\"controller_accessTokenMethod\":\"put\",\"controller_subsMethod\":\"post\",\"controller_subscriptionUrl\":\"/restconf/v1/operations/huawei-nce-notification-action:establish-subscription\",\"controller_disableSsl\":\"true\",\"event_details\":[{\"event_name\":\"ONT_registration\",\"event_description\":\"ONTregistartionevent\",\"event_sseventUrlEmbed\":\"true\",\"event_sseventsField\":\"output.url\",\"event_sseventsUrl\":\"null\",\"event_subscriptionTemplate\":\"./etc/ont_registartion_subscription_template.json\",\"event_unSubscriptionTemplate\":\"./etc/ont_registartion_unsubscription_template.json\",\"event_ruleId\":\"777777777\"}]}");
- AccessController acClr = new AccessController(controller, properties);
-
- PersistentEventConnection p = new PersistentEventConnection.PersistentEventConnectionBuilder().setEventName("")
- .setEventDescription("").setEventSseventUrlEmbed(true).setEventSseventsField("").setEventSseventsUrl("")
- .setEventSubscriptionTemplate("").setEventUnSubscriptionTemplate("").setEventRuleId("1234646346")
- .setParentCtrllr(acClr).setModifyEvent(true).setModifyMethod("modifyOntEvent")
- .setUserData("remote_id=AC9.0234.0337;svlan=1001;macAddress=00:11:22:33:44:55;")
- .createPersistentEventConnection();
- p.getEventParamMapValue("restapiUrl");
- p.modifyEventParamMap("restapiUrl", "10.118.191.43:26335");
- RestConfCollector.fProcessingInputQueue = new LinkedBlockingQueue<>(4);
- p.getParentCtrllr().setRestApiCallNode(restApiCallNode);
- RestConfCollector.fProcessingInputQueue.offer(new EventData(p, new JSONObject("{\n" +
- " \"notification\" : {\n" +
- " \"notification-id\" : \"01010101011\",\n" +
- " \"event-time\" : \"2019-3-9T3:30:30.547z\",\n" +
- " \"message\" : {\n" +
- " \"object-type\" : \"onu\",\n" +
- " \"topic\" : \"resources\",\n" +
- " \"version\" : \"v1\",\n" +
- " \"operation\" : \"create\",\n" +
- " \"content\" : {\n" +
- " \"onu\" : {\n" +
- " \"alias\" : \"\",\n" +
- " \"refParentLTP\" : \"gpon.0.5.1\",\n" +
- " \"sn\" : \"HWTCC01B7503\",\n" +
- " \"refParentLTPNativeId\" : \"NE=167772165,FR=0,S=5,CP=-1,PP=||1|\",\n" +
- " \"onuId\": \"\",\n" +
- " \"refParentNE\" : \"aaaaaaaaa-aaaaa-aaaa-aaaa-aaa167772165\",\n" +
- " \"refParentNeNativeId\": \"NE=167772165\"\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}")));
- RestConfCollector.fProcessingInputQueue.offer(new EventData(null, null));
- EventProcessor ev = new EventProcessor(eventPublisher, streamMap);
- ev.run();
- } catch (Exception e){}
+ when(properties.truststoreFileLocation()).thenReturn(TRUSTSTORE.toString());
+ when(properties.truststorePasswordFileLocation()).thenReturn(TRUSTSTORE_PASSWORD_FILE.toString());
+ when(properties.keystoreFileLocation()).thenReturn(KEYSTORE.toString());
+ when(properties.keystorePasswordFileLocation()).thenReturn(KEYSTORE_PASSWORD_FILE.toString());
+ when(properties.rccKeystoreFileLocation()).thenReturn(RCC_KEYSTORE.toString());
+ when(properties.rccKeystorePasswordFileLocation()).thenReturn(RCC_KEYSTORE_PASSWORD_FILE.toString());
+ when(properties.controllerConfigFileLocation())
+ .thenReturn(Paths.get("etc/ont_config.json").toAbsolutePath().toString());
+
+ RestapiCallNode restApiCallNode = Mockito.mock(RestapiCallNode.class);
+ Mockito.doNothing().when(restApiCallNode).sendRequest(any(), any(), any());
+
+
+ JSONObject controller = new JSONObject(
+ "{\"controller_name\":\"AccessM&C\",\"controller_restapiUrl\":\"10.118.191.43:26335\","
+ + "\"controller_restapiUser\":\"access\",\"controller_restapiPassword\":\"Huawei@123\","
+ + "\"controller_accessTokenUrl\":\"/rest/plat/smapp/v1/oauth/token\","
+ + "\"controller_accessTokenFile\":\"./etc/access-token.json\","
+ + "\"controller_accessTokenMethod\":\"put\",\"controller_subsMethod\":\"post\","
+ + "\"controller_subscriptionUrl\":"
+ + "\"/restconf/v1/operations/huawei-nce-notification-action:establish-subscription\","
+ + "\"controller_disableSsl\":\"true\",\"event_details\":[{\"event_name\":"
+ + "\"ONT_registration\",\"event_description\":\"ONTregistartionevent\","
+ + "\"event_sseventUrlEmbed\":\"true\",\"event_sseventsField\":\"output.url\","
+ + "\"event_sseventsUrl\":\"null\","
+ + "\"event_subscriptionTemplate\":\"./etc/ont_registartion_subscription_template.json\","
+ + "\"event_unSubscriptionTemplate\":"
+ + "\"./etc/ont_registartion_unsubscription_template.json\","
+ + "\"event_ruleId\":\"777777777\"}]}");
+ AccessController acClr = new AccessController(controller, properties);
+
+ PersistentEventConnection eventConnection = new PersistentEventConnection.PersistentEventConnectionBuilder()
+ .setEventName("")
+ .setEventDescription("").setEventSseventUrlEmbed(true).setEventSseventsField("")
+ .setEventSseventsUrl("")
+ .setEventSubscriptionTemplate("").setEventUnSubscriptionTemplate("").setEventRuleId("1234646346")
+ .setParentCtrllr(acClr).setModifyEvent(true).setModifyMethod("modifyOntEvent")
+ .setUserData("remote_id=AC9.0234.0337;svlan=1001;macAddress=00:11:22:33:44:55;")
+ .createPersistentEventConnection();
+ eventConnection.getEventParamMapValue("restapiUrl");
+ eventConnection.modifyEventParamMap("restapiUrl", "10.118.191.43:26335");
+ RestConfCollector.fProcessingInputQueue = new LinkedBlockingQueue<>(4);
+ eventConnection.getParentCtrllr().setRestApiCallNode(restApiCallNode);
+ RestConfCollector.fProcessingInputQueue.offer(new EventData(eventConnection, new JSONObject("{\n"
+ + " \"notification\" : {\n"
+ + " \"notification-id\" : \"01010101011\",\n"
+ + " \"event-time\" : \"2019-3-9T3:30:30.547z\",\n"
+ + " \"message\" : {\n"
+ + " \"object-type\" : \"onu\",\n"
+ + " \"topic\" : \"resources\",\n"
+ + " \"version\" : \"v1\",\n"
+ + " \"operation\" : \"create\",\n"
+ + " \"content\" : {\n"
+ + " \"onu\" : {\n"
+ + " \"alias\" : \"\",\n"
+ + " \"refParentLTP\" : \"gpon.0.5.1\",\n"
+ + " \"sn\" : \"HWTCC01B7503\",\n"
+ + " \"refParentLTPNativeId\" : \"NE=167772165,FR=0,S=5,CP=-1,PP=||1|\",\n"
+ + " \"onuId\": \"\",\n"
+ + " \"refParentNE\" : \"aaaaaaaaa-aaaaa-aaaa-aaaa-aaa167772165\",\n"
+ + " \"refParentNeNativeId\": \"NE=167772165\"\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + "}")));
+ RestConfCollector.fProcessingInputQueue.offer(new EventData(null, null));
+ EventProcessor ev = new EventProcessor(eventPublisher, streamMap);
+ ev.run();
+ } catch (Exception e) {
+ System.out.println("Exception " + e);
+ }
}
} \ No newline at end of file