aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorMichal Banka <michal.banka@nokia.com>2021-02-08 12:42:52 +0100
committerMichal Banka <michal.banka@nokia.com>2021-02-11 03:13:24 +0100
commit7f7704977116ead5bc3ae8cba4afdf698d08bce7 (patch)
tree989ee772ab8c2b10e2b544485a4cc07b00cc5bbd /src/test
parentba2f6a95fb320238638b6a7bf7ddf07d8ef0d6bb (diff)
Add ves-openapi-manager implementation
Change-Id: I923fa43028c78989604547b365a3326a1f8e9548 Signed-off-by: Michal Banka <michal.banka@nokia.com> Issue-ID: DCAEGEN2-2572
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/config/DistributionClientConfigTest.java89
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/config/ValidatorPropertiesTest.java60
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/model/DistributionStatusMessageTest.java56
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/service/ServiceFunctionalTest.java94
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/service/notification/ArtifactsCollectorStatusSenderTest.java118
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/service/notification/ArtifactsCollectorTest.java106
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/service/notification/ClientCallbackTest.java153
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/service/notification/ValidationStatusSenderTest.java84
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/service/serialization/SchemaMapDeserializerTest.java84
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/service/serialization/VesEventsArtifactDeserializerTest.java73
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/service/testModel/ArtifactInfo.java121
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/service/testModel/Resource.java161
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/service/testModel/Service.java136
-rw-r--r--src/test/java/org/onap/ves/openapi/manager/service/validation/SchemaReferenceValidatorTest.java120
-rw-r--r--src/test/resources/test-schema-map.json14
-rw-r--r--src/test/resources/ves_artifact_invalid_stndDefined_events.yaml107
-rw-r--r--src/test/resources/ves_artifact_stndDefined_events.yaml107
17 files changed, 1683 insertions, 0 deletions
diff --git a/src/test/java/org/onap/ves/openapi/manager/config/DistributionClientConfigTest.java b/src/test/java/org/onap/ves/openapi/manager/config/DistributionClientConfigTest.java
new file mode 100644
index 0000000..9118f82
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/config/DistributionClientConfigTest.java
@@ -0,0 +1,89 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.config;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.context.properties.bind.BindResult;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
+import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class DistributionClientConfigTest {
+
+ @Test
+ void shouldCreateDistributionClientConfig() {
+ //given
+ String asdcAddress = "sdc-be.onap:8443";
+ String msgBusAddress = "message-router.onap";
+ String user = "dcae";
+ String password = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U";
+ Integer pollingInterval = 20;
+ Integer pollingTimeout = 20;
+ String consumerGroup = "ves-openapi-manager";
+ String environmentName = "AUTO";
+ String consumerID = "ves-openapi-manager";
+ Map<String, Object> properties = new HashMap<>();
+ properties.put("vesopenapimanager.distribution.asdcAddress", asdcAddress);
+ properties.put("vesopenapimanager.distribution.msgBusAddress", msgBusAddress);
+ properties.put("vesopenapimanager.distribution.user", user);
+ properties.put("vesopenapimanager.distribution.password", password);
+ properties.put("vesopenapimanager.distribution.pollingInterval", pollingInterval);
+ properties.put("vesopenapimanager.distribution.pollingTimeout", pollingTimeout);
+ properties.put("vesopenapimanager.distribution.consumerGroup", consumerGroup);
+ properties.put("vesopenapimanager.distribution.environmentName", environmentName);
+ properties.put("vesopenapimanager.distribution.consumerID", consumerID);
+ properties.put("vesopenapimanager.distribution.activateServerTLSAuth", false);
+ properties.put("vesopenapimanager.distribution.isFilterInEmptyResources", false);
+ properties.put("vesopenapimanager.distribution.isUseHttpsWithDmaap", false);
+ ConfigurationPropertySource source = new MapConfigurationPropertySource(properties);
+ Binder binder = new Binder(source);
+
+ //when
+ BindResult<DistributionClientConfig> result = binder.bind("vesopenapimanager.distribution", DistributionClientConfig.class);
+
+ //then
+ assertThat(result.isBound()).isTrue();
+ DistributionClientConfig config = result.get();
+ assertThat(config.getAsdcAddress()).isEqualTo(asdcAddress);
+ assertThat(config.getMsgBusAddress()).isEqualTo(List.of(msgBusAddress));
+ assertThat(config.getUser()).isEqualTo(user);
+ assertThat(config.getPassword()).isEqualTo(password);
+ assertThat(config.getPollingInterval()).isEqualTo(pollingInterval);
+ assertThat(config.getPollingTimeout()).isEqualTo(pollingTimeout);
+ assertThat(config.getRelevantArtifactTypes()).isEqualTo(Collections.singletonList("VES_EVENTS"));
+ assertThat(config.getConsumerGroup()).isEqualTo(consumerGroup);
+ assertThat(config.getEnvironmentName()).isEqualTo(environmentName);
+ assertThat(config.getConsumerID()).isEqualTo(consumerID);
+ assertThat(config.getKeyStorePath()).isNull();
+ assertThat(config.getKeyStorePassword()).isNull();
+ assertThat(config.activateServerTLSAuth()).isFalse();
+ assertThat(config.isFilterInEmptyResources()).isFalse();
+ assertThat(config.activateServerTLSAuth()).isFalse();
+ assertThat(config.isUseHttpsWithDmaap()).isFalse();
+ }
+}
diff --git a/src/test/java/org/onap/ves/openapi/manager/config/ValidatorPropertiesTest.java b/src/test/java/org/onap/ves/openapi/manager/config/ValidatorPropertiesTest.java
new file mode 100644
index 0000000..57b3725
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/config/ValidatorPropertiesTest.java
@@ -0,0 +1,60 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.config;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.context.properties.bind.BindResult;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
+import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ValidatorPropertiesTest {
+
+ @Test
+ void shouldCreateDistributionClientConfig() {
+ //given
+ String schemaMapPath = "schema-map.json";
+ String eventDomainPath = "/event/structure/commonEventHeader/structure/domain/value";
+ String eventSchemaReferencePath = "/event/structure/stndDefinedFields/structure/schemaReference/value";
+
+ Map<String, Object> properties = new HashMap<>();
+ properties.put("vesopenapimanager.validation.schemaMapPath", schemaMapPath);
+ properties.put("vesopenapimanager.validation.eventDomainPath", eventDomainPath);
+ properties.put("vesopenapimanager.validation.eventSchemaReferencePath", eventSchemaReferencePath);
+
+ ConfigurationPropertySource source = new MapConfigurationPropertySource(properties);
+ Binder binder = new Binder(source);
+
+ //when
+ BindResult<ValidatorProperties> result = binder.bind("vesopenapimanager.validation", ValidatorProperties.class);
+
+ //then
+ assertThat(result.isBound()).isTrue();
+ ValidatorProperties config = result.get();
+ assertThat(config.getSchemaMapPath()).isEqualTo(schemaMapPath);
+ assertThat(config.getEventDomainPath()).isEqualTo(eventDomainPath);
+ assertThat(config.getEventSchemaReferencePath()).isEqualTo(eventSchemaReferencePath);
+ }
+}
diff --git a/src/test/java/org/onap/ves/openapi/manager/model/DistributionStatusMessageTest.java b/src/test/java/org/onap/ves/openapi/manager/model/DistributionStatusMessageTest.java
new file mode 100644
index 0000000..e84b919
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/model/DistributionStatusMessageTest.java
@@ -0,0 +1,56 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.model;
+
+import org.junit.jupiter.api.Test;
+import org.onap.sdc.utils.DistributionStatusEnum;
+
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+
+public class DistributionStatusMessageTest {
+ @Test
+ void shouldCreateDistributionStatusMessage() {
+ //given
+ long timestamp = LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli();
+ String consumerId = "ves-consumer";
+ String artifactUrl = "http://artifact-url:1234/test";
+ String distributionId = "distribution-id";
+
+ //when
+ DistributionStatusMessage distributionStatusMessage = new DistributionStatusMessage(
+ artifactUrl,
+ distributionId,
+ consumerId,
+ timestamp,
+ DistributionStatusEnum.DOWNLOAD_OK);
+
+ //then
+ assertThat(distributionStatusMessage.getArtifactURL()).isEqualTo(artifactUrl);
+ assertThat(distributionStatusMessage.getDistributionID()).isEqualTo(distributionId);
+ assertThat(distributionStatusMessage.getConsumerID()).isEqualTo(consumerId);
+ assertThat(distributionStatusMessage.getTimestamp()).isEqualTo(timestamp);
+ assertThat(distributionStatusMessage.getStatus()).isEqualTo(DistributionStatusEnum.DOWNLOAD_OK);
+ }
+}
diff --git a/src/test/java/org/onap/ves/openapi/manager/service/ServiceFunctionalTest.java b/src/test/java/org/onap/ves/openapi/manager/service/ServiceFunctionalTest.java
new file mode 100644
index 0000000..a3beb4e
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/service/ServiceFunctionalTest.java
@@ -0,0 +1,94 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.Test;
+import org.onap.sdc.api.notification.INotificationData;
+import org.onap.sdc.http.SdcConnectorClient;
+import org.onap.sdc.impl.DistributionClientDownloadResultImpl;
+import org.onap.sdc.impl.DistributionClientImpl;
+import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.onap.ves.openapi.manager.config.DistributionClientConfig;
+import org.onap.ves.openapi.manager.config.ValidatorProperties;
+import org.onap.ves.openapi.manager.service.notification.ArtifactsCollectorStatusSender;
+import org.onap.ves.openapi.manager.service.notification.FinalStatusSender;
+import org.onap.ves.openapi.manager.service.notification.ValidationStatusSender;
+import org.onap.ves.openapi.manager.service.serialization.SchemaMapDeserializer;
+import org.onap.ves.openapi.manager.service.serialization.VesEventsArtifactDeserializer;
+import org.onap.ves.openapi.manager.service.testModel.Service;
+import org.onap.ves.openapi.manager.service.validation.ArtifactsValidator;
+import org.onap.ves.openapi.manager.service.validation.SchemaReferenceValidator;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class ServiceFunctionalTest {
+
+ private final DistributionClientImpl distributionClient = mock(DistributionClientImpl.class);
+ private final SdcConnectorClient sdcConnectorClient = mock(SdcConnectorClient.class);
+ private final DistributionClientConfig config = mock(DistributionClientConfig.class);
+ private final ValidatorProperties validatorProperties = mock(ValidatorProperties.class);
+
+ private final ObjectMapper objectMapper = new ObjectMapper();
+ private final VesEventsArtifactDeserializer vesEventsArtifactDeserializer = new VesEventsArtifactDeserializer(objectMapper);
+ private final SchemaMapDeserializer schemaMapDeserializer = new SchemaMapDeserializer(objectMapper);
+
+ private final List<ArtifactsValidator> validators = List.of(new SchemaReferenceValidator(vesEventsArtifactDeserializer, schemaMapDeserializer, validatorProperties));
+ private final ArtifactsCollector artifactsCollector = new ArtifactsCollector(sdcConnectorClient);
+ private final ArtifactsCollectorStatusSender artifactsCollectorStatusSender = new ArtifactsCollectorStatusSender(distributionClient);
+ private final ValidationStatusSender validationStatusSender = new ValidationStatusSender(distributionClient);
+ private final FinalStatusSender finalStatusSender = new FinalStatusSender(distributionClient);
+ private final ClientCallback clientCallback = new ClientCallback(validators, artifactsCollector, artifactsCollectorStatusSender, validationStatusSender, finalStatusSender);
+
+ private final INotificationData service = new Service();
+
+
+ @Test
+ void shouldNotThrowExceptionWhenCallingCallbackAndArtifactIsValid() throws IOException {
+ //given
+ byte[] payload = Files.readAllBytes(Paths.get("src/test/resources/ves_artifact_stndDefined_events.yaml"));
+ DistributionClientDownloadResultImpl message = new DistributionClientDownloadResultImpl(
+ DistributionActionResultEnum.SUCCESS, "message", "artifact-name", payload);
+ DistributionClientDownloadResultImpl responseStatus = new DistributionClientDownloadResultImpl(DistributionActionResultEnum.SUCCESS, "OK");
+
+ when(sdcConnectorClient.downloadArtifact(any())).thenReturn(message);
+ when(distributionClient.sendDownloadStatus(any())).thenReturn(responseStatus);
+ when(distributionClient.sendDeploymentStatus(any())).thenReturn(responseStatus);
+ when(distributionClient.getConfiguration()).thenReturn(config);
+ when(distributionClient.sendFinalDistrStatus(any())).thenReturn(responseStatus);
+ when(config.getConsumerID()).thenReturn("consumer-id");
+ when(validatorProperties.getSchemaMapPath()).thenReturn("src/test/resources/test-schema-map.json");
+ when(validatorProperties.getEventDomainPath()).thenReturn("/event/structure/commonEventHeader/structure/domain/value");
+ when(validatorProperties.getEventSchemaReferencePath()).thenReturn("/event/structure/stndDefinedFields/structure/schemaReference/value");
+
+ //when
+ //then
+ assertDoesNotThrow(() -> clientCallback.activateCallback(service));
+ }
+}
diff --git a/src/test/java/org/onap/ves/openapi/manager/service/notification/ArtifactsCollectorStatusSenderTest.java b/src/test/java/org/onap/ves/openapi/manager/service/notification/ArtifactsCollectorStatusSenderTest.java
new file mode 100644
index 0000000..377cc4b
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/service/notification/ArtifactsCollectorStatusSenderTest.java
@@ -0,0 +1,118 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.service.notification;
+
+import org.junit.jupiter.api.Test;
+import org.onap.sdc.api.consumer.IConfiguration;
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.results.IDistributionClientResult;
+import org.onap.sdc.impl.DistributionClientImpl;
+import org.onap.sdc.impl.DistributionClientResultImpl;
+import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.onap.sdc.utils.DistributionStatusEnum;
+import org.onap.ves.openapi.manager.config.DistributionClientConfig;
+import org.onap.ves.openapi.manager.model.DistributionStatusMessage;
+import org.onap.ves.openapi.manager.service.testModel.ArtifactInfo;
+
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class ArtifactsCollectorStatusSenderTest {
+
+ private final IConfiguration configuration = mock(IConfiguration.class);
+ private final DistributionClientImpl distributionClient = mock(DistributionClientImpl.class);
+ private final ArtifactsCollectorStatusSender sender = new ArtifactsCollectorStatusSender(distributionClient);
+
+ @Test
+ void shouldSuccessfullySendStatusToEachDownloadedArtifacts() {
+ //given
+ DistributionClientResultImpl expectedResponse = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, "sample-response-message");
+ List<DistributionClientResultImpl> expectedResponses = List.of(expectedResponse, expectedResponse);
+
+ ArtifactInfo artifact = new ArtifactInfo(DistributionClientConfig.VES_EVENTS_ARTIFACT_TYPE);
+ List<IArtifactInfo> artifacts = List.of(artifact, artifact);
+ String consumerId = "ves-consumer";
+
+ when(distributionClient.sendDownloadStatus(any())).thenReturn(expectedResponse);
+ when(distributionClient.getConfiguration()).thenReturn(configuration);
+ when(configuration.getConsumerID()).thenReturn(consumerId);
+
+ //when
+ List<IDistributionClientResult> responses = sender.sendDownloadOk("distribution-id", artifacts);
+
+ //then
+ assertThat(responses).isEqualTo(expectedResponses);
+ }
+
+ @Test
+ void shouldSendDownloadErrorStatusToEachDownloadedArtifacts() {
+ //given
+ DistributionClientResultImpl expectedResponse = new DistributionClientResultImpl(
+ DistributionActionResultEnum.GENERAL_ERROR, "sample-response-message");
+ List<DistributionClientResultImpl> expectedResponses = List.of(expectedResponse, expectedResponse);
+
+ ArtifactInfo artifact = new ArtifactInfo(DistributionClientConfig.VES_EVENTS_ARTIFACT_TYPE);
+ List<IArtifactInfo> artifacts = List.of(artifact, artifact);
+ String consumerId = "ves-consumer";
+ when(distributionClient.sendDownloadStatus(any(),any())).thenReturn(expectedResponse);
+ when(distributionClient.getConfiguration()).thenReturn(configuration);
+ when(configuration.getConsumerID()).thenReturn(consumerId);
+ long timestamp = LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli();
+
+ DistributionStatusMessage dm = new DistributionStatusMessage(
+ artifact.getArtifactURL(),
+ "distribution-id",
+ distributionClient.getConfiguration().getConsumerID(),
+ timestamp,
+ DistributionStatusEnum.DOWNLOAD_OK);
+
+ //when
+ List<IDistributionClientResult> responses = sender.sendDownloadError("distribution-id", artifacts);
+
+ //then
+ assertThat(responses).isEqualTo(expectedResponses);
+ assertThat(dm.getArtifactURL()).isEqualTo(artifact.getArtifactURL());
+ assertThat(dm.getDistributionID()).isEqualTo("distribution-id");
+ assertThat(dm.getTimestamp()).isEqualTo(timestamp);
+ assertThat(dm.getStatus()).isEqualTo(DistributionStatusEnum.DOWNLOAD_OK);
+ }
+
+ @Test
+ void shouldNotSendAnyStatusWhenNoArtifactsAreDownloaded() {
+ //given
+ List<DistributionClientResultImpl> expectedResponses = List.of();
+ List<IArtifactInfo> artifacts = List.of();
+
+ //when
+ List<IDistributionClientResult> responses = sender.sendDownloadOk("distribution-id", artifacts);
+
+ //then
+ assertThat(responses).isEqualTo(expectedResponses);
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/ves/openapi/manager/service/notification/ArtifactsCollectorTest.java b/src/test/java/org/onap/ves/openapi/manager/service/notification/ArtifactsCollectorTest.java
new file mode 100644
index 0000000..3da47f7
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/service/notification/ArtifactsCollectorTest.java
@@ -0,0 +1,106 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.service.notification;
+
+import org.junit.jupiter.api.Test;
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.http.SdcConnectorClient;
+import org.onap.sdc.impl.DistributionClientDownloadResultImpl;
+import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.onap.ves.openapi.manager.config.DistributionClientConfig;
+import org.onap.ves.openapi.manager.exceptions.ArtifactException;
+import org.onap.ves.openapi.manager.model.Artifact;
+import org.onap.ves.openapi.manager.service.ArtifactsCollector;
+import org.onap.ves.openapi.manager.service.testModel.ArtifactInfo;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class ArtifactsCollectorTest {
+
+ private static final String NOT_VES_ARTIFACT = "NOT_VES_ARTIFACT";
+ private final SdcConnectorClient sdcConnectorClient = mock(SdcConnectorClient.class);
+ private final ArtifactsCollector artifactsCollector = new ArtifactsCollector(sdcConnectorClient);
+
+ @Test
+ void shouldReturnArtifactsContentWhenVESArtifactsAreDistributed() throws IOException {
+ //given
+ IArtifactInfo vesArtifact = new ArtifactInfo(DistributionClientConfig.VES_EVENTS_ARTIFACT_TYPE);
+ List<IArtifactInfo> artifacts = List.of(vesArtifact);
+
+ byte[] payload = getVesArtifactPayload();
+ DistributionClientDownloadResultImpl artifactDownloadResult = new DistributionClientDownloadResultImpl(
+ DistributionActionResultEnum.SUCCESS, "sample-message", "artifact-name",
+ payload);
+ when(sdcConnectorClient.downloadArtifact(vesArtifact)).thenReturn(artifactDownloadResult);
+ List<Artifact> expectedArtifacts = List.of(new Artifact(vesArtifact, payload));
+
+ //when
+ List<Artifact> artifactContents = artifactsCollector.pullArtifacts(artifacts);
+
+ //then
+ assertThat(artifactContents).isEqualTo(expectedArtifacts);
+ }
+
+ @Test
+ void shouldNotReturnArtifactsContentWhenNoVESArtifactsAreDistributed() {
+ //given
+ IArtifactInfo notVesArtifact = new ArtifactInfo(NOT_VES_ARTIFACT);
+ List<IArtifactInfo> artifactsDefinitions = List.of(notVesArtifact);
+ List<Artifact> expectedArtifacts = List.of();
+
+ //when
+ List<Artifact> artifacts = artifactsCollector.pullArtifacts(artifactsDefinitions);
+
+ //then
+ assertThat(artifacts).isEqualTo(expectedArtifacts);
+ }
+
+ @Test
+ void shouldThrowExceptionWhenArtifactNameIsEmpty() {
+ //given
+ IArtifactInfo vesArtifact = new ArtifactInfo(DistributionClientConfig.VES_EVENTS_ARTIFACT_TYPE);
+ List<IArtifactInfo> artifacts = List.of(vesArtifact);
+
+ byte[] payload = new byte[0];
+ DistributionClientDownloadResultImpl artifactDownloadResult = new DistributionClientDownloadResultImpl(
+ DistributionActionResultEnum.SUCCESS, "sample-message", "",
+ payload);
+ when(sdcConnectorClient.downloadArtifact(vesArtifact)).thenReturn(artifactDownloadResult);
+
+ //when then
+ assertThrows(
+ ArtifactException.class,
+ () -> artifactsCollector.pullArtifacts(artifacts)
+ );
+ }
+
+ private byte[] getVesArtifactPayload() throws IOException {
+ return Files.readAllBytes(Paths.get("src/test/resources/ves_artifact_stndDefined_events.yaml"));
+ }
+}
diff --git a/src/test/java/org/onap/ves/openapi/manager/service/notification/ClientCallbackTest.java b/src/test/java/org/onap/ves/openapi/manager/service/notification/ClientCallbackTest.java
new file mode 100644
index 0000000..91dfda7
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/service/notification/ClientCallbackTest.java
@@ -0,0 +1,153 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.service.notification;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.notification.INotificationData;
+import org.onap.ves.openapi.manager.model.Artifact;
+import org.onap.ves.openapi.manager.model.ArtifactValidationResult;
+import org.onap.ves.openapi.manager.service.ArtifactsCollector;
+import org.onap.ves.openapi.manager.service.ClientCallback;
+import org.onap.ves.openapi.manager.service.testModel.Service;
+import org.onap.ves.openapi.manager.service.validation.ArtifactsValidator;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+class ClientCallbackTest {
+
+ private ArtifactsCollector artifactsCollector;
+ private ArtifactsCollectorStatusSender artifactsCollectorStatusSender;
+ private ValidationStatusSender validationStatusSender;
+ private FinalStatusSender finalStatusSender;
+ private ArtifactsValidator artifactsValidator;
+ private List<ArtifactsValidator> validators;
+ private ClientCallback callback;
+
+ @BeforeEach
+ void setUpMocks() {
+ artifactsCollector = mock(ArtifactsCollector.class);
+ artifactsCollectorStatusSender = mock(ArtifactsCollectorStatusSender.class);
+ validationStatusSender = mock(ValidationStatusSender.class);
+ finalStatusSender = mock(FinalStatusSender.class);
+ artifactsValidator = mock(ArtifactsValidator.class);
+ validators = new ArrayList<>();
+ validators.add(artifactsValidator);
+
+ callback = new ClientCallback(validators, artifactsCollector, artifactsCollectorStatusSender,
+ validationStatusSender, finalStatusSender);
+ }
+
+ @Test
+ void shouldNotValidateAnyArtifactsOrSendAnyStatusIfPulledArtifactsListIsEmpty() {
+ testClientCallback(0);
+ }
+
+ @Test
+ void shouldValidateArtifactUsingValidatorAndSendStatusIfPulledArtifactsListContainsOneArtifact() {
+ testClientCallback(1);
+ }
+
+ @Test
+ void shouldValidateArtifactsUsingValidatorAndSendStatusesIfPulledArtifactsListContainsMultipleArtifacts() {
+ testClientCallback(3);
+ }
+
+ @Test
+ void shouldValidateArtifactUsingMultipleValidatorsAndSendStatusIfPulledArtifactsListContainsOneArtifact() {
+ ArtifactsValidator extraArtifactsValidator = mock(ArtifactsValidator.class);
+ testClientCallback(1, extraArtifactsValidator);
+ }
+
+ @Test
+ void shouldValidateArtifactUsingMultipleValidatorsAndSendStatusIfPulledArtifactsListContainsMultipleArtifacts() {
+ ArtifactsValidator extraArtifactsValidator = mock(ArtifactsValidator.class);
+ testClientCallback(3, extraArtifactsValidator);
+ }
+
+ private void testClientCallback(int numberOfPulledArtefacts, ArtifactsValidator... extraValidators) {
+ // given
+ validators.addAll(Arrays.asList(extraValidators));
+ final INotificationData service = new Service(numberOfPulledArtefacts);
+ ExpectedTestParameters testParameters = setupCallbackTest(service);
+
+ // when
+ callback.activateCallback(service);
+
+ // then
+ verifyMockedMethodCalls(testParameters, numberOfPulledArtefacts);
+ for(ArtifactsValidator validator: extraValidators) {
+ verify(validator, times(1)).validate(eq(testParameters.getExpectedPulledArtifacts()));
+ }
+ }
+
+ private ExpectedTestParameters setupCallbackTest(INotificationData service) {
+ final List<IArtifactInfo> expectedArtifactsList = service.getResources().get(0).getArtifacts();
+
+ final List<Artifact> expectedPulledArtifacts = new ArrayList<>();
+ final List<ArtifactValidationResult> expectedValidationResults = new ArrayList<>();
+ for(IArtifactInfo artifactInfo: expectedArtifactsList) {
+ final Artifact artifact = setUpTestArtifact(artifactInfo);
+ expectedPulledArtifacts.add(artifact);
+ final ArtifactValidationResult expectedValidationResult = new ArtifactValidationResult(
+ artifactInfo, true, artifactInfo.getArtifactName() + " validated", artifactsValidator
+ );
+ expectedValidationResults.add(expectedValidationResult);
+ }
+
+ when(artifactsCollector.pullArtifacts(expectedArtifactsList)).thenReturn(expectedPulledArtifacts);
+ when(artifactsValidator.validate(expectedPulledArtifacts)).thenReturn(expectedValidationResults);
+
+ return new ExpectedTestParameters(expectedPulledArtifacts, expectedValidationResults, expectedArtifactsList);
+ }
+
+ private Artifact setUpTestArtifact(IArtifactInfo artifactInfo) {
+ final byte[] expectedArtifactContent = ("test content " + artifactInfo.getArtifactName()).getBytes();
+ return new Artifact(artifactInfo, expectedArtifactContent);
+ }
+
+ private void verifyMockedMethodCalls(ExpectedTestParameters testParameters, int numberOfPulledArtifacts) {
+ verify(artifactsCollector, times(1)).pullArtifacts(eq(testParameters.getExpectedArtifactsList()));
+ verify(artifactsCollectorStatusSender, times(numberOfPulledArtifacts)).sendDownloadOk(any(), eq(testParameters.getExpectedArtifactsList()));
+ verify(validationStatusSender, times(1)).send(any(), eq(testParameters.getExpectedValidationResults()));
+ validators.forEach(validator -> verify(validator, times(1)).validate(eq(testParameters.getExpectedPulledArtifacts())));
+ }
+
+ @Getter
+ @AllArgsConstructor
+ private static class ExpectedTestParameters {
+ final private List<Artifact> expectedPulledArtifacts;
+ final private List<ArtifactValidationResult> expectedValidationResults;
+ final private List<IArtifactInfo> expectedArtifactsList;
+ }
+}
diff --git a/src/test/java/org/onap/ves/openapi/manager/service/notification/ValidationStatusSenderTest.java b/src/test/java/org/onap/ves/openapi/manager/service/notification/ValidationStatusSenderTest.java
new file mode 100644
index 0000000..e4bb504
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/service/notification/ValidationStatusSenderTest.java
@@ -0,0 +1,84 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.service.notification;
+
+import org.junit.jupiter.api.Test;
+import org.onap.sdc.api.consumer.IConfiguration;
+import org.onap.sdc.api.results.IDistributionClientResult;
+import org.onap.sdc.impl.DistributionClientImpl;
+import org.onap.sdc.impl.DistributionClientResultImpl;
+import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.onap.ves.openapi.manager.config.DistributionClientConfig;
+import org.onap.ves.openapi.manager.model.ArtifactValidationResult;
+import org.onap.ves.openapi.manager.service.testModel.ArtifactInfo;
+import org.onap.ves.openapi.manager.service.validation.ArtifactsValidator;
+import org.onap.ves.openapi.manager.service.validation.SchemaReferenceValidator;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class ValidationStatusSenderTest {
+
+ private final ArtifactsValidator validator = mock(SchemaReferenceValidator.class);
+ private final IConfiguration configuration = mock(IConfiguration.class);
+ private final DistributionClientImpl distributionClient = mock(DistributionClientImpl.class);
+ private final ValidationStatusSender statusSender = new ValidationStatusSender(distributionClient);
+
+ @Test
+ void shouldSendValidationStatusForEachValidationResult() {
+ //given
+ String distributionId = "distribution-id";
+ String consumerId = "ves-consumer";
+
+ DistributionClientResultImpl sendingResult =
+ new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS, "sample-message");
+ List<IDistributionClientResult> expectedSendingResults = List.of(sendingResult, sendingResult);
+
+ ArtifactInfo artifact = new ArtifactInfo(DistributionClientConfig.VES_EVENTS_ARTIFACT_TYPE);
+ List<ArtifactValidationResult> validationResults = getValidationResults(artifact);
+
+ when(distributionClient.sendDeploymentStatus(any())).thenReturn(sendingResult);
+ when(distributionClient.sendDeploymentStatus(any(), anyString())).thenReturn(sendingResult);
+ when(distributionClient.getConfiguration()).thenReturn(configuration);
+ when(configuration.getConsumerID()).thenReturn(consumerId);
+
+ //when
+ List<IDistributionClientResult> sendingResults = statusSender.send(distributionId, validationResults);
+
+ //then
+ assertThat(sendingResults).isEqualTo(expectedSendingResults);
+
+ }
+
+ private List<ArtifactValidationResult> getValidationResults(ArtifactInfo artifactInfo) {
+ ArtifactValidationResult validationResultValid = new ArtifactValidationResult(artifactInfo, true,
+ "sample-message", validator);
+ ArtifactValidationResult validationResultInvalid = new ArtifactValidationResult(artifactInfo, false,
+ "sample-message", validator);
+ return List.of(validationResultValid, validationResultInvalid);
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/ves/openapi/manager/service/serialization/SchemaMapDeserializerTest.java b/src/test/java/org/onap/ves/openapi/manager/service/serialization/SchemaMapDeserializerTest.java
new file mode 100644
index 0000000..6b16c89
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/service/serialization/SchemaMapDeserializerTest.java
@@ -0,0 +1,84 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.service.serialization;
+
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.Test;
+import org.onap.ves.openapi.manager.model.SchemaMap;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class SchemaMapDeserializerTest {
+
+ final ObjectMapper objectMapper = new ObjectMapper();
+ private final SchemaMapDeserializer deserializer =
+ new SchemaMapDeserializer(objectMapper);
+
+ @Test
+ void shouldReturnSchemaMapFromFileWhenFileExists() {
+ //given
+ List<String> expectedPublicURLs = getExpectedPublicURLs();
+ List<String> expectedLocalURLs = getExpectedLocalURLs();
+ String schemaMapPath = "src/test/resources/test-schema-map.json";
+
+ //when
+ SchemaMap schemaMap = deserializer.getSchemaMapFromFile(schemaMapPath);
+
+ //then
+ assertThat(schemaMap.getMappings().size()).isEqualTo(3);
+ assertThat(schemaMap.getMappings().stream().map(SchemaMap.Mapping::getPublicURL).collect(Collectors.toList()))
+ .isEqualTo(expectedPublicURLs);
+ assertThat(schemaMap.getMappings().stream().map(SchemaMap.Mapping::getLocalURL).collect(Collectors.toList()))
+ .isEqualTo(expectedLocalURLs);
+ }
+
+ @Test
+ void shouldReturnEmptySchemaMapWhenFileDoesNotExist() {
+ //given
+ String schemaMapPath = "src/test/resources/not-existing-schema-map.yaml";
+
+ //when
+ SchemaMap schemaMap = deserializer.getSchemaMapFromFile(schemaMapPath);
+
+ //then
+ assertThat(schemaMap.getMappings().size()).isZero();
+ }
+
+ private List<String> getExpectedPublicURLs() {
+ return List.of(
+ "https://forge.3gpp.org/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerMeasJobCtlMnS.yaml",
+ "https://forge.3gpp.org/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerThresMonMnS.yaml",
+ "https://forge.3gpp.org/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerfDataStreamingMnS.yaml"
+ );
+ }
+
+ private List<String> getExpectedLocalURLs() {
+ return List.of(
+ "3gpp/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerMeasJobCtlMnS.yaml",
+ "3gpp/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerThresMonMnS.yaml",
+ "3gpp/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerfDataStreamingMnS.yaml"
+ );
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/ves/openapi/manager/service/serialization/VesEventsArtifactDeserializerTest.java b/src/test/java/org/onap/ves/openapi/manager/service/serialization/VesEventsArtifactDeserializerTest.java
new file mode 100644
index 0000000..6c35b18
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/service/serialization/VesEventsArtifactDeserializerTest.java
@@ -0,0 +1,73 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.service.serialization;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.function.Predicate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class VesEventsArtifactDeserializerTest {
+
+ private static final String EVENT_DOMAIN_PATH = "/event/structure/commonEventHeader/structure/domain/value";
+ private static final String STND_DEFINED_DOMAIN = "stndDefined";
+ private final ObjectMapper objectMapper = new ObjectMapper();
+ private final VesEventsArtifactDeserializer deserializer = new VesEventsArtifactDeserializer(objectMapper);
+
+
+ @Test
+ void shouldReturnObjectNodesPerEachYamlDocumentWhenByteCodeIsCorrect() throws IOException {
+ //given
+ byte[] bytecode = Files.readAllBytes(Paths.get("src/test/resources/ves_artifact_stndDefined_events.yaml"));
+ int expectedDocuments = 3;
+
+ //when
+ List<ObjectNode> objectNodes = deserializer.deserializeMultiDocumentYaml(bytecode);
+
+ //then
+ assertThat(objectNodes.size()).isEqualTo(expectedDocuments);
+ assertThat(objectNodes).anyMatch(isStndDefinedEvent());
+ }
+
+ @Test
+ void shouldReturnEmptyListWhenInvalidYamlByteCodeIsGiven() {
+ //given
+ byte[] invalidBytecode = new byte[] {'i','n','v','a','l','i', 'd'};
+ //when
+ List<ObjectNode> objectNodes = deserializer.deserializeMultiDocumentYaml(invalidBytecode);
+
+ //then
+ assertThat(objectNodes.size()).isZero();
+ }
+
+ private Predicate<ObjectNode> isStndDefinedEvent() {
+ return event -> event.at(EVENT_DOMAIN_PATH).asText()
+ .equals(STND_DEFINED_DOMAIN);
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/ves/openapi/manager/service/testModel/ArtifactInfo.java b/src/test/java/org/onap/ves/openapi/manager/service/testModel/ArtifactInfo.java
new file mode 100644
index 0000000..5c7ea56
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/service/testModel/ArtifactInfo.java
@@ -0,0 +1,121 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.service.testModel;
+
+import org.onap.sdc.api.notification.IArtifactInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class ArtifactInfo implements IArtifactInfo {
+
+ private final String artifactName;
+ private final String artifactType;
+ private final String artifactURL;
+ private String artifactChecksum;
+ private Integer artifactTimeout;
+ private String artifactDescription;
+ private String artifactVersion;
+ private String artifactUUID;
+ private IArtifactInfo generatedArtifact;
+ private List<IArtifactInfo> relatedArtifacts;
+
+ public ArtifactInfo(String artifactType) {
+ this.artifactName = "artifact-name";
+ this.artifactType = artifactType;
+ this.artifactURL = "http://artifact-url:1234/test";
+ }
+
+ private ArtifactInfo(IArtifactInfo iArtifactInfo) {
+ artifactName = iArtifactInfo.getArtifactName();
+ artifactType = iArtifactInfo.getArtifactType();
+ artifactURL = iArtifactInfo.getArtifactURL();
+ artifactChecksum = iArtifactInfo.getArtifactChecksum();
+ artifactDescription = iArtifactInfo.getArtifactDescription();
+ artifactTimeout = iArtifactInfo.getArtifactTimeout();
+ artifactVersion = iArtifactInfo.getArtifactVersion();
+ artifactUUID = iArtifactInfo.getArtifactUUID();
+ generatedArtifact = iArtifactInfo.getGeneratedArtifact();
+ relatedArtifacts = iArtifactInfo.getRelatedArtifacts();
+
+ }
+
+ @Override
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ @Override
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ @Override
+ public String getArtifactURL() {
+ return artifactURL;
+ }
+
+ @Override
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
+
+ @Override
+ public Integer getArtifactTimeout() {
+ return artifactTimeout;
+ }
+
+ @Override
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ @Override
+ public String getArtifactVersion() {
+ return artifactVersion;
+ }
+
+ @Override
+ public String getArtifactUUID() {
+ return artifactUUID;
+ }
+
+ @Override
+ public IArtifactInfo getGeneratedArtifact() {
+ return generatedArtifact;
+ }
+
+ @Override
+ public List<IArtifactInfo> getRelatedArtifacts() {
+ return relatedArtifacts;
+ }
+
+ public static List<ArtifactInfo> convertToArtifactInfoImpl(List<IArtifactInfo> list) {
+ List<ArtifactInfo> ret = new ArrayList<>();
+ if (list != null) {
+ for (IArtifactInfo artifactInfo : list) {
+ ret.add(new ArtifactInfo(artifactInfo));
+ }
+ }
+ return ret;
+ }
+}
diff --git a/src/test/java/org/onap/ves/openapi/manager/service/testModel/Resource.java b/src/test/java/org/onap/ves/openapi/manager/service/testModel/Resource.java
new file mode 100644
index 0000000..130de6f
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/service/testModel/Resource.java
@@ -0,0 +1,161 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.service.testModel;
+
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.notification.IResourceInstance;
+import org.onap.ves.openapi.manager.config.DistributionClientConfig;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class Resource implements IResourceInstance {
+
+ private String resourceInstanceName;
+ private String resourceCustomizationUUID;
+ private String resourceName;
+ private String resourceVersion;
+ private String resourceType;
+ private String resourceUUID;
+ private String resourceInvariantUUID;
+ private String category;
+ private String subcategory;
+ private List<ArtifactInfo> artifacts;
+
+ public Resource(int numberOfArtifacts) {
+ this.artifacts = Stream.generate(() -> new ArtifactInfo(DistributionClientConfig.VES_EVENTS_ARTIFACT_TYPE))
+ .limit(numberOfArtifacts)
+ .collect(Collectors.toList());
+ }
+
+ public Resource() {
+ this.artifacts = List.of(new ArtifactInfo(DistributionClientConfig.VES_EVENTS_ARTIFACT_TYPE));
+ }
+
+ private Resource(IResourceInstance resourceInstance) {
+ resourceInstanceName = resourceInstance.getResourceInstanceName();
+ resourceCustomizationUUID = resourceInstance.getResourceCustomizationUUID();
+ resourceName = resourceInstance.getResourceName();
+ resourceVersion = resourceInstance.getResourceVersion();
+ resourceType = resourceInstance.getResourceType();
+ resourceUUID = resourceInstance.getResourceUUID();
+ resourceInvariantUUID = resourceInstance.getResourceInvariantUUID();
+ category = resourceInstance.getCategory();
+ subcategory = resourceInstance.getSubcategory();
+ artifacts = ArtifactInfo.convertToArtifactInfoImpl(resourceInstance.getArtifacts());
+ }
+
+ public static List<Resource> convertToJsonContainer(List<IResourceInstance> resources) {
+ return resources.stream().map(Resource::new).collect(Collectors.toList());
+ }
+
+ @Override
+ public String getResourceInstanceName() {
+ return resourceInstanceName;
+ }
+
+ public void setResourceInstanceName(String resourceInstanceName) {
+ this.resourceInstanceName = resourceInstanceName;
+ }
+
+ @Override
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ @Override
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @Override
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ @Override
+ public String getResourceUUID() {
+ return resourceUUID;
+ }
+
+ public void setResourceUUID(String resourceUUID) {
+ this.resourceUUID = resourceUUID;
+ }
+
+ @Override
+ public List<IArtifactInfo> getArtifacts() {
+ return List.copyOf(artifacts);
+ }
+
+ public void setArtifacts(List<ArtifactInfo> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ public List<ArtifactInfo> getArtifactsImpl() {
+ return artifacts;
+ }
+
+ @Override
+ public String getResourceInvariantUUID() {
+ return resourceInvariantUUID;
+ }
+
+ public void setResourceInvariantUUID(String resourceInvariantUUID) {
+ this.resourceInvariantUUID = resourceInvariantUUID;
+ }
+
+ public String getResourceCustomizationUUID() {
+ return resourceCustomizationUUID;
+ }
+
+ public void setResourceCustomizationUUID(String resourceCustomizationUUID) {
+ this.resourceCustomizationUUID = resourceCustomizationUUID;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getSubcategory() {
+ return subcategory;
+ }
+
+ public void setSubcategory(String subcategory) {
+ this.subcategory = subcategory;
+ }
+}
diff --git a/src/test/java/org/onap/ves/openapi/manager/service/testModel/Service.java b/src/test/java/org/onap/ves/openapi/manager/service/testModel/Service.java
new file mode 100644
index 0000000..0dae772
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/service/testModel/Service.java
@@ -0,0 +1,136 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.service.testModel;
+
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.notification.INotificationData;
+import org.onap.sdc.api.notification.IResourceInstance;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Service implements INotificationData {
+
+ private String distributionID;
+ private String serviceName;
+ private String serviceVersion;
+ private String serviceUUID;
+ private String serviceDescription;
+ private String serviceInvariantUUID;
+ private List<Resource> resources;
+ private List<ArtifactInfo> serviceArtifacts;
+ private String workloadContext;
+
+ public Service(int numberOfArtifacts) {
+ this.resources = List.of(new Resource(numberOfArtifacts));
+ this.serviceUUID = "UUID";
+ this.serviceName = "testService";
+ }
+
+ public Service() {
+ this.resources = List.of(new Resource());
+ this.serviceUUID = "UUID";
+ this.serviceName = "testService";
+ }
+
+ @Override
+ public String getDistributionID() {
+ return distributionID;
+ }
+
+ @Override
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ @Override
+ public String getServiceVersion() {
+ return serviceVersion;
+ }
+
+ @Override
+ public String getServiceUUID() {
+ return serviceUUID;
+ }
+
+ public String getServiceDescription() {
+ return serviceDescription;
+ }
+
+ @Override
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ @Override
+ public void setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+
+ @Override
+ public String toString() {
+ return "NotificationDataImpl [distributionID=" + distributionID + ", serviceName=" + serviceName
+ + ", serviceVersion=" + serviceVersion + ", serviceUUID=" + serviceUUID + ", serviceDescription="
+ + serviceDescription + ", serviceInvariantUUID=" + serviceInvariantUUID + ", resources=" + resources
+ + ", serviceArtifacts=" + serviceArtifacts + ", workloadContext=" + workloadContext + "]";
+ }
+
+ @Override
+ public List<IResourceInstance> getResources() {
+ return List.copyOf(resources);
+ }
+
+ @Override
+ public List<IArtifactInfo> getServiceArtifacts() {
+ return List.copyOf(serviceArtifacts);
+ }
+
+ @Override
+ public String getServiceInvariantUUID() {
+ return serviceInvariantUUID;
+ }
+
+ @Override
+ public IArtifactInfo getArtifactMetadataByUUID(String artifactUUID) {
+ IArtifactInfo ret = findArtifactInfoByUUID(artifactUUID, serviceArtifacts);
+ if (ret == null && resources != null) {
+ for (Resource currResourceInstance : resources) {
+ ret = findArtifactInfoByUUID(artifactUUID, currResourceInstance.getArtifactsImpl());
+ if (ret != null) {
+ break;
+ }
+ }
+ }
+ return ret;
+ }
+
+ private IArtifactInfo findArtifactInfoByUUID(String artifactUUID, List<ArtifactInfo> listToCheck) {
+ IArtifactInfo ret = null;
+ if (listToCheck != null) {
+ for (IArtifactInfo curr : listToCheck) {
+ if (curr.getArtifactUUID().equals(artifactUUID)) {
+ ret = curr;
+ break;
+ }
+ }
+ }
+ return ret;
+ }
+}
diff --git a/src/test/java/org/onap/ves/openapi/manager/service/validation/SchemaReferenceValidatorTest.java b/src/test/java/org/onap/ves/openapi/manager/service/validation/SchemaReferenceValidatorTest.java
new file mode 100644
index 0000000..fc17564
--- /dev/null
+++ b/src/test/java/org/onap/ves/openapi/manager/service/validation/SchemaReferenceValidatorTest.java
@@ -0,0 +1,120 @@
+/*
+ * ============LICENSE_START=======================================================
+ * VES-OPENAPI-MANAGER
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. 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.ves.openapi.manager.service.validation;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.logging.log4j.util.Strings;
+import org.junit.jupiter.api.Test;
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.ves.openapi.manager.config.DistributionClientConfig;
+import org.onap.ves.openapi.manager.config.ValidatorProperties;
+import org.onap.ves.openapi.manager.model.Artifact;
+import org.onap.ves.openapi.manager.model.ArtifactValidationResult;
+import org.onap.ves.openapi.manager.service.serialization.SchemaMapDeserializer;
+import org.onap.ves.openapi.manager.service.serialization.VesEventsArtifactDeserializer;
+import org.onap.ves.openapi.manager.service.testModel.ArtifactInfo;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class SchemaReferenceValidatorTest {
+
+ private final ObjectMapper objectMapper = new ObjectMapper();
+ private final VesEventsArtifactDeserializer vesEventsArtifactDeserializer =
+ new VesEventsArtifactDeserializer(objectMapper);
+ private final SchemaMapDeserializer schemaMapDeserializer = new SchemaMapDeserializer(objectMapper);
+ private final String schemaMapPath = "src/test/resources/test-schema-map.json";
+ private final String eventDomain = "/event/structure/commonEventHeader/structure/domain/value";
+ private final String schemaReference = "/event/structure/stndDefinedFields/structure/schemaReference/value";
+ private final ValidatorProperties validatorProperties = mock(ValidatorProperties.class);
+
+ private final SchemaReferenceValidator validator = new SchemaReferenceValidator(vesEventsArtifactDeserializer,
+ schemaMapDeserializer, validatorProperties);
+
+ @Test
+ void shouldReturnSuccessValidationResultWhenValidVesArtifactIsGiven() throws IOException {
+ //given
+ ArtifactInfo artifactInfo = new ArtifactInfo(DistributionClientConfig.VES_EVENTS_ARTIFACT_TYPE);
+ List<Artifact> artifacts = getArtifacts(artifactInfo,
+ "src/test/resources/ves_artifact_stndDefined_events.yaml");
+ List<ArtifactValidationResult> expectedValidationResults =
+ getExpectedResults(artifactInfo, true, Strings.EMPTY);
+
+ when(validatorProperties.getSchemaMapPath()).thenReturn(schemaMapPath);
+ when(validatorProperties.getEventDomainPath()).thenReturn(eventDomain);
+ when(validatorProperties.getEventSchemaReferencePath()).thenReturn(schemaReference);
+
+ //when
+ List<ArtifactValidationResult> validationResults = validator.validate(artifacts);
+
+ //then
+ assertThat(validationResults).isEqualTo(expectedValidationResults);
+ }
+
+ @Test
+ void shouldReturnFailedValidationResultWhenInvalidVesArtifactIsGiven() throws IOException {
+ //given
+ ArtifactInfo artifactInfo = new ArtifactInfo(DistributionClientConfig.VES_EVENTS_ARTIFACT_TYPE);
+ List<Artifact> artifacts = getArtifacts(artifactInfo,
+ "src/test/resources/ves_artifact_invalid_stndDefined_events.yaml");
+ List<ArtifactValidationResult> expectedValidationResults = getExpectedResults(artifactInfo, false,
+ SchemaReferenceValidator.SCHEMA_REFERENCE_ERROR_MESSAGE);
+
+ when(validatorProperties.getSchemaMapPath()).thenReturn(schemaMapPath);
+ when(validatorProperties.getEventDomainPath()).thenReturn(eventDomain);
+ when(validatorProperties.getEventSchemaReferencePath()).thenReturn(schemaReference);
+
+ //when
+ List<ArtifactValidationResult> validationResults = validator.validate(artifacts);
+ List<String> validationResultsMessages =
+ validationResults.stream()
+ .map(result -> SchemaReferenceValidator.SCHEMA_REFERENCE_ERROR_MESSAGE)
+ .collect(Collectors.toList());
+
+ //then
+ assertThat(validationResults).usingElementComparatorIgnoringFields("message")
+ .isEqualTo(expectedValidationResults);
+ assertThat(validationResultsMessages)
+ .isNotEmpty()
+ .allMatch(message -> message.contains(SchemaReferenceValidator.SCHEMA_REFERENCE_ERROR_MESSAGE));
+ }
+
+ private List<Artifact> getArtifacts(IArtifactInfo artifactInfo, String artifactFilePath) throws IOException {
+ Path path = Paths.get(artifactFilePath);
+ byte[] artifactByteCode = Files.readAllBytes(path);
+ Artifact artifact = new Artifact(artifactInfo, artifactByteCode);
+ return List.of(artifact);
+ }
+
+ private List<ArtifactValidationResult> getExpectedResults(IArtifactInfo artifactInfo, boolean isValid, String message) {
+ ArtifactValidationResult result = new ArtifactValidationResult(artifactInfo, isValid,
+ message, validator);
+ return List.of(result);
+ }
+} \ No newline at end of file
diff --git a/src/test/resources/test-schema-map.json b/src/test/resources/test-schema-map.json
new file mode 100644
index 0000000..2317f9f
--- /dev/null
+++ b/src/test/resources/test-schema-map.json
@@ -0,0 +1,14 @@
+[
+ {
+ "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerMeasJobCtlMnS.yaml",
+ "localURL": "3gpp/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerMeasJobCtlMnS.yaml"
+ },
+ {
+ "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerThresMonMnS.yaml",
+ "localURL": "3gpp/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerThresMonMnS.yaml"
+ },
+ {
+ "publicURL": "https://forge.3gpp.org/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerfDataStreamingMnS.yaml",
+ "localURL": "3gpp/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerfDataStreamingMnS.yaml"
+ }
+] \ No newline at end of file
diff --git a/src/test/resources/ves_artifact_invalid_stndDefined_events.yaml b/src/test/resources/ves_artifact_invalid_stndDefined_events.yaml
new file mode 100644
index 0000000..08d4716
--- /dev/null
+++ b/src/test/resources/ves_artifact_invalid_stndDefined_events.yaml
@@ -0,0 +1,107 @@
+---
+event:
+ presence: required
+ action: [ any, any, null, null, null ]
+ comment: "
+ ALARM NAME: LogHasReachedFullCapacity,
+ ALARM DESCRIPTION: 'Log Has Reached Full Capacity',
+ ALARM EFFECT: 'See alarm OPI x/2223-ABC 123 4567/1 Uen',
+ MANAGED OBJECT CLASSES: Log,
+ EVENT TYPE: 'PROCESSINGERRORALARM',
+ PROBABLE CAUSE: 'FileError',
+ PROPOSED REPAIR ACTIONS: 'See alarm OPI x/3334-ABC 123 4567/1 Uen',
+ CLEARING TYPE: Automatic
+ "
+ structure:
+ commonEventHeader:
+ presence: required
+ structure:
+ version: {presence: required, value: 4.0.1}
+ vesEventListenerVersion: {presence: required, value: 7.0.1}
+ domain: {presence: required, value: fault}
+ eventName: {presence: required, value: Fault_MyPnf-Acme_LogHasReachedFullCapacity}
+ eventId: {presence: required}
+ sequence: {presence: required}
+ priority: {presence: required, value: Normal}
+ reportingEntityName: {presence: required}
+ sourceName: {presence: required}
+ nfVendorName: {presence: required, value: Acme}
+ startEpochMicrosec: {presence: required}
+ lastEpochMicrosec: {presence: required}
+ timeZoneOffset: {presence: required}
+ faultFields:
+ presence: required
+ structure:
+ faultFieldsVersion: {presence: required, value: 4.0}
+ alarmCondition: {presence: required, value: 'LogHasReachedFullCapacity'}
+ eventCategory: {presence: required, value: 'PROCESSINGERRORALARM'}
+ eventSourceType: {presence: required}
+ specificProblem: {presence: required, value: 'Log Has Reached Full Capacity'}
+ eventSeverity: {presence: required}
+ vfStatus: {presence: required, value: Active}
+ alarmAdditionalInformation: {presence: required, structure: {
+ keyValuePair: {presence: required, structure: {key: {presence: required, value: source},value: {presence: required}}},
+ keyValuePair: {presence: required, structure: {key: {presence: required, value: probableCause},value: {presence: required, value: 'FileError'}}},
+ keyValuePair: {presence: required, structure: {key: {presence: required, value: additionalText},value: {presence: optional}}},
+ keyValuePair: {presence: required, structure: {key: {presence: required, value: additionalInfo},value: {presence: optional}}}}
+ }
+...
+---
+event:
+ presence: required
+ comment: "stndDefined event to support 3GPP FaultSupervision NotifyNewAlarm notification"
+ structure:
+ commonEventHeader:
+ presence: required
+ structure:
+ domain: {presence: required, value: stndDefined}
+ eventName: {presence: required, value: stndDefined-gNB-Nokia-Notification}
+ priority: {presence: required, value: Normal}
+ eventId: {presence: required}
+ reportingEntityId: {presence: required}
+ reportingEntityName: {presence: required}
+ sequence: {presence: required, value: 0}
+ sourceId: {presence: required}
+ sourceName: {presence: required}
+ version: {presence: required, value: 4.1}
+ vesEventListenerVersion: {presence: required, value: 7.2}
+ startEpochMicrosec: {presence: required}
+ lastEpochMicrosec: {presence: required}
+ stndDefinedNamespace: {presence: required, value: "3GPP-FaultSupervision"}
+ stndDefinedFields:
+ presence: required
+ structure:
+ schemaReference: { presence: required, value: "https://forge.3gpp.org/rep/invalid" }
+ data: {presence: required}
+ stndDefinedFieldsVersion: {presence: required, value: "1.0"}
+
+...
+---
+event:
+ presence: required
+ comment: "stndDefined event to support 3GPP FaultSupervision NotifyNewAlarm notification"
+ structure:
+ commonEventHeader:
+ presence: required
+ structure:
+ domain: {presence: required, value: stndDefined}
+ eventName: {presence: required, value: stndDefined-gNB-Nokia-Notification}
+ priority: {presence: required, value: Normal}
+ eventId: {presence: required}
+ reportingEntityId: {presence: required}
+ reportingEntityName: {presence: required}
+ sequence: {presence: required, value: 0}
+ sourceId: {presence: required}
+ sourceName: {presence: required}
+ version: {presence: required, value: 4.1}
+ vesEventListenerVersion: {presence: required, value: 7.2}
+ startEpochMicrosec: {presence: required}
+ lastEpochMicrosec: {presence: required}
+ stndDefinedNamespace: {presence: required, value: "3GPP-FaultSupervision"}
+ stndDefinedFields:
+ presence: required
+ structure:
+ schemaReference: { presence: required, value: ["https://forge.3gpp.org/rep/sa5/MnS/tree/another_invalid.yaml", "https://forge.3gpp.org/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerfDataStreamingMnS.yaml"] }
+ data: {presence: required}
+ stndDefinedFieldsVersion: {presence: required, value: "1.0"}
+... \ No newline at end of file
diff --git a/src/test/resources/ves_artifact_stndDefined_events.yaml b/src/test/resources/ves_artifact_stndDefined_events.yaml
new file mode 100644
index 0000000..11f805b
--- /dev/null
+++ b/src/test/resources/ves_artifact_stndDefined_events.yaml
@@ -0,0 +1,107 @@
+---
+event:
+ presence: required
+ action: [ any, any, null, null, null ]
+ comment: "
+ ALARM NAME: LogHasReachedFullCapacity,
+ ALARM DESCRIPTION: 'Log Has Reached Full Capacity',
+ ALARM EFFECT: 'See alarm OPI x/2223-ABC 123 4567/1 Uen',
+ MANAGED OBJECT CLASSES: Log,
+ EVENT TYPE: 'PROCESSINGERRORALARM',
+ PROBABLE CAUSE: 'FileError',
+ PROPOSED REPAIR ACTIONS: 'See alarm OPI x/3334-ABC 123 4567/1 Uen',
+ CLEARING TYPE: Automatic
+ "
+ structure:
+ commonEventHeader:
+ presence: required
+ structure:
+ version: {presence: required, value: 4.0.1}
+ vesEventListenerVersion: {presence: required, value: 7.0.1}
+ domain: {presence: required, value: fault}
+ eventName: {presence: required, value: Fault_MyPnf-Acme_LogHasReachedFullCapacity}
+ eventId: {presence: required}
+ sequence: {presence: required}
+ priority: {presence: required, value: Normal}
+ reportingEntityName: {presence: required}
+ sourceName: {presence: required}
+ nfVendorName: {presence: required, value: Acme}
+ startEpochMicrosec: {presence: required}
+ lastEpochMicrosec: {presence: required}
+ timeZoneOffset: {presence: required}
+ faultFields:
+ presence: required
+ structure:
+ faultFieldsVersion: {presence: required, value: 4.0}
+ alarmCondition: {presence: required, value: 'LogHasReachedFullCapacity'}
+ eventCategory: {presence: required, value: 'PROCESSINGERRORALARM'}
+ eventSourceType: {presence: required}
+ specificProblem: {presence: required, value: 'Log Has Reached Full Capacity'}
+ eventSeverity: {presence: required}
+ vfStatus: {presence: required, value: Active}
+ alarmAdditionalInformation: {presence: required, structure: {
+ keyValuePair: {presence: required, structure: {key: {presence: required, value: source},value: {presence: required}}},
+ keyValuePair: {presence: required, structure: {key: {presence: required, value: probableCause},value: {presence: required, value: 'FileError'}}},
+ keyValuePair: {presence: required, structure: {key: {presence: required, value: additionalText},value: {presence: optional}}},
+ keyValuePair: {presence: required, structure: {key: {presence: required, value: additionalInfo},value: {presence: optional}}}}
+ }
+...
+---
+event:
+ presence: required
+ comment: "stndDefined event to support 3GPP FaultSupervision NotifyNewAlarm notification"
+ structure:
+ commonEventHeader:
+ presence: required
+ structure:
+ domain: {presence: required, value: stndDefined}
+ eventName: {presence: required, value: stndDefined-gNB-Nokia-Notification}
+ priority: {presence: required, value: Normal}
+ eventId: {presence: required}
+ reportingEntityId: {presence: required}
+ reportingEntityName: {presence: required}
+ sequence: {presence: required, value: 0}
+ sourceId: {presence: required}
+ sourceName: {presence: required}
+ version: {presence: required, value: 4.1}
+ vesEventListenerVersion: {presence: required, value: 7.2}
+ startEpochMicrosec: {presence: required}
+ lastEpochMicrosec: {presence: required}
+ stndDefinedNamespace: {presence: required, value: "3GPP-FaultSupervision"}
+ stndDefinedFields:
+ presence: required
+ structure:
+ schemaReference: { presence: required, value: "https://forge.3gpp.org/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerMeasJobCtlMnS.yaml" }
+ data: {presence: required}
+ stndDefinedFieldsVersion: {presence: required, value: "1.0"}
+
+...
+---
+event:
+ presence: required
+ comment: "stndDefined event to support 3GPP FaultSupervision NotifyNewAlarm notification"
+ structure:
+ commonEventHeader:
+ presence: required
+ structure:
+ domain: {presence: required, value: stndDefined}
+ eventName: {presence: required, value: stndDefined-gNB-Nokia-Notification}
+ priority: {presence: required, value: Normal}
+ eventId: {presence: required}
+ reportingEntityId: {presence: required}
+ reportingEntityName: {presence: required}
+ sequence: {presence: required, value: 0}
+ sourceId: {presence: required}
+ sourceName: {presence: required}
+ version: {presence: required, value: 4.1}
+ vesEventListenerVersion: {presence: required, value: 7.2}
+ startEpochMicrosec: {presence: required}
+ lastEpochMicrosec: {presence: required}
+ stndDefinedNamespace: {presence: required, value: "3GPP-FaultSupervision"}
+ stndDefinedFields:
+ presence: required
+ structure:
+ schemaReference: { presence: required, value: ["https://forge.3gpp.org/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerThresMonMnS.yaml", "https://forge.3gpp.org/rep/sa5/MnS/tree/SA88-Rel16/OpenAPI/PerfDataStreamingMnS.yaml"] }
+ data: {presence: required}
+ stndDefinedFieldsVersion: {presence: required, value: "1.0"}
+... \ No newline at end of file