aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/pnfsimulator/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocks/pnfsimulator/src')
-rw-r--r--test/mocks/pnfsimulator/src/assembly/resources.xml82
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java49
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MDCVariables.java35
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java85
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageBuilder.java81
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java81
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java42
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfConfigurationCheckingTask.java61
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorService.java73
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceConfiguration.java112
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationCache.java34
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationReader.java40
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationWriter.java51
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConnectionParams.java45
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/SimulatorController.java211
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/DateUtil.java35
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/ResponseBuilder.java62
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/Simulator.java151
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java83
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapter.java26
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImpl.java89
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/JSONValidator.java66
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ValidationException.java28
-rw-r--r--test/mocks/pnfsimulator/src/main/resources/application.properties1
-rw-r--r--test/mocks/pnfsimulator/src/main/resources/logback.xml50
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/JSONObjectFactoryTest.java73
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java120
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfConfigurationCheckingTaskTest.java94
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceConfigurationTest.java72
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceTest.java73
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationCacheTest.java38
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationReaderTest.java70
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationWriterTest.java67
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/SimulatorControllerTest.java173
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/DateUtilTest.java38
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/ResponseBuilderTest.java65
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/ResourceReader.java45
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/SimulatorFactoryTest.java91
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/SimulatorTest.java92
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImplTest.java71
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/validation/JSONValidatorTest.java123
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/invalid-test-schema.json19
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/logback-test.xml49
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/message/MessageProviderTest/notificationParams.json6
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/message/MessageProviderTest/pnfRegistrationParams.json6
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/rest/SimulatorControllerTest/incorrectJson.json12
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/rest/SimulatorControllerTest/pnfRegistration.json24
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams1.json14
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams2.json15
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams3.json14
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidSimulatorParams.json4
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validCommonEventHeaderParams.json8
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validNotificationParams.json20
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validPnfRegistrationParams.json10
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validSimulatorParams.json5
-rw-r--r--test/mocks/pnfsimulator/src/test/resources/valid-test-schema.json19
56 files changed, 0 insertions, 3203 deletions
diff --git a/test/mocks/pnfsimulator/src/assembly/resources.xml b/test/mocks/pnfsimulator/src/assembly/resources.xml
deleted file mode 100644
index 470df7c46..000000000
--- a/test/mocks/pnfsimulator/src/assembly/resources.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<assembly>
- <id>resources</id>
- <formats>
- <format>zip</format>
- </formats>
-
- <fileSets>
- <fileSet>
- <includes>
- <include>simulator.sh</include>
- </includes>
- <lineEnding>unix</lineEnding>
- <fileMode>0755</fileMode>
- </fileSet>
- <fileSet>
- <includes>
- <include>docker-compose.yml</include>
- </includes>
- <lineEnding>unix</lineEnding>
- <fileMode>0644</fileMode>
- </fileSet>
- <fileSet>
- <directory>config</directory>
- <outputDirectory>config</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>deployment</directory>
- <outputDirectory>deployment</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>ftpes</directory>
- <outputDirectory>ftpes</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
- <fileMode>0644</fileMode>
-
- </fileSet>
- <fileSet>
- <directory>json_schema</directory>
- <outputDirectory>json_schema</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>netconf</directory>
- <outputDirectory>netconf</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>netopeer_tls_cfg</directory>
- <outputDirectory>netopeer_tls_cfg</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>sftp</directory>
- <outputDirectory>sftp</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>ssh</directory>
- <outputDirectory>ssh</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
-
- </fileSet>
- </fileSets>
-</assembly> \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java
deleted file mode 100644
index 244eef6bd..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator;
-
-import org.onap.pnfsimulator.message.MessageProvider;
-import org.onap.pnfsimulator.simulator.validation.JSONValidator;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-import org.springframework.scheduling.annotation.EnableAsync;
-
-@SpringBootApplication
-@EnableAsync
-public class Main {
-
- public static void main(String[] args) {
- SpringApplication.run(Main.class, args);
- }
-
- @Bean
- public MessageProvider messageProvider() {
- return new MessageProvider();
- }
-
- @Bean
- public JSONValidator jsonValidator() {
- return new JSONValidator();
- }
-}
-
-
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MDCVariables.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MDCVariables.java
deleted file mode 100644
index 8f6fe3b66..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MDCVariables.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.logging;
-
-public final class MDCVariables {
-
- public static final String X_ONAP_REQUEST_ID = "X-ONAP-RequestID";
- public static final String X_INVOCATION_ID = "X-InvocationID";
- public static final String REQUEST_ID = "RequestID";
- public static final String INVOCATION_ID = "InvocationID";
- public static final String INSTANCE_UUID = "InstanceUUID";
- public static final String RESPONSE_CODE = "ResponseCode";
- public static final String SERVICE_NAME = "ServiceName";
-
- private MDCVariables() {
- }
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
deleted file mode 100644
index 3ebf5674a..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.message;
-
-import static org.onap.pnfsimulator.message.MessageConstants.EVENT_ID;
-import static org.onap.pnfsimulator.message.MessageConstants.INTERNAL_HEADER_FIELDS;
-import static org.onap.pnfsimulator.message.MessageConstants.LAST_EPOCH_MICROSEC;
-import static org.onap.pnfsimulator.message.MessageConstants.NOTIFICATION_FIELDS_VERSION;
-import static org.onap.pnfsimulator.message.MessageConstants.NOTIFICATION_FIELDS_VERSION_VALUE;
-import static org.onap.pnfsimulator.message.MessageConstants.PNF_LAST_SERVICE_DATE;
-import static org.onap.pnfsimulator.message.MessageConstants.PNF_MANUFACTURE_DATE;
-import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FIELDS_VERSION;
-import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FIELDS_VERSION_VALUE;
-import static org.onap.pnfsimulator.message.MessageConstants.PRIORITY;
-import static org.onap.pnfsimulator.message.MessageConstants.PRIORITY_NORMAL;
-import static org.onap.pnfsimulator.message.MessageConstants.SEQUENCE;
-import static org.onap.pnfsimulator.message.MessageConstants.SEQUENCE_NUMBER;
-import static org.onap.pnfsimulator.message.MessageConstants.START_EPOCH_MICROSEC;
-import static org.onap.pnfsimulator.message.MessageConstants.VERSION;
-import static org.onap.pnfsimulator.message.MessageConstants.VERSION_NUMBER;
-import static org.onap.pnfsimulator.message.MessageConstants.VES_EVENT_LISTENER_VERSION;
-import static org.onap.pnfsimulator.message.MessageConstants.VES_EVENT_LISTENER_VERSION_NUMBER;
-
-import org.json.JSONObject;
-
-final class JSONObjectFactory {
-
- static JSONObject generateConstantCommonEventHeader() {
- JSONObject commonEventHeader = new JSONObject();
- long timestamp = System.currentTimeMillis();
- commonEventHeader.put(EVENT_ID, generateEventId());
- commonEventHeader.put(LAST_EPOCH_MICROSEC, timestamp);
- commonEventHeader.put(PRIORITY, PRIORITY_NORMAL);
- commonEventHeader.put(SEQUENCE, SEQUENCE_NUMBER);
- commonEventHeader.put(START_EPOCH_MICROSEC, timestamp);
- commonEventHeader.put(INTERNAL_HEADER_FIELDS, new JSONObject());
- commonEventHeader.put(VERSION, VERSION_NUMBER);
- commonEventHeader.put(VES_EVENT_LISTENER_VERSION, VES_EVENT_LISTENER_VERSION_NUMBER);
- return commonEventHeader;
- }
-
- static JSONObject generatePnfRegistrationFields() {
- JSONObject pnfRegistrationFields = new JSONObject();
- pnfRegistrationFields.put(PNF_REGISTRATION_FIELDS_VERSION, PNF_REGISTRATION_FIELDS_VERSION_VALUE);
- pnfRegistrationFields.put(PNF_LAST_SERVICE_DATE, String.valueOf(System.currentTimeMillis()));
- pnfRegistrationFields.put(PNF_MANUFACTURE_DATE, String.valueOf(System.currentTimeMillis()));
- return pnfRegistrationFields;
- }
-
- static JSONObject generateNotificationFields() {
- JSONObject notificationFields = new JSONObject();
- notificationFields.put(NOTIFICATION_FIELDS_VERSION, NOTIFICATION_FIELDS_VERSION_VALUE);
- return notificationFields;
- }
-
-
- static String generateEventId() {
- String timeAsString = String.valueOf(System.currentTimeMillis());
- return String.format("registration_%s",
- timeAsString.substring(timeAsString.length() - 11, timeAsString.length() - 3));
- }
-
- private JSONObjectFactory() {
-
- }
-
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageBuilder.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageBuilder.java
deleted file mode 100644
index ef0b2fdd2..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageBuilder.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.message;
-
-import org.json.JSONObject;
-
-import static org.onap.pnfsimulator.message.MessageConstants.COMMON_EVENT_HEADER;
-import static org.onap.pnfsimulator.message.MessageConstants.DOMAIN;
-import static org.onap.pnfsimulator.message.MessageConstants.DOMAIN_NOTIFICATION;
-import static org.onap.pnfsimulator.message.MessageConstants.DOMAIN_PNF_REGISTRATION;
-import static org.onap.pnfsimulator.message.MessageConstants.EVENT;
-import static org.onap.pnfsimulator.message.MessageConstants.EVENT_TYPE;
-import static org.onap.pnfsimulator.message.MessageConstants.NOTIFICATION_FIELDS;
-import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FIELDS;
-
-public final class MessageBuilder {
- private JSONObject root;
- private JSONObject event;
- private JSONObject commonEventHeader;
-
- private MessageBuilder() {
- }
-
- public static MessageBuilder withCommonEventHeaderParams(JSONObject commonEventHeaderParams) {
- MessageBuilder builder = new MessageBuilder();
- builder.initializeBuilder(commonEventHeaderParams);
- return builder;
- }
-
- public MessageBuilder withNotificationParams(JSONObject notificationParams) {
- JSONObject notificationFields = JSONObjectFactory.generateNotificationFields();
- merge(notificationParams, notificationFields);
- commonEventHeader.put(DOMAIN, DOMAIN_NOTIFICATION);
- event.put(NOTIFICATION_FIELDS, notificationFields);
- return this;
- }
-
- public MessageBuilder withPnfRegistrationParams(JSONObject pnfRegistrationParams) {
- JSONObject pnfRegistrationFields = JSONObjectFactory.generatePnfRegistrationFields();
- merge(pnfRegistrationParams, pnfRegistrationFields);
- commonEventHeader.put(DOMAIN, DOMAIN_PNF_REGISTRATION);
- commonEventHeader.put(EVENT_TYPE, DOMAIN_PNF_REGISTRATION);
- event.put(PNF_REGISTRATION_FIELDS, pnfRegistrationFields);
- return this;
- }
-
- public JSONObject build() {
- return root;
- }
-
- private void initializeBuilder(JSONObject commonEventHeaderParams) {
- root = new JSONObject();
- event = new JSONObject();
- commonEventHeader = JSONObjectFactory.generateConstantCommonEventHeader();
- commonEventHeaderParams.toMap().forEach(commonEventHeader::put);
- event.put(COMMON_EVENT_HEADER, commonEventHeader);
- root.put(EVENT, event);
- }
-
- private void merge(JSONObject source, JSONObject destination) {
- source.toMap().forEach(destination::put);
- }
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
deleted file mode 100644
index 95e8f69f3..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.message;
-
-public final class MessageConstants {
-
- public static final String SIMULATOR_PARAMS = "simulatorParams";
- public static final String COMMON_EVENT_HEADER_PARAMS = "commonEventHeaderParams";
- public static final String PNF_REGISTRATION_PARAMS = "pnfRegistrationParams";
- public static final String NOTIFICATION_PARAMS = "notificationParams";
-
- static final String COMMON_EVENT_HEADER = "commonEventHeader";
- static final String PNF_REGISTRATION_FIELDS = "pnfRegistrationFields";
- static final String NOTIFICATION_FIELDS = "notificationFields";
- static final String EVENT = "event";
-
- //=============================================================================================
- //Simulation parameters
- public static final String VES_SERVER_URL = "vesServerUrl";
- public static final String TEST_DURATION = "testDuration";
- public static final String MESSAGE_INTERVAL = "messageInterval";
-
- //=============================================================================================
- //commonEventHeader
- //parameters
- static final String DOMAIN = "domain";
- static final String EVENT_ID = "eventId";
- static final String EVENT_TYPE = "eventType";
- static final String LAST_EPOCH_MICROSEC = "lastEpochMicrosec";
- static final String PRIORITY = "priority";
- static final String SEQUENCE = "sequence";
- static final String START_EPOCH_MICROSEC = "startEpochMicrosec";
- static final String INTERNAL_HEADER_FIELDS = "internalHeaderFields";
- static final String VERSION = "version";
- static final String VES_EVENT_LISTENER_VERSION = "vesEventListenerVersion";
- //constant values
- static final int SEQUENCE_NUMBER = 0;
- static final String VERSION_NUMBER = "4.0.1";
- static final String VES_EVENT_LISTENER_VERSION_NUMBER = "7.0.1";
- static final String PRIORITY_NORMAL = "Normal";
-
- //=============================================================================================
- //PNF registration
- //parameters
- static final String PNF_REGISTRATION_FIELDS_VERSION = "pnfRegistrationFieldsVersion";
- static final String PNF_LAST_SERVICE_DATE = "lastServiceDate";
- static final String PNF_MANUFACTURE_DATE = "manufactureDate";
- //constant values
- static final String PNF_REGISTRATION_FIELDS_VERSION_VALUE = "2.0";
- static final String DOMAIN_PNF_REGISTRATION ="pnfRegistration";
-
- //=============================================================================================
- // Notifications
- //parameters
- static final String NOTIFICATION_FIELDS_VERSION = "notificationFieldsVersion";
- //constant values
- static final String NOTIFICATION_FIELDS_VERSION_VALUE = "2.0";
- static final String DOMAIN_NOTIFICATION ="notification";
-
- private MessageConstants() {
- }
-
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
deleted file mode 100644
index fee574597..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.message;
-
-import org.json.JSONObject;
-
-public class MessageProvider {
-
- public JSONObject createMessageWithNotification(JSONObject commonEventHeaderParams,
- JSONObject notificationParams) {
- return MessageBuilder
- .withCommonEventHeaderParams(commonEventHeaderParams)
- .withNotificationParams(notificationParams)
- .build();
- }
-
- public JSONObject createMessageWithPnfRegistration(JSONObject commonEventHeaderParams, JSONObject pnfRegistrationParams) {
- return MessageBuilder
- .withCommonEventHeaderParams(commonEventHeaderParams)
- .withPnfRegistrationParams(pnfRegistrationParams)
- .build();
- }
-
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfConfigurationCheckingTask.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfConfigurationCheckingTask.java
deleted file mode 100644
index 2300d6492..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfConfigurationCheckingTask.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor;
-
-import com.tailf.jnc.JNCException;
-import java.io.IOException;
-import java.util.TimerTask;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationCache;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationReader;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NetconfConfigurationCheckingTask extends TimerTask {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(NetconfConfigurationCheckingTask.class);
-
- private final NetconfConfigurationReader reader;
- private final NetconfConfigurationWriter writer;
- private final NetconfConfigurationCache cache;
-
- public NetconfConfigurationCheckingTask(NetconfConfigurationReader reader,
- NetconfConfigurationWriter writer,
- NetconfConfigurationCache cache) {
- this.reader = reader;
- this.writer = writer;
- this.cache = cache;
- }
-
- @Override
- public void run() {
- try {
- String currentConfiguration = reader.read();
- if (!currentConfiguration.equals(cache.getConfiguration())) {
- LOGGER.info("Configuration has changed, new configuration:\n\n{}", currentConfiguration);
- writer.writeToFile(currentConfiguration);
- cache.update(currentConfiguration);
- }
- } catch (IOException | JNCException e) {
- LOGGER.warn("Error during configuration reading: {}", e.getMessage());
- }
- }
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorService.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorService.java
deleted file mode 100644
index 0e7ab257d..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorService.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor;
-
-import com.tailf.jnc.JNCException;
-import java.io.IOException;
-import java.util.Timer;
-import javax.annotation.PostConstruct;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationCache;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationReader;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-@Service
-public class NetconfMonitorService {
- private static final Logger LOGGER = LoggerFactory.getLogger(NetconfMonitorService.class);
- private static final long timePeriod = 1000L;
- private static final long startDelay = 0;
-
- private Timer timer;
- private NetconfConfigurationReader reader;
- private NetconfConfigurationWriter writer;
- private NetconfConfigurationCache cache;
-
- @Autowired
- public NetconfMonitorService(Timer timer,
- NetconfConfigurationReader reader,
- NetconfConfigurationWriter writer,
- NetconfConfigurationCache cache) {
- this.timer = timer;
- this.reader = reader;
- this.writer = writer;
- this.cache = cache;
- }
-
- @PostConstruct
- public void start() {
- setStartConfiguration();
- NetconfConfigurationCheckingTask task = new NetconfConfigurationCheckingTask(reader, writer, cache);
- timer.scheduleAtFixedRate(task, startDelay, timePeriod);
- }
-
- private void setStartConfiguration() {
- try {
- String configuration = reader.read();
- writer.writeToFile(configuration);
- cache.update(configuration);
- } catch (IOException | JNCException e) {
- LOGGER.warn("Error during configuration reading: {}", e.getMessage());
- }
- }
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceConfiguration.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceConfiguration.java
deleted file mode 100644
index b0965d42b..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceConfiguration.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor;
-
-import com.tailf.jnc.JNCException;
-import com.tailf.jnc.NetconfSession;
-import com.tailf.jnc.SSHConnection;
-import com.tailf.jnc.SSHSession;
-import java.io.IOException;
-import java.util.Map;
-import java.util.Timer;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationCache;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationReader;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationWriter;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConnectionParams;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class NetconfMonitorServiceConfiguration {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(NetconfMonitorServiceConfiguration.class);
- private static final Map<String, String> enviroment = System.getenv();
-
- private static final String LOG_PATH = "/var/log";
-
- private static final String NETCONF_ADDRESS = "NETCONF_ADDRESS";
- private static final String NETCONF_PORT = "NETCONF_PORT";
- private static final String NETCONF_MODEL = "NETCONF_MODEL";
- private static final String NETCONF_MAIN_CONTAINER = "NETCONF_MAIN_CONTAINER";
-
- private static final String DEFAULT_NETCONF_ADDRESS = "localhost";
- private static final int DEFAULT_NETCONF_PORT = 830;
- private static final String DEFAULT_NETCONF_MODEL = "pnf-simulator";
- private static final String DEFAULT_NETCONF_MAIN_CONTAINER = "config";
-
- private static final String DEFAULT_NETCONF_USER = "netconf";
- private static final String DEFAULT_NETCONF_PASSWORD = "netconf";
-
- @Bean
- public Timer timer() {
- return new Timer("NetconfMonitorServiceTimer");
- }
-
- @Bean
- public NetconfConfigurationCache configurationCache() {
- return new NetconfConfigurationCache();
- }
-
- @Bean
- public NetconfConfigurationReader configurationReader() throws IOException, JNCException {
- NetconfConnectionParams params = resolveConnectionParams();
- LOGGER.info("Configuration params are : {}", params);
- NetconfSession session = createNetconfSession(params);
- return new NetconfConfigurationReader(session, buildModelPath());
- }
-
- NetconfSession createNetconfSession(NetconfConnectionParams params) throws IOException, JNCException {
- SSHConnection sshConnection = new SSHConnection(params.address, params.port);
- sshConnection.authenticateWithPassword(params.user, params.password);
- return new NetconfSession( new SSHSession(sshConnection));
- }
-
- @Bean
- public NetconfConfigurationWriter netconfConfigurationWriter() {
- return new NetconfConfigurationWriter(LOG_PATH);
- }
-
- private String buildModelPath() {
- return String.format("/%s:%s",
- enviroment.getOrDefault(NETCONF_MODEL, DEFAULT_NETCONF_MODEL),
- enviroment.getOrDefault(NETCONF_MAIN_CONTAINER, DEFAULT_NETCONF_MAIN_CONTAINER));
- }
-
- NetconfConnectionParams resolveConnectionParams() {
- return new NetconfConnectionParams(
- enviroment.getOrDefault(NETCONF_ADDRESS, DEFAULT_NETCONF_ADDRESS),
- resolveNetconfPort(),
- DEFAULT_NETCONF_USER,
- DEFAULT_NETCONF_PASSWORD);
- }
-
- private int resolveNetconfPort() {
- try {
- return Integer.parseInt(enviroment.get(NETCONF_PORT));
- } catch (NumberFormatException e) {
- LOGGER.warn("Invalid netconf port: {}. Default netconf port {} is set.", e.getMessage(),
- DEFAULT_NETCONF_PORT);
- return DEFAULT_NETCONF_PORT;
- }
- }
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationCache.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationCache.java
deleted file mode 100644
index 39721841b..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationCache.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor.netconf;
-
-public class NetconfConfigurationCache {
-
- private String configuration = "";
-
- public String getConfiguration() {
- return configuration;
- }
-
- public void update(String configuration) {
- this.configuration = configuration;
- }
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationReader.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationReader.java
deleted file mode 100644
index 593598e86..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationReader.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor.netconf;
-
-import com.tailf.jnc.JNCException;
-import com.tailf.jnc.NetconfSession;
-import java.io.IOException;
-
-public class NetconfConfigurationReader {
-
- private final NetconfSession session;
- private final String netconfModelPath;
-
- public NetconfConfigurationReader(NetconfSession session, String netconfModelPath) {
- this.session = session;
- this.netconfModelPath = netconfModelPath;
- }
-
- public String read() throws IOException, JNCException {
- return session.getConfig(netconfModelPath).first().toXMLString();
- }
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationWriter.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationWriter.java
deleted file mode 100644
index 40030796f..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationWriter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor.netconf;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import org.onap.pnfsimulator.rest.util.DateUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NetconfConfigurationWriter {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(NetconfConfigurationWriter.class);
- private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
- private String pathToLog;
-
- public NetconfConfigurationWriter(String pathToLog) {
- this.pathToLog = pathToLog;
- }
-
- public void writeToFile(String configuration) {
- String fileName = String.format("%s/config[%s].xml", pathToLog, DateUtil.getTimestamp(dateFormat));
- try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
- writer.write(configuration);
- LOGGER.info("Configuration wrote to file {}/{} ", pathToLog, fileName);
- } catch (IOException e) {
- LOGGER.warn("Failed to write configuration to file: {}", e.getMessage());
- }
- }
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConnectionParams.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConnectionParams.java
deleted file mode 100644
index 1d6eb89bf..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConnectionParams.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor.netconf;
-
-public class NetconfConnectionParams {
-
- public final String address;
- public final int port;
- public final String user;
- public final String password;
-
- public NetconfConnectionParams(String address, int port, String user, String password) {
- this.address = address;
- this.port = port;
- this.user = user;
- this.password = password;
- }
-
- @Override
- public String toString() {
- return String.format("NetconfConnectionParams{address=%s, port=%d, user=%s, password=%s}",
- address,
- port,
- user,
- password);
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/SimulatorController.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/SimulatorController.java
deleted file mode 100644
index 6b9f02622..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/SimulatorController.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.rest;
-
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.onap.pnfsimulator.rest.util.DateUtil;
-import org.onap.pnfsimulator.rest.util.ResponseBuilder;
-import org.onap.pnfsimulator.simulator.Simulator;
-import org.onap.pnfsimulator.simulator.SimulatorFactory;
-import org.onap.pnfsimulator.simulator.validation.JSONValidator;
-import org.onap.pnfsimulator.simulator.validation.ValidationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.Marker;
-import org.slf4j.MarkerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.UUID;
-
-import static org.onap.pnfsimulator.logging.MDCVariables.INSTANCE_UUID;
-import static org.onap.pnfsimulator.logging.MDCVariables.INVOCATION_ID;
-import static org.onap.pnfsimulator.logging.MDCVariables.REQUEST_ID;
-import static org.onap.pnfsimulator.logging.MDCVariables.RESPONSE_CODE;
-import static org.onap.pnfsimulator.logging.MDCVariables.SERVICE_NAME;
-import static org.onap.pnfsimulator.logging.MDCVariables.X_INVOCATION_ID;
-import static org.onap.pnfsimulator.logging.MDCVariables.X_ONAP_REQUEST_ID;
-import static org.onap.pnfsimulator.message.MessageConstants.COMMON_EVENT_HEADER_PARAMS;
-import static org.onap.pnfsimulator.message.MessageConstants.NOTIFICATION_PARAMS;
-import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_PARAMS;
-import static org.onap.pnfsimulator.message.MessageConstants.SIMULATOR_PARAMS;
-import static org.onap.pnfsimulator.rest.util.ResponseBuilder.MESSAGE;
-import static org.onap.pnfsimulator.rest.util.ResponseBuilder.REMAINING_TIME;
-import static org.onap.pnfsimulator.rest.util.ResponseBuilder.SIMULATOR_STATUS;
-import static org.onap.pnfsimulator.rest.util.ResponseBuilder.TIMESTAMP;
-import static org.springframework.http.HttpStatus.BAD_REQUEST;
-import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
-import static org.springframework.http.HttpStatus.OK;
-
-@RestController
-@RequestMapping("/simulator")
-public class SimulatorController {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(Simulator.class);
- private static final DateFormat RESPONSE_DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss,SSS");
- private final Marker ENTRY = MarkerFactory.getMarker("ENTRY");
- private Simulator simulator;
- private JSONValidator validator;
- private SimulatorFactory factory;
-
- @Autowired
- public SimulatorController(JSONValidator validator, SimulatorFactory factory) {
- this.validator = validator;
- this.factory = factory;
- }
-
- @PostMapping("start")
- public ResponseEntity start(@RequestHeader HttpHeaders headers, @RequestBody String message) {
- MDC.put(REQUEST_ID, headers.getFirst(X_ONAP_REQUEST_ID));
- MDC.put(INVOCATION_ID, headers.getFirst(X_INVOCATION_ID));
- MDC.put(INSTANCE_UUID, UUID.randomUUID().toString());
- MDC.put(SERVICE_NAME, "/simulator/start");
- LOGGER.info(ENTRY, "Simulator starting");
-
- if (isSimulatorRunning()) {
- MDC.put(RESPONSE_CODE, BAD_REQUEST.toString());
- return ResponseBuilder
- .status(BAD_REQUEST)
- .put(TIMESTAMP, DateUtil.getTimestamp(RESPONSE_DATE_FORMAT))
- .put(MESSAGE, "Cannot start simulator since it's already running")
- .build();
- }
-
- try {
- validator.validate(message, "json_schema/input_validator.json");
- JSONObject root = new JSONObject(message);
- JSONObject simulatorParams = root.getJSONObject(SIMULATOR_PARAMS);
- JSONObject commonEventHeaderParams = root.getJSONObject(COMMON_EVENT_HEADER_PARAMS);
- simulator = createSimulator(root, simulatorParams, commonEventHeaderParams);
- simulator.start();
-
- MDC.put(RESPONSE_CODE, OK.toString());
- return ResponseBuilder
- .status(OK)
- .put(TIMESTAMP, DateUtil.getTimestamp(RESPONSE_DATE_FORMAT))
- .put(MESSAGE, "Simulator started")
- .build();
-
- } catch (JSONException e) {
- MDC.put(RESPONSE_CODE, BAD_REQUEST.toString());
- LOGGER.warn("Cannot start simulator, invalid json format: {}", e.getMessage());
- LOGGER.debug("Received json has invalid format", e);
- return ResponseBuilder
- .status(BAD_REQUEST)
- .put(TIMESTAMP, DateUtil.getTimestamp(RESPONSE_DATE_FORMAT))
- .put(MESSAGE, "Cannot start simulator, invalid json format")
- .build();
-
- } catch (ProcessingException | ValidationException | IOException e) {
- MDC.put(RESPONSE_CODE, BAD_REQUEST.toString());
- LOGGER.warn("Json validation failed: {}", e.getMessage());
- return ResponseBuilder
- .status(BAD_REQUEST)
- .put(TIMESTAMP, DateUtil.getTimestamp(RESPONSE_DATE_FORMAT))
- .put(MESSAGE, "Cannot start simulator - Json format is not compatible with schema definitions")
- .build();
-
- } catch (Exception e) {
- MDC.put(RESPONSE_CODE, INTERNAL_SERVER_ERROR.toString());
- LOGGER.error("Cannot start simulator - unexpected exception", e);
- return ResponseBuilder
- .status(INTERNAL_SERVER_ERROR)
- .put(TIMESTAMP, DateUtil.getTimestamp(RESPONSE_DATE_FORMAT))
- .put(MESSAGE, "Unexpected exception: " + e.getMessage())
- .build();
- } finally {
- MDC.clear();
- }
- }
-
- private Simulator createSimulator(JSONObject root, JSONObject simulatorParams, JSONObject commonEventHeaderParams)
- throws ProcessingException, IOException, ValidationException {
- JSONObject pnfRegistrationFields = root.optJSONObject(PNF_REGISTRATION_PARAMS);
- JSONObject notificationFields = root.optJSONObject(NOTIFICATION_PARAMS);
- if (pnfRegistrationFields != null && notificationFields == null) {
- return factory.createSimulatorWithPnfRegistration(simulatorParams, commonEventHeaderParams, pnfRegistrationFields);
- } else if (pnfRegistrationFields == null && notificationFields != null) {
- return factory.createSimulatorWithNotification(simulatorParams, commonEventHeaderParams, notificationFields);
- } else {
- throw new ValidationException("Exactly one of pnfRegistrationFields or notificationFields should be present");
- }
- }
-
- @GetMapping("status")
- public ResponseEntity status() {
- if (isSimulatorRunning()) {
- ResponseBuilder responseBuilder = ResponseBuilder
- .status(OK)
- .put(TIMESTAMP, DateUtil.getTimestamp(RESPONSE_DATE_FORMAT))
- .put(SIMULATOR_STATUS, "RUNNING");
-
- return !simulator.isEndless() ?
- responseBuilder
- .put(REMAINING_TIME, simulator.getRemainingTime())
- .build() :
- responseBuilder
- .build();
- } else {
- return ResponseBuilder
- .status(OK)
- .put(TIMESTAMP, DateUtil.getTimestamp(RESPONSE_DATE_FORMAT))
- .put(SIMULATOR_STATUS, "NOT RUNNING")
- .build();
- }
- }
-
- @PostMapping("stop")
- public ResponseEntity stop() {
- if (isSimulatorRunning()) {
- simulator.interrupt();
-
- return ResponseBuilder
- .status(OK)
- .put(TIMESTAMP, DateUtil.getTimestamp(RESPONSE_DATE_FORMAT))
- .put(MESSAGE, "Simulator successfully stopped")
- .build();
- } else {
- return ResponseBuilder
- .status(BAD_REQUEST)
- .put(TIMESTAMP, DateUtil.getTimestamp(RESPONSE_DATE_FORMAT))
- .put(MESSAGE, "Cannot stop simulator, because it's not running")
- .build();
- }
- }
-
- private boolean isSimulatorRunning() {
- return simulator != null && simulator.isAlive();
- }
-}
-
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/DateUtil.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/DateUtil.java
deleted file mode 100644
index 284d58904..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/DateUtil.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.rest.util;
-
-import java.text.DateFormat;
-import java.util.Date;
-
-public final class DateUtil {
-
- private DateUtil() {
- }
-
- public static String getTimestamp(DateFormat dateFormat) {
-
- return dateFormat.format(new Date());
- }
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/ResponseBuilder.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/ResponseBuilder.java
deleted file mode 100644
index 98f4588c1..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/ResponseBuilder.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.rest.util;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-public class ResponseBuilder {
-
- public static final String TIMESTAMP = "timestamp";
- public static final String MESSAGE = "message";
- public static final String SIMULATOR_STATUS = "simulatorStatus";
- public static final String REMAINING_TIME = "remainingTime";
-
- private HttpStatus httpStatus;
- private Map<String, Object> body = new LinkedHashMap<>();
-
- private ResponseBuilder(HttpStatus httpStatus) {
- this.httpStatus = httpStatus;
- }
-
- public static ResponseBuilder status(HttpStatus httpStatus) {
-
- return new ResponseBuilder(httpStatus);
- }
-
- public ResponseBuilder put(String key, Object value) {
-
- body.put(key, value);
- return this;
- }
-
- public ResponseEntity build() {
-
- if (body.isEmpty()) {
- return ResponseEntity.status(httpStatus).build();
- }
-
- return ResponseEntity.status(httpStatus).body(body);
- }
-
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/Simulator.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/Simulator.java
deleted file mode 100644
index 854311709..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/Simulator.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.simulator;
-
-import java.time.Duration;
-import java.time.Instant;
-import java.util.Map;
-import org.json.JSONObject;
-import org.onap.pnfsimulator.simulator.client.HttpClientAdapter;
-import org.onap.pnfsimulator.simulator.client.HttpClientAdapterImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.Marker;
-import org.slf4j.MarkerFactory;
-
-public class Simulator extends Thread {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(Simulator.class);
- private final Marker EXIT = MarkerFactory.getMarker("EXIT");
- private Map<String,String> contextMap = MDC.getCopyOfContextMap();
- private boolean isEndless;
- private String vesUrl;
- private HttpClientAdapter httpClient;
- private JSONObject messageBody;
- private Duration duration;
- private Duration interval;
- private Instant endTime;
-
- private Simulator() {
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public void run() {
- setMdcContextMap(contextMap);
- LOGGER.info("Simulation started - duration: {}, interval: {}s", getDuration(), interval.getSeconds());
- endTime = Instant.now().plus(duration);
- while (isEndless || runningTimeNotExceeded()) {
- try {
- LOGGER.debug("Message to be sent:\n" + getMessage());
- httpClient.send(messageBody.toString(), vesUrl);
- Thread.sleep(interval.toMillis());
- } catch (InterruptedException e) {
- LOGGER.info("Simulation interrupted");
- return;
- }
- }
- LOGGER.info(EXIT, "Simulation finished");
- MDC.clear();
- }
-
- private void setMdcContextMap(Map<String,String> mdcContextMap) {
- if(mdcContextMap != null)
- MDC.setContextMap(mdcContextMap);
- }
-
- private String getMessage() {
- return messageBody.toString(4);
- }
-
- private String getDuration() {
- return isEndless() ? "infinity" : duration.getSeconds() + "s";
- }
-
- private boolean runningTimeNotExceeded() {
- return Instant.now().isBefore(endTime);
- }
-
- public boolean isEndless() {
- return isEndless;
- }
-
- public long getRemainingTime() {
- return Duration.between(Instant.now(), endTime).getSeconds();
- }
-
- public static class Builder {
-
- private String vesUrl;
- private HttpClientAdapter httpClient;
- private JSONObject messageBody;
- private Duration duration;
- private Duration interval;
-
- private Builder() {
- this.vesUrl = "";
- this.httpClient = new HttpClientAdapterImpl();
- this.messageBody = new JSONObject();
- this.duration = Duration.ZERO;
- this.interval = Duration.ZERO;
- }
-
- public Builder withVesUrl(String vesUrl) {
- this.vesUrl = vesUrl;
- return this;
- }
-
- public Builder withCustomHttpClientAdapter(HttpClientAdapter httpClient) {
- this.httpClient = httpClient;
- return this;
- }
-
- public Builder withMessageBody(JSONObject messageBody) {
- this.messageBody = messageBody;
- return this;
- }
-
- public Builder withDuration(Duration duration) {
- this.duration = duration;
- return this;
- }
-
-
- public Builder withInterval(Duration interval) {
- this.interval = interval;
- return this;
- }
-
- public Simulator build() {
- Simulator simulator = new Simulator();
- simulator.vesUrl = this.vesUrl;
- simulator.httpClient = this.httpClient;
- simulator.messageBody = this.messageBody;
- simulator.duration = this.duration;
- simulator.interval = this.interval;
- simulator.isEndless = duration.equals(Duration.ZERO);
- return simulator;
- }
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
deleted file mode 100644
index 8e16ad2ce..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.simulator;
-
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import org.json.JSONObject;
-import org.onap.pnfsimulator.message.MessageProvider;
-import org.onap.pnfsimulator.simulator.validation.JSONValidator;
-import org.onap.pnfsimulator.simulator.validation.ValidationException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.io.IOException;
-import java.time.Duration;
-
-import static java.lang.Integer.parseInt;
-import static org.onap.pnfsimulator.message.MessageConstants.MESSAGE_INTERVAL;
-import static org.onap.pnfsimulator.message.MessageConstants.TEST_DURATION;
-import static org.onap.pnfsimulator.message.MessageConstants.VES_SERVER_URL;
-
-@Service
-public class SimulatorFactory {
-
- private static final String DEFAULT_OUTPUT_SCHEMA_PATH = "json_schema/output_validator_ves_schema_30.0.1.json";
-
- private MessageProvider messageProvider;
- private JSONValidator validator;
-
- @Autowired
- public SimulatorFactory(MessageProvider messageProvider, JSONValidator validator) {
- this.messageProvider = messageProvider;
- this.validator = validator;
- }
-
- public Simulator createSimulatorWithNotification(JSONObject simulatorParams, JSONObject commonEventHeaderParams,
- JSONObject notificationParams)
- throws ProcessingException, IOException, ValidationException {
- JSONObject messageBody = messageProvider
- .createMessageWithNotification(commonEventHeaderParams, notificationParams);
- return createSimulatorWithMessage(simulatorParams, messageBody);
- }
-
- public Simulator createSimulatorWithPnfRegistration(JSONObject simulatorParams, JSONObject commonEventHeaderParams,
- JSONObject pnfRegistrationParams)
- throws ProcessingException, IOException, ValidationException {
- JSONObject messageBody = messageProvider
- .createMessageWithPnfRegistration(commonEventHeaderParams, pnfRegistrationParams);
- return createSimulatorWithMessage(simulatorParams, messageBody);
- }
-
- private Simulator createSimulatorWithMessage(JSONObject simulatorParams, JSONObject messageBody)
- throws ValidationException, ProcessingException, IOException {
- Duration duration = Duration.ofSeconds(parseInt(simulatorParams.getString(TEST_DURATION)));
- Duration interval = Duration.ofSeconds(parseInt(simulatorParams.getString(MESSAGE_INTERVAL)));
- String vesUrl = simulatorParams.getString(VES_SERVER_URL);
- validator.validate(messageBody.toString(), DEFAULT_OUTPUT_SCHEMA_PATH);
-
- return Simulator.builder()
- .withVesUrl(vesUrl)
- .withDuration(duration)
- .withInterval(interval)
- .withMessageBody(messageBody)
- .build();
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapter.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapter.java
deleted file mode 100644
index 47f2e3112..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapter.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.simulator.client;
-
-public interface HttpClientAdapter {
-
- void send(String content, String url);
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImpl.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImpl.java
deleted file mode 100644
index f0c9917f5..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImpl.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.simulator.client;
-
-import static org.onap.pnfsimulator.logging.MDCVariables.REQUEST_ID;
-import static org.onap.pnfsimulator.logging.MDCVariables.X_INVOCATION_ID;
-import static org.onap.pnfsimulator.logging.MDCVariables.X_ONAP_REQUEST_ID;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.UUID;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.slf4j.Marker;
-import org.slf4j.MarkerFactory;
-
-public class HttpClientAdapterImpl implements HttpClientAdapter {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(HttpClientAdapterImpl.class);
- private static final String CONTENT_TYPE = "Content-Type";
- private static final String APPLICATION_JSON = "application/json";
- private final Marker INVOKE = MarkerFactory.getMarker("INVOKE");
- private static final RequestConfig CONFIG = RequestConfig.custom()
- .setConnectTimeout(1000)
- .setConnectionRequestTimeout(1000)
- .setSocketTimeout(1000)
- .build();
-
- private HttpClient client;
-
- public HttpClientAdapterImpl() {
- this.client = HttpClientBuilder
- .create()
- .setDefaultRequestConfig(CONFIG)
- .build();
- }
-
- @Override
- public void send(String content, String url) {
- try {
- HttpPost request = createRequest(content, url);
- HttpResponse response = client.execute(request);
- EntityUtils.consumeQuietly(response.getEntity());
- LOGGER.info(INVOKE, "Message sent, ves response code: {}", response.getStatusLine());
- } catch (IOException e) {
- LOGGER.warn("Error sending message to ves: {}", e.getMessage());
- }
- }
-
- HttpClientAdapterImpl(HttpClient client) {
- this.client = client;
- }
-
- private HttpPost createRequest(String content, String url) throws UnsupportedEncodingException {
- HttpPost request = new HttpPost(url);
- StringEntity stringEntity = new StringEntity(content);
- request.addHeader(CONTENT_TYPE, APPLICATION_JSON);
- request.addHeader(X_ONAP_REQUEST_ID, MDC.get(REQUEST_ID));
- request.addHeader(X_INVOCATION_ID, UUID.randomUUID().toString());
- request.setEntity(stringEntity);
- return request;
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/JSONValidator.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/JSONValidator.java
deleted file mode 100644
index 89135f9b4..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/JSONValidator.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.simulator.validation;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jackson.JsonLoader;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.report.LogLevel;
-import com.github.fge.jsonschema.core.report.ProcessingMessage;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-import com.google.gson.JsonParser;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
-
-public class JSONValidator {
-
- public void validate(String data, String jsonSchemaPath)
- throws ValidationException, ProcessingException, IOException {
- String jsonSchema = readJsonSchemaAsString(jsonSchemaPath);
- JsonNode jsonData = JsonLoader.fromString(data);
- ProcessingReport report = createJsonSchema(jsonSchema).validate(jsonData);
-
- if (!report.isSuccess()) {
- throw new ValidationException(constructValidationErrors(report));
- }
- }
-
- private String readJsonSchemaAsString(String schemaPath) throws IOException {
- try (FileReader reader = new FileReader(schemaPath)) {
- return new JsonParser().parse(reader).toString();
- }
- }
-
- private JsonSchema createJsonSchema(String schema) throws ProcessingException, IOException {
- return JsonSchemaFactory.byDefault().getJsonSchema(JsonLoader.fromString(schema));
- }
-
- private String constructValidationErrors(ProcessingReport report) {
- return StreamSupport.stream(report.spliterator(), false)
- .filter(entry -> entry.getLogLevel() == LogLevel.ERROR)
- .map(ProcessingMessage::getMessage)
- .collect(Collectors.joining("\n"));
- }
-}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ValidationException.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ValidationException.java
deleted file mode 100644
index a9349174a..000000000
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ValidationException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.simulator.validation;
-
-public class ValidationException extends Exception {
-
- public ValidationException(String message) {
- super(message);
- }
-}
diff --git a/test/mocks/pnfsimulator/src/main/resources/application.properties b/test/mocks/pnfsimulator/src/main/resources/application.properties
deleted file mode 100644
index 888dcec44..000000000
--- a/test/mocks/pnfsimulator/src/main/resources/application.properties
+++ /dev/null
@@ -1 +0,0 @@
-server.port=5000 \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/main/resources/logback.xml b/test/mocks/pnfsimulator/src/main/resources/logback.xml
deleted file mode 100644
index de34b9ae3..000000000
--- a/test/mocks/pnfsimulator/src/main/resources/logback.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration complete="true" compact="true">
-
- <Property name="outputFilename" value="pnfsimulator_output"/>
- <Property name="log-path" value="/var/log/ONAP/pnfsimulator"/>
- <Property name="archive" value="/var/log/ONAP/pnfsimulator/archive"/>
- <property name="maxFileSize" value="50MB"/>
- <property name="maxHistory" value="30"/>
- <property name="totalSizeCap" value="10GB"/>
-
- <appender name="Console" target="SYSTEM_OUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>%nopexception%logger
- |%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}
- |%level
- |%replace(%replace(%message){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%mdc){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%rootException){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%marker){'\t','\\\\t'}){'\n','\\\\n'}
- |%thread
- |%n</Pattern>
- </encoder>
- </appender>
-
- <appender name="ROLLING-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <encoder>
- <pattern>%nopexception%logger
- |%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}
- |%level
- |%replace(%replace(%message){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%mdc){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%rootException){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%marker){'\t','\\\\t'}){'\n','\\\\n'}
- |%thread
- |%n</pattern>
- </encoder>
- <File>${log-path}/${outputFilename}.log</File>
- <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
- <FileNamePattern>${archive}/${outputFilename}.%d{yyyy-MM-dd}.%i.log.zip</FileNamePattern>
- <MaxFileSize>${maxFileSize}</MaxFileSize>
- <MaxHistory>${maxHistory}</MaxHistory>
- <TotalSizeCap>${totalSizeCap}</TotalSizeCap>
- </rollingPolicy>
- </appender>
-
- <root level="info">
- <appender-ref ref="Console" />
- <appender-ref ref="ROLLING-FILE" />
- </root>
-</Configuration>
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/JSONObjectFactoryTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/JSONObjectFactoryTest.java
deleted file mode 100644
index 4331195c9..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/JSONObjectFactoryTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.message;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.onap.pnfsimulator.message.MessageConstants.*;
-
-import org.json.JSONObject;
-import org.junit.jupiter.api.Test;
-
-public class JSONObjectFactoryTest {
-
- @Test
- public void generateConstantCommonEventHeader_shouldCreateProperly(){
- JSONObject commonEventHeader = JSONObjectFactory.generateConstantCommonEventHeader();
- assertEquals(8,commonEventHeader.toMap().size());
- assertTrue(commonEventHeader.has(EVENT_ID));
- assertTrue(commonEventHeader.has(LAST_EPOCH_MICROSEC));
- assertTrue(commonEventHeader.has(PRIORITY));
- assertTrue(commonEventHeader.has(SEQUENCE));
- assertTrue(commonEventHeader.has(START_EPOCH_MICROSEC));
- assertTrue(commonEventHeader.has(INTERNAL_HEADER_FIELDS));
- assertTrue(commonEventHeader.has(VERSION));
- assertEquals(commonEventHeader.get(PRIORITY),PRIORITY_NORMAL);
- assertEquals(commonEventHeader.get(SEQUENCE),SEQUENCE_NUMBER);
- assertEquals(commonEventHeader.get(VERSION),VERSION_NUMBER);
- assertEquals(commonEventHeader.get(VES_EVENT_LISTENER_VERSION),VES_EVENT_LISTENER_VERSION_NUMBER);
- }
-
- @Test
- public void generateConstantPnfRegistrationFields_shouldCreateProperly(){
- JSONObject pnfRegistrationFields = JSONObjectFactory.generatePnfRegistrationFields();
- assertEquals(3,pnfRegistrationFields.toMap().size());
- assertTrue(pnfRegistrationFields.has(PNF_REGISTRATION_FIELDS_VERSION));
- assertEquals(pnfRegistrationFields.get(PNF_REGISTRATION_FIELDS_VERSION), PNF_REGISTRATION_FIELDS_VERSION_VALUE);
- assertTrue(pnfRegistrationFields.has(PNF_LAST_SERVICE_DATE));
- assertTrue(pnfRegistrationFields.has(PNF_MANUFACTURE_DATE));
- }
-
- @Test
- public void generateEventId_shouldCreateProperly(){
- String eventId = JSONObjectFactory.generateEventId();
- assertTrue(eventId.startsWith("registration_"));
- }
-
- @Test
- public void generateNotificationFields_shouldCreateProperly(){
- JSONObject notificationFields = JSONObjectFactory.generateNotificationFields();
- assertEquals(1,notificationFields.keySet().size());
- assertEquals(NOTIFICATION_FIELDS_VERSION_VALUE,notificationFields.get(NOTIFICATION_FIELDS_VERSION));
-
- }
-
-}
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java
deleted file mode 100644
index 4524b96c3..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.message;
-
-import org.json.JSONObject;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.onap.pnfsimulator.simulator.ResourceReader;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.data.MapEntry.entry;
-import static org.onap.pnfsimulator.message.MessageConstants.COMMON_EVENT_HEADER;
-import static org.onap.pnfsimulator.message.MessageConstants.EVENT;
-import static org.onap.pnfsimulator.message.MessageConstants.NOTIFICATION_FIELDS;
-import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FIELDS;
-
-public class MessageProviderTest {
-
- private static String testParamsPnfRegistration;
-
- private static String testParamsNotification;
-
- private MessageProvider messageProvider = new MessageProvider();
-
- @BeforeAll
- public static void setup() {
- ResourceReader reader = new ResourceReader("org/onap/pnfsimulator/message/MessageProviderTest/");
- testParamsPnfRegistration = reader.readResource("pnfRegistrationParams.json");
- testParamsNotification = reader.readResource("notificationParams.json");
- }
-
- @Test
- public void createMessageWithPnfRegistration_should_create_constant_message_when_no_params_specified() {
- JSONObject message = messageProvider.createMessageWithPnfRegistration(new JSONObject(), new JSONObject());
- JSONObject event = message.getJSONObject(EVENT);
-
- JSONObject commonEventHeader = event.getJSONObject(COMMON_EVENT_HEADER);
- JSONObject pnfRegistrationFields = event.getJSONObject(PNF_REGISTRATION_FIELDS);
-
- JSONObject expectedCommonEventHeader = JSONObjectFactory.generateConstantCommonEventHeader();
- JSONObject expectedPnfRegistrationFields = JSONObjectFactory.generatePnfRegistrationFields();
-
- assertThat(commonEventHeader.keySet())
- .containsAll(expectedCommonEventHeader.keySet());
- assertThat(pnfRegistrationFields.keySet())
- .containsAll(expectedPnfRegistrationFields.keySet());
- }
-
- @Test
- public void createMessageWithNotification_should_create_constant_message_when_no_params_specified() {
- JSONObject message = messageProvider.createMessageWithNotification(new JSONObject(),
- new JSONObject());
- JSONObject event = message.getJSONObject(EVENT);
-
- JSONObject commonEventHeader = event.getJSONObject(COMMON_EVENT_HEADER);
- JSONObject notificationFields = event.getJSONObject(NOTIFICATION_FIELDS);
-
- JSONObject expectedCommonEventHeader = JSONObjectFactory.generateConstantCommonEventHeader();
- JSONObject expectedNotificationFields = JSONObjectFactory.generateNotificationFields();
-
- assertThat(commonEventHeader.keySet())
- .containsAll(expectedCommonEventHeader.keySet());
-
- assertThat(notificationFields.keySet())
- .containsAll(expectedNotificationFields.keySet());
- }
-
- @Test
- public void createMessageWithPnfRegistration_should_add_specified_params_to_valid_subobjects() {
- JSONObject message = messageProvider
- .createMessageWithPnfRegistration(new JSONObject(), new JSONObject(testParamsPnfRegistration));
- JSONObject event = message.getJSONObject(EVENT);
-
- JSONObject commonEventHeader = event.getJSONObject(COMMON_EVENT_HEADER);
-
- JSONObject pnfRegistrationFields = event.getJSONObject(PNF_REGISTRATION_FIELDS);
- assertThat(pnfRegistrationFields.toMap()).contains(
- entry("pnfKey1", "pnfVal1"),
- entry("pnfKey2", "pnfVal2"),
- entry("pnfKey3", "pnfVal3"),
- entry("pnfKey4", "pnfVal4")
- );
- }
-
- @Test
- public void createMessageWithNotification_should_add_specified_params_to_valid_subobjects() {
- JSONObject message = messageProvider
- .createMessageWithNotification(new JSONObject(),
- new JSONObject(testParamsNotification));
- JSONObject event = message.getJSONObject(EVENT);
-
- JSONObject notificationFields = event.getJSONObject(NOTIFICATION_FIELDS);
- assertThat(notificationFields.toMap()).contains(
- entry("notKey1", "notVal1"),
- entry("notKey2", "notVal2"),
- entry("notKey3", "notVal3"),
- entry("notKey4", "notVal4")
- );
-
- }
-
-}
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfConfigurationCheckingTaskTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfConfigurationCheckingTaskTest.java
deleted file mode 100644
index 99cae00df..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfConfigurationCheckingTaskTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import com.tailf.jnc.JNCException;
-import java.io.IOException;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationCache;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationReader;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationWriter;
-
-class NetconfConfigurationCheckingTaskTest {
-
- private NetconfConfigurationCheckingTask checkingTask;
-
- @Mock
- private NetconfConfigurationReader reader;
- @Mock
- private NetconfConfigurationWriter writer;
- @Mock
- private NetconfConfigurationCache cache;
-
- @BeforeEach
- void setup() {
- MockitoAnnotations.initMocks(this);
- checkingTask = new NetconfConfigurationCheckingTask(reader, writer, cache);
- }
-
- @Test
- void run_should_update_configuration_when_changed() throws IOException, JNCException {
- String configuration = "newConfiguration";
- when(reader.read()).thenReturn(configuration);
- when(cache.getConfiguration()).thenReturn("oldConfiguration");
-
- checkingTask.run();
-
- verify(reader).read();
- verify(cache).getConfiguration();
- verify(writer).writeToFile(configuration);
- verify(cache).update(configuration);
- }
-
- @Test
- void run_should_not_update_configuration_when_same() throws IOException, JNCException {
- String configuration = "configuration";
- when(reader.read()).thenReturn(configuration);
- when(cache.getConfiguration()).thenReturn("configuration");
-
- checkingTask.run();
-
- verify(reader).read();
- verify(cache).getConfiguration();
- verify(writer, never()).writeToFile(configuration);
- verify(cache, never()).update(configuration);
- }
-
- @Test
- void run_should_not_take_any_action_when_failed_to_read_configuration() throws IOException, JNCException {
- when(reader.read()).thenThrow(new IOException());
-
- checkingTask.run();
-
- verify(reader).read();
- verify(cache, never()).getConfiguration();
- verify(writer, never()).writeToFile(any());
- verify(cache, never()).update(any());
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceConfigurationTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceConfigurationTest.java
deleted file mode 100644
index 02b8423f1..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceConfigurationTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-
-import com.tailf.jnc.JNCException;
-import com.tailf.jnc.NetconfSession;
-import java.io.IOException;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
-
-class NetconfMonitorServiceConfigurationTest {
-
- private NetconfMonitorServiceConfiguration configuration;
-
- @Mock
- private NetconfSession netconfSession;
-
- @BeforeEach
- void setup() {
- netconfSession = mock(NetconfSession.class);
- configuration = spy(new NetconfMonitorServiceConfiguration());
- }
-
- @Test
- void readNetconfConfiguration() throws IOException, JNCException {
- doReturn(netconfSession).when(configuration).createNetconfSession(any());
-
- assertNotNull(configuration.configurationReader());
- verify(configuration).createNetconfSession(any());
- }
-
- @Test
- void configurationCacheIsNotNull() {
- assertNotNull(configuration.configurationCache());
- }
-
- @Test
- void netconfConfigurationWriterIsNotNull() {
- assertNotNull(configuration.netconfConfigurationWriter());
- }
-
- @Test
- void timerIsNotNull() {
- assertNotNull(configuration.timer());
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceTest.java
deleted file mode 100644
index 4f5da3309..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor;
-
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyLong;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import com.tailf.jnc.JNCException;
-import java.io.IOException;
-import java.util.Timer;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationCache;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationReader;
-import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationWriter;
-
-class NetconfMonitorServiceTest {
-
- private NetconfMonitorService service;
-
- @Mock
- private Timer timer;
- @Mock
- private NetconfConfigurationReader reader;
- @Mock
- private NetconfConfigurationWriter writer;
- @Mock
- private NetconfConfigurationCache cache;
-
- @BeforeEach
- void setup() {
- MockitoAnnotations.initMocks(this);
- service = new NetconfMonitorService(timer, reader, writer, cache);
- }
-
- @Test
- void startNetconfService() throws IOException, JNCException {
- when(reader.read()).thenReturn("message");
- doNothing().when(writer).writeToFile(anyString());
- doNothing().when(cache).update(anyString());
-
- service.start();
-
- verify(cache, times(1)).update(anyString());
- verify(writer, times(1)).writeToFile(anyString());
- verify(timer, times(1)).scheduleAtFixedRate(any(), anyLong(), anyLong());
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationCacheTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationCacheTest.java
deleted file mode 100644
index 56f62ac50..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationCacheTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor.netconf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.junit.jupiter.api.Test;
-
-public class NetconfConfigurationCacheTest {
-
- private static final String CONFIGURATION = "sampleConfiguration";
-
- @Test
- void changeConfigurationAfterUpdate() {
- NetconfConfigurationCache configurationCache = new NetconfConfigurationCache();
- configurationCache.update(CONFIGURATION);
-
- assertEquals(CONFIGURATION, configurationCache.getConfiguration());
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationReaderTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationReaderTest.java
deleted file mode 100644
index 65b2bc32e..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationReaderTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor.netconf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import com.tailf.jnc.Element;
-import com.tailf.jnc.JNCException;
-import com.tailf.jnc.NetconfSession;
-import com.tailf.jnc.NodeSet;
-import java.io.IOException;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-class NetconfConfigurationReaderTest {
-
- private static final String NETCONF_MODEL_PATH = "";
- private static final String EXPECTED_STRING_XML = "<?xml version=\"1.0\"?>";
- private NetconfConfigurationReader reader;
-
- @Mock
- private NetconfSession netconfSession;
- @Mock
- private NodeSet nodeSet;
- @Mock
- private Element element;
-
- @BeforeEach
- void setup() {
- MockitoAnnotations.initMocks(this);
- reader = new NetconfConfigurationReader(netconfSession, NETCONF_MODEL_PATH);
- }
-
- @Test
- void properlyReadXML() throws IOException, JNCException {
- when(netconfSession.getConfig(anyString())).thenReturn(nodeSet);
- when(nodeSet.first()).thenReturn(element);
- when(element.toXMLString()).thenReturn(EXPECTED_STRING_XML);
-
- String result = reader.read();
-
- verify(netconfSession).getConfig(anyString());
- verify(nodeSet).first();
- verify(element).toXMLString();
- assertEquals(EXPECTED_STRING_XML, result);
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationWriterTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationWriterTest.java
deleted file mode 100644
index 2baee21b7..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationWriterTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.netconfmonitor.netconf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import org.apache.commons.io.FileUtils;
-import org.junit.Rule;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
-import org.junit.rules.TemporaryFolder;
-
-@EnableRuleMigrationSupport
-class NetconfConfigurationWriterTest {
-
- private static final String TEST_CONFIGURATION = "test-configuration";
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- @Test
- void writeToFile_should_write_sample_config_when_directory_exists() throws IOException {
- File file = temporaryFolder.newFolder("temp");
- NetconfConfigurationWriter configurationWriter = new NetconfConfigurationWriter(file.getPath());
-
- configurationWriter.writeToFile(TEST_CONFIGURATION);
-
- File[] files = file.listFiles();
- assertEquals(1, files.length);
-
- String content = FileUtils.readFileToString(files[0], "UTF-8");
- assertEquals(TEST_CONFIGURATION, content);
- }
-
- @Test
- void writeToFile_should_not_write_config_when_directory_doesnt_exist() {
- String logFolderPath = "/not/existing/logs";
- NetconfConfigurationWriter configurationWriter = new NetconfConfigurationWriter(logFolderPath);
-
- configurationWriter.writeToFile(TEST_CONFIGURATION);
-
- assertFalse(Files.exists(Paths.get(logFolderPath)));
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/SimulatorControllerTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/SimulatorControllerTest.java
deleted file mode 100644
index bed67e33e..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/SimulatorControllerTest.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.rest;
-
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.onap.pnfsimulator.simulator.ResourceReader;
-import org.onap.pnfsimulator.simulator.Simulator;
-import org.onap.pnfsimulator.simulator.SimulatorFactory;
-import org.onap.pnfsimulator.simulator.client.HttpClientAdapter;
-import org.onap.pnfsimulator.simulator.validation.JSONValidator;
-import org.onap.pnfsimulator.simulator.validation.ValidationException;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-
-import java.time.Duration;
-
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-class SimulatorControllerTest {
-
- private static final String START_URL = "/simulator/start";
- private static final String STOP_URL = "/simulator/stop";
- private static final String STATUS_URL = "/simulator/status";
- private static final String JSON_MSG_EXPRESSION = "$.message";
- private static final String JSON_STATUS_EXPRESSION = "$.simulatorStatus";
- private static String pnfRegistrationJson;
- private static String incorrectJson;
-
- private MockMvc mockMvc;
-
- @InjectMocks
- private SimulatorController controller;
-
- @Mock
- private SimulatorFactory factory;
-
- @Mock
- private JSONValidator validator;
-
- private Simulator simulator;
-
- @BeforeAll
- static void beforeAll() {
- ResourceReader reader = new ResourceReader("org/onap/pnfsimulator/rest/SimulatorControllerTest/");
- pnfRegistrationJson = reader.readResource("pnfRegistration.json");
- incorrectJson = reader.readResource("incorrectJson.json");
- }
-
- @BeforeEach
- void setup() {
- MockitoAnnotations.initMocks(this);
- simulator = createEndlessSimulator();
- mockMvc = MockMvcBuilders
- .standaloneSetup(controller)
- .build();
- }
-
- private Simulator createEndlessSimulator() {
- return spy(Simulator.builder()
- .withCustomHttpClientAdapter(mock(HttpClientAdapter.class))
- .withInterval(Duration.ofMinutes(1))
- .build());
- }
-
- @Test
- void wrongJSONFormatOnStart() throws Exception {
- when(factory.createSimulatorWithNotification(any(), any(), any())).thenReturn(simulator);
- doThrow(new ValidationException("")).when(validator).validate(anyString(), anyString());
-
- mockMvc.perform(post("/simulator/start").content(incorrectJson))
- .andExpect(status().isBadRequest())
- .andExpect(jsonPath("$.message").value("Cannot start simulator - Json format " +
- "is not compatible with schema definitions"));
- verify(validator).validate(anyString(), anyString());
- }
-
- @Test
- void startSimulatorProperly() throws Exception {
- startSimulatorWithPnfRegistration();
-
- verify(validator).validate(anyString(), anyString());
- verify(factory).createSimulatorWithPnfRegistration(any(), any(), any());
- verify(simulator).start();
- }
-
- @Test
- void notStartWhenAlreadyRunning() throws Exception {
- startSimulatorWithPnfRegistration();
-
- mockMvc
- .perform(post(START_URL).content(pnfRegistrationJson))
- .andExpect(status().isBadRequest())
- .andExpect(jsonPath(JSON_MSG_EXPRESSION).value("Cannot start simulator since it's already running"));
- }
-
- @Test
- void stopSimulatorWhenRunning() throws Exception {
- startSimulatorWithPnfRegistration();
-
- mockMvc
- .perform(post(STOP_URL))
- .andExpect(status().isOk())
- .andExpect(jsonPath(JSON_MSG_EXPRESSION).value("Simulator successfully stopped"));
- }
-
- @Test
- void getNotRunningMessageWhenOff() throws Exception {
- mockMvc
- .perform(post(STOP_URL))
- .andExpect(status().isBadRequest())
- .andExpect(jsonPath(JSON_MSG_EXPRESSION).value("Cannot stop simulator, because it's not running"));
- }
-
- @Test
- void getRunningStatusWhenOn() throws Exception {
- startSimulatorWithPnfRegistration();
-
- mockMvc
- .perform(get(STATUS_URL))
- .andExpect(status().isOk())
- .andExpect(jsonPath(JSON_STATUS_EXPRESSION).value("RUNNING"));
- }
-
- @Test
- void getNotRunningStatusWhenOff() throws Exception {
- mockMvc
- .perform(get(STATUS_URL))
- .andExpect(status().isOk())
- .andExpect(jsonPath(JSON_STATUS_EXPRESSION).value("NOT RUNNING"));
- }
-
- private void startSimulatorWithPnfRegistration() throws Exception {
- when(factory.createSimulatorWithPnfRegistration(any(), any(), any())).thenReturn(simulator);
-
- mockMvc
- .perform(post(START_URL).content(pnfRegistrationJson))
- .andExpect(status().isOk())
- .andExpect(jsonPath(JSON_MSG_EXPRESSION).value("Simulator started"));
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/DateUtilTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/DateUtilTest.java
deleted file mode 100644
index 99b9af7ec..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/DateUtilTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.rest.util;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import org.junit.jupiter.api.Test;
-
-class DateUtilTest {
-
- @Test
- void getFormattedDate() {
- Calendar currentCalendar = Calendar.getInstance();
- String expectedResult = String.valueOf(currentCalendar.get(Calendar.YEAR));
-
- assertEquals(expectedResult, DateUtil.getTimestamp(new SimpleDateFormat("yyyy")));
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/ResponseBuilderTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/ResponseBuilderTest.java
deleted file mode 100644
index 59e1e3b4f..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/ResponseBuilderTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.rest.util;
-
-import static org.junit.jupiter.api.Assertions.assertAll;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import java.util.Map;
-import org.junit.jupiter.api.Test;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-
-public class ResponseBuilderTest {
-
-
- private static final HttpStatus SAMPLE_STATUS = HttpStatus.OK;
-
- @Test
- void response_should_have_empty_body_when_built_immediately() {
- ResponseEntity responseEntity = ResponseBuilder.status(SAMPLE_STATUS).build();
-
- assertAll(
- () -> assertEquals(responseEntity.getStatusCode(), SAMPLE_STATUS),
- () -> assertNull(responseEntity.getBody())
- );
- }
-
- @Test
- void builder_should_set_response_status_and_body() {
- String key = "key";
- String value = "value";
- ResponseEntity response = ResponseBuilder
- .status(SAMPLE_STATUS)
- .put(key, value)
- .build();
-
- Map<String, Object> body = (Map<String, Object>) response.getBody();
-
- assertAll(
- () -> assertEquals(SAMPLE_STATUS, response.getStatusCode()),
- () -> assertEquals(value, body.get(key))
- );
- }
-
-
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/ResourceReader.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/ResourceReader.java
deleted file mode 100644
index b5721533f..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/ResourceReader.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.simulator;
-
-import com.google.common.io.Resources;
-
-import java.io.IOException;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-
-public class ResourceReader {
- private final String baseDirectory;
-
- public ResourceReader(String baseDirectory) {
- this.baseDirectory = baseDirectory;
- }
-
- public String readResource(String resourceName) {
- try {
- URL pnfRegistrationJson = Resources.getResource(baseDirectory + resourceName);
- return Resources.toString(pnfRegistrationJson, StandardCharsets.UTF_8);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
-}
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/SimulatorFactoryTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/SimulatorFactoryTest.java
deleted file mode 100644
index 5781bbc0b..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/SimulatorFactoryTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.simulator;
-
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.junit.jupiter.api.Test;
-import org.onap.pnfsimulator.message.MessageProvider;
-import org.onap.pnfsimulator.simulator.validation.JSONValidator;
-import org.onap.pnfsimulator.simulator.validation.ValidationException;
-
-import java.io.IOException;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-class SimulatorFactoryTest {
- private static final ResourceReader resourceReader = new ResourceReader("org/onap/pnfsimulator/simulator/SimulatorFactoryTest/");
-
- private static final JSONObject VALID_SIMULATOR_PARAMS = new JSONObject(resourceReader.readResource("validSimulatorParams.json"));
- private static final JSONObject VALID_COMMON_EVENT_HEADER_PARAMS = new JSONObject(resourceReader.readResource("validCommonEventHeaderParams.json"));
- private static final JSONObject VALID_PNF_REGISTRATION_PARAMS = new JSONObject(resourceReader.readResource("validPnfRegistrationParams.json"));
- private static final JSONObject VALID_NOTIFICATION_PARAMS = new JSONObject(resourceReader.readResource("validNotificationParams.json"));
-
- private static final JSONObject INVALID_SIMULATOR_PARAMS = new JSONObject(resourceReader.readResource("invalidSimulatorParams.json"));
- private static final JSONObject INVALID_PNF_REGISTRATION_PARAMS_1 = new JSONObject(resourceReader.readResource("invalidPnfRegistrationParams1.json"));
- private static final JSONObject INVALID_PNF_REGISTRATION_PARAMS_2 = new JSONObject(resourceReader.readResource("invalidPnfRegistrationParams2.json"));
- private static final JSONObject INVALID_PNF_REGISTRATION_PARAMS_3 = new JSONObject(resourceReader.readResource("invalidPnfRegistrationParams3.json"));
-
- private SimulatorFactory simulatorFactory = new SimulatorFactory(new MessageProvider(), new JSONValidator());
-
- @Test
- void should_successfully_create_simulator_given_valid_pnf_registration_params_and_valid_output_message()
- throws ValidationException, IOException, ProcessingException {
- assertNotNull(simulatorFactory.createSimulatorWithPnfRegistration(VALID_SIMULATOR_PARAMS, VALID_COMMON_EVENT_HEADER_PARAMS,
- VALID_PNF_REGISTRATION_PARAMS));
- }
-
- @Test
- void should_successfully_create_simulator_given_valid_notification_params_and_valid_output_message()
- throws ValidationException, IOException, ProcessingException {
- assertNotNull(simulatorFactory.createSimulatorWithNotification(VALID_SIMULATOR_PARAMS, VALID_COMMON_EVENT_HEADER_PARAMS,
- VALID_NOTIFICATION_PARAMS));
- }
-
- @Test
- void should_throw_given_invalid_params() {
- assertThrows(
- JSONException.class,
- () -> simulatorFactory.createSimulatorWithPnfRegistration(INVALID_SIMULATOR_PARAMS, VALID_COMMON_EVENT_HEADER_PARAMS,
- VALID_PNF_REGISTRATION_PARAMS));
- }
-
- @Test
- void should_throw_given_valid_params_and_invalid_output_message() {
-
- assertThrows(
- ValidationException.class,
- () -> simulatorFactory.createSimulatorWithPnfRegistration(VALID_SIMULATOR_PARAMS, VALID_COMMON_EVENT_HEADER_PARAMS,
- INVALID_PNF_REGISTRATION_PARAMS_1));
-
- assertThrows(
- ValidationException.class,
- () -> simulatorFactory.createSimulatorWithPnfRegistration(VALID_SIMULATOR_PARAMS, VALID_COMMON_EVENT_HEADER_PARAMS,
- INVALID_PNF_REGISTRATION_PARAMS_2));
-
- assertThrows(
- ValidationException.class,
- () -> simulatorFactory.createSimulatorWithPnfRegistration(VALID_SIMULATOR_PARAMS, VALID_COMMON_EVENT_HEADER_PARAMS,
- INVALID_PNF_REGISTRATION_PARAMS_3));
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/SimulatorTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/SimulatorTest.java
deleted file mode 100644
index db9dbd785..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/SimulatorTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.simulator;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTimeout;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.atLeast;
-import static org.mockito.Mockito.verify;
-
-import java.time.Duration;
-import org.json.JSONObject;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.function.Executable;
-import org.mockito.Mockito;
-import org.onap.pnfsimulator.simulator.client.HttpClientAdapter;
-
-class SimulatorTest {
-
- private static final String TEST_VES_URL = "http://test-ves-url";
-
- @Test
- void builder_should_create_endless_simulator_when_duration_not_specified() {
- Simulator simulator = Simulator
- .builder()
- .withDuration(Duration.ofSeconds(1))
- .withVesUrl(TEST_VES_URL).build();
-
- assertFalse(simulator.isEndless());
-
- simulator = Simulator
- .builder()
- .withVesUrl(TEST_VES_URL).build();
-
- assertTrue(simulator.isEndless());
- }
-
- @Test
- void simulator_should_send_given_message() {
-
- JSONObject messageBody = new JSONObject("{\"key\":\"val\"}");
- HttpClientAdapter httpClientMock = Mockito.mock(HttpClientAdapter.class);
-
- Simulator simulator = Simulator.builder()
- .withDuration(Duration.ofMillis(100))
- .withInterval(Duration.ofMillis(10))
- .withMessageBody(messageBody)
- .withCustomHttpClientAdapter(httpClientMock)
- .withVesUrl(TEST_VES_URL).build();
-
- simulator.start();
-
- assertTimeout(Duration.ofMillis(150), (Executable) simulator::join);
- verify(httpClientMock, atLeast(2)).send(messageBody.toString(), TEST_VES_URL);
- }
-
- @Test
- void simulator_should_stop_when_interrupted() {
-
- JSONObject messageBody = new JSONObject("{\"key\":\"val\"}");
- HttpClientAdapter httpClientMock = Mockito.mock(HttpClientAdapter.class);
-
- Simulator simulator = Simulator.builder()
- .withInterval(Duration.ofSeconds(1))
- .withMessageBody(messageBody)
- .withCustomHttpClientAdapter(httpClientMock)
- .withVesUrl(TEST_VES_URL).build();
-
- simulator.start();
- simulator.interrupt();
-
- assertTimeout(Duration.ofSeconds(1), (Executable) simulator::join);
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImplTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImplTest.java
deleted file mode 100644
index a4fb9eb04..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImplTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.simulator.client;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.io.IOException;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mock;
-
-class HttpClientAdapterImplTest {
-
- private HttpClientAdapter adapter;
-
- @Mock
- private HttpClient httpClient;
- @Mock
- private HttpResponse httpResponse;
-
- @BeforeEach
- void setup() {
- initMocks(this);
- adapter = new HttpClientAdapterImpl(httpClient);
- }
-
- @Test
- void send_should_successfully_send_request_given_valid_url() throws IOException {
- doReturn(httpResponse).when(httpClient).execute(any());
-
- adapter.send("test-msg", "http://valid-url");
-
- verify(httpClient).execute(any());
- verify(httpResponse).getStatusLine();
- }
-
- @Test
- void send_should_not_send_request_given_invalid_url() throws IOException {
- doThrow(new IOException("test")).when(httpClient).execute(any());
-
- adapter.send("test-msg", "http://invalid-url");
-
- verify(httpClient).execute(any());
- verify(httpResponse, never()).getStatusLine();
- }
-}
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/validation/JSONValidatorTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/validation/JSONValidatorTest.java
deleted file mode 100644
index 30dfe065e..000000000
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/validation/JSONValidatorTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.pnfsimulator.simulator.validation;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-import com.github.fge.jsonschema.core.exceptions.InvalidSchemaException;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import java.io.IOException;
-import java.net.URL;
-import org.json.JSONObject;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-class JSONValidatorTest {
-
- private final static String VALID_SCHEMA_NAME = "valid-test-schema.json";
- private final static String INVALID_SCHEMA_NAME = "invalid-test-schema.json";
-
- private JSONValidator validator;
-
- @BeforeEach
- void setUp() {
- validator = new JSONValidator();
- }
-
- @Test
- void validate_should_not_throw_given_valid_json() throws ProcessingException, IOException, ValidationException {
- validator.validate(getValidJsonString(), getResourcePath(VALID_SCHEMA_NAME));
- }
-
- @Test
- void validate_should_not_throw_when_optional_parameter_missing()
- throws ProcessingException, IOException, ValidationException {
-
- String invalidJsonString = new JSONObject()
- .put("key1", "value1")
- .put("key2", "value2")
- .toString();
-
- validator.validate(invalidJsonString, getResourcePath(VALID_SCHEMA_NAME));
- }
-
- @Test
- void validate_should_throw_when_mandatory_parameter_missing() {
-
- String invalidJsonString = new JSONObject()
- .put("key1", "value1")
- .put("key3", "value3")
- .toString();
-
- assertThrows(
- ValidationException.class,
- () -> validator.validate(invalidJsonString, getResourcePath(VALID_SCHEMA_NAME)));
- }
-
- @Test
- void validate_should_throw_when_invalid_json_format() {
- String invalidJsonString = "{" +
- "\"key1\": \"value1\"" +
- "\"key2\": \"value2" +
- "}";
-
- assertThrows(
- IOException.class,
- () -> validator.validate(invalidJsonString, getResourcePath(VALID_SCHEMA_NAME)));
- }
-
- @Test
- void validate_should_throw_when_invalid_schema_format() {
- assertThrows(
- InvalidSchemaException.class,
- () -> validator.validate(getValidJsonString(), getResourcePath(INVALID_SCHEMA_NAME)));
- }
-
- @Test
- void validate_should_throw_when_invalid_schema_path() {
-
- assertThrows(
- IOException.class,
- () -> validator.validate(getValidJsonString(), "/not/existing/path/schema.json"));
- }
-
- private String getResourcePath(String schemaFileName) {
- URL result = getClass()
- .getClassLoader()
- .getResource(schemaFileName);
-
- if (result == null) {
- throw new IllegalArgumentException("Given file doesn't exist");
- } else {
- return result
- .toString()
- .replace("file:", "");
- }
- }
-
- private String getValidJsonString() {
- return new JSONObject()
- .put("key1", "value1")
- .put("key2", "value2")
- .put("key3", "value3")
- .toString();
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/invalid-test-schema.json b/test/mocks/pnfsimulator/src/test/resources/invalid-test-schema.json
deleted file mode 100644
index 8c37c822b..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/invalid-test-schema.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "type": "object",
- "$schema": "http://json-schema.org/draft-07/schema#",
- "properties": {
- "key1": {
- "type": "string"
- },
- "key2": {
- "type": "string"
- },
- "key3": {
- "type": "string"
- },
- "required": [
- "key1",
- "key2"
- ]
- }
-}
diff --git a/test/mocks/pnfsimulator/src/test/resources/logback-test.xml b/test/mocks/pnfsimulator/src/test/resources/logback-test.xml
deleted file mode 100644
index d7966fe60..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration complete="true" compact="true">
-
- <Property name="outputFilename" value="pnfsimulator_output"/>
- <Property name="log-path" value="${java.io.tmpdir}"/>
- <property name="maxFileSize" value="50MB"/>
- <property name="maxHistory" value="30"/>
- <property name="totalSizeCap" value="10GB"/>
-
- <appender name="Console" target="SYSTEM_OUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>%nopexception%logger
- |%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}
- |%level
- |%replace(%replace(%message){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%mdc){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%rootException){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%marker){'\t','\\\\t'}){'\n','\\\\n'}
- |%thread
- |%n</Pattern>
- </encoder>
- </appender>
-
- <appender name="ROLLING-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <encoder>
- <pattern>%nopexception%logger
- |%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}
- |%level
- |%replace(%replace(%message){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%mdc){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%rootException){'\t','\\\\t'}){'\n','\\\\n'}
- |%replace(%replace(%marker){'\t','\\\\t'}){'\n','\\\\n'}
- |%thread
- |%n</pattern>
- </encoder>
- <File>${log-path}/${outputFilename}.log</File>
- <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
- <FileNamePattern>${log-path}/${outputFilename}.%d{yyyy-MM-dd}.%i.log.zip</FileNamePattern>
- <MaxFileSize>${maxFileSize}</MaxFileSize>
- <MaxHistory>${maxHistory}</MaxHistory>
- <TotalSizeCap>${totalSizeCap}</TotalSizeCap>
- </rollingPolicy>
- </appender>
-
- <root level="info">
- <appender-ref ref="Console" />
- <appender-ref ref="ROLLING-FILE" />
- </root>
-</Configuration>
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/message/MessageProviderTest/notificationParams.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/message/MessageProviderTest/notificationParams.json
deleted file mode 100644
index b73c379a8..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/message/MessageProviderTest/notificationParams.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "notKey1": "notVal1",
- "notKey2": "notVal2",
- "notKey3": "notVal3",
- "notKey4": "notVal4"
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/message/MessageProviderTest/pnfRegistrationParams.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/message/MessageProviderTest/pnfRegistrationParams.json
deleted file mode 100644
index 95446bf80..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/message/MessageProviderTest/pnfRegistrationParams.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "pnfKey1": "pnfVal1",
- "pnfKey2": "pnfVal2",
- "pnfKey3": "pnfVal3",
- "pnfKey4": "pnfVal4"
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/rest/SimulatorControllerTest/incorrectJson.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/rest/SimulatorControllerTest/incorrectJson.json
deleted file mode 100644
index 682afac9f..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/rest/SimulatorControllerTest/incorrectJson.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "mes": {
- "vesServerUrl": "http://10.154.187.70:8080/eventListener/v5",
- "testDuration": "10",
- "messageInterval": "1"
- },
- "messageParams": {
- "sourceName": "val12",
- "sourceId": "val13",
- "reportingEntityName": "val14"
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/rest/SimulatorControllerTest/pnfRegistration.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/rest/SimulatorControllerTest/pnfRegistration.json
deleted file mode 100644
index a7bf487e7..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/rest/SimulatorControllerTest/pnfRegistration.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "simulatorParams": {
- "vesServerUrl": "http://10.154.187.70:8080/eventListener/v7",
- "testDuration": "10",
- "messageInterval": "1"
- },
- "commonEventHeaderParams": {
- "eventName": "val11",
- "nfNamingCode": "val12",
- "nfcNamingCode": "val13",
- "sourceName": "val14",
- "sourceId": "val15",
- "reportingEntityName": "val16"
- },
- "pnfRegistrationParams": {
- "SerialNumber": "val1",
- "VendorName": "val2",
- "OamIpv4Address": "val3",
- "OamIpv6Address": "val4",
- "Family": "val5",
- "ModelNumber": "val6",
- "SoftwareVersion": "val7"
- }
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams1.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams1.json
deleted file mode 100644
index eb9b4c156..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams1.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "pnfSerialNumber": "val1",
- "pnfVendorName": "val2",
- "pnfFamily": "val5",
- "pnfModelNumber": "val6",
- "pnfSoftwareVersion": "val7",
- "pnfType": "val8",
- "eventName": "val9",
- "nfNamingCode": "val10",
- "nfcNamingCode": "val11",
- "sourceName": "val12",
- "sourceId": "val13",
- "reportingEntityName": "val14"
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams2.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams2.json
deleted file mode 100644
index 9196caa30..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams2.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "pnfVendorName": "val2",
- "pnfOamIpv4Address": "val3",
- "pnfOamIpv6Address": "val4",
- "pnfFamily": "val5",
- "pnfModelNumber": "val6",
- "pnfSoftwareVersion": "val7",
- "pnfType": "val8",
- "eventName": "val9",
- "nfNamingCode": "val10",
- "nfcNamingCode": "val11",
- "sourceName": "val12",
- "sourceId": "val13",
- "reportingEntityName": "val14"
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams3.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams3.json
deleted file mode 100644
index e8734e6a0..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidPnfRegistrationParams3.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "pnfSerialNumber": "val1",
- "pnfOamIpv4Address": "val3",
- "pnfFamily": "val5",
- "pnfModelNumber": "val6",
- "pnfSoftwareVersion": "val7",
- "pnfType": "val8",
- "eventName": "val9",
- "nfNamingCode": "val10",
- "nfcNamingCode": "val11",
- "sourceName": "val12",
- "sourceId": "val13",
- "reportingEntityName": "val14"
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidSimulatorParams.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidSimulatorParams.json
deleted file mode 100644
index be7b79477..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/invalidSimulatorParams.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "vesServerUrl": "http://10.42.111.42:8080/eventListener/v5",
- "messageInterval": "1"
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validCommonEventHeaderParams.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validCommonEventHeaderParams.json
deleted file mode 100644
index e0f455045..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validCommonEventHeaderParams.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "eventName": "pnfRegistration_Nokia_5gDu",
- "nfNamingCode": "gNB",
- "nfcNamingCode": "oam",
- "sourceName": "NOK6061ZW3",
- "sourceId": "val13",
- "reportingEntityName": "NOK6061ZW3"
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validNotificationParams.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validNotificationParams.json
deleted file mode 100644
index f7f463d3d..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validNotificationParams.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "changeIdentifier": "PM_MEAS_FILES",
- "changeType": "FileReady",
- "arrayOfNamedHashMap": [
- {"name": "A20161221.1031-1041.bin.gz", "hashMap": {
- "location": "ftpes://192.169.0.1:22/ftp/rop/A20161224.1030-1045.bin.gz",
- "compression": "gzip",
- "fileformatType": "org.3GPP.32.435#measCollec",
- "fileFormatVersion": "V10"
- }
- },
- {"name": "A20161222.1042-1102.bin.gz", "hashMap": {
- "location": "ftpes://192.168.0.102:22/ftp/rop/A20161224.1045-1100.bin.gz",
- "compression": "gzip",
- "fileFormatType": "org.3GPP.32.435#measCollec",
- "fileFormatVersion": "V10"
- }
- }
- ]
-}
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validPnfRegistrationParams.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validPnfRegistrationParams.json
deleted file mode 100644
index b95f8e60a..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validPnfRegistrationParams.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "serialNumber": "6061ZW3",
- "vendorName": "Nokia",
- "oamV4IpAddress": "val3",
- "oamV6IpAddress": "val4",
- "unitFamily": "BBU",
- "modelNumber": "val6",
- "softwareVersion": "val7",
- "unitType": "val8"
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validSimulatorParams.json b/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validSimulatorParams.json
deleted file mode 100644
index 6485ee4a4..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/SimulatorFactoryTest/validSimulatorParams.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "vesServerUrl": "http://VES-HOST:VES-PORT/eventListener/v7",
- "testDuration": "10",
- "messageInterval": "1"
-} \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/src/test/resources/valid-test-schema.json b/test/mocks/pnfsimulator/src/test/resources/valid-test-schema.json
deleted file mode 100644
index 26e48a5e8..000000000
--- a/test/mocks/pnfsimulator/src/test/resources/valid-test-schema.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "type": "object",
- "$schema": "http://json-schema.org/draft-07/schema#",
- "properties": {
- "key1": {
- "type": "string"
- },
- "key2": {
- "type": "string"
- },
- "key3": {
- "type": "string"
- }
- },
- "required": [
- "key1",
- "key2"
- ]
-}