summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/java/org/onap/aai/modelloader/config/ModelLoaderConfigTest.java412
-rw-r--r--src/test/java/org/onap/aai/modelloader/notification/DistributionStatusMsgTest.java43
-rw-r--r--src/test/java/org/onap/aai/modelloader/notification/EventCallbackTest.java613
-rw-r--r--src/test/java/org/onap/aai/modelloader/notification/TestConfiguration.java295
-rw-r--r--src/test/java/org/onap/aai/modelloader/service/ModelLoaderServiceTest.java87
5 files changed, 1314 insertions, 136 deletions
diff --git a/src/test/java/org/onap/aai/modelloader/config/ModelLoaderConfigTest.java b/src/test/java/org/onap/aai/modelloader/config/ModelLoaderConfigTest.java
index b30b00d..bd10634 100644
--- a/src/test/java/org/onap/aai/modelloader/config/ModelLoaderConfigTest.java
+++ b/src/test/java/org/onap/aai/modelloader/config/ModelLoaderConfigTest.java
@@ -1,136 +1,276 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property.
- * Copyright © 2017 Amdocs
- * 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=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.onap.aai.modelloader.config;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.List;
-import java.util.Properties;
-
-import org.eclipse.jetty.util.security.Password;
-import org.junit.Test;
-import org.onap.aai.modelloader.config.ModelLoaderConfig;
-import org.onap.aai.modelloader.restclient.AaiRestClient;
-import org.openecomp.sdc.utils.ArtifactTypeEnum;
-
-public class ModelLoaderConfigTest {
-
- @Test
- public void testYangModelArtifactType() {
- Properties props = new Properties();
- props.setProperty("ml.distribution.ARTIFACT_TYPES",
- "MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG");
- ModelLoaderConfig config = new ModelLoaderConfig(props, null);
-
- List<String> types = config.getRelevantArtifactTypes();
-
- System.out.println("ArtifactType: " + types.get(0));
- assertEquals(0,
- types.get(0).compareToIgnoreCase(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.toString()));
-
- System.out.println("ArtifactType: " + types.get(1));
- assertEquals(0, types.get(1).compareToIgnoreCase(ArtifactTypeEnum.MODEL_QUERY_SPEC.toString()));
-
- System.out.println("ArtifactType: " + types.get(2));
- assertEquals(0, types.get(2).compareToIgnoreCase(ArtifactTypeEnum.VNF_CATALOG.toString()));
-
- assertEquals(3, types.size());
- }
-
- @Test
- public void testDecryptPassword() {
- Properties props = new Properties();
- String testPass = "youshallnotpass";
- String encryptedTestPass = Password.obfuscate(testPass);
-
- System.out.println("Encrypt " + testPass + " ==> " + encryptedTestPass);
-
- props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_PASSWORD, encryptedTestPass);
- ModelLoaderConfig config = new ModelLoaderConfig(props, null);
-
- assertEquals(testPass, config.getPassword());
- }
-
- @Test
- public void testDecryptKeystorePassword() {
- Properties props = new Properties();
- String testPass = "youshallnotpass";
- String encryptedTestPass = Password.obfuscate(testPass);
-
- System.out.println("Encrypt " + testPass + " ==> " + encryptedTestPass);
-
- props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD, encryptedTestPass);
- ModelLoaderConfig config = new ModelLoaderConfig(props, null);
-
- assertEquals(testPass, config.getKeyStorePassword());
- }
-
- @Test
- public void testDecryptAAIPassword() {
-
- Properties props = new Properties();
- String testPassword = "myvoiceismypassword";
- String encryptedTestPassword = Password.obfuscate(testPassword);
-
- props.put(ModelLoaderConfig.PROP_AAI_AUTHENTICATION_PASSWORD, encryptedTestPassword);
- ModelLoaderConfig config = new ModelLoaderConfig(props, null);
-
- assertEquals(testPassword, config.getAaiAuthenticationPassword());
- }
-
- @Test
- public void testNoAAIAuth() throws IOException {
-
- Properties props = new Properties();
- props.load(
- new FileInputStream("src/test/resources/model-loader-empty-auth-password.properties"));
-
- ModelLoaderConfig config = new ModelLoaderConfig(props, null);
- AaiRestClient aaiClient = new AaiRestClient(config);
-
- assertFalse("Empty AAI Password should result in no basic authentication",
- aaiClient.useBasicAuth());
-
- props.load(new FileInputStream("src/test/resources/model-loader-no-auth-password.properties"));
- config = new ModelLoaderConfig(props, null);
- aaiClient = new AaiRestClient(config);
-
- assertFalse("No AAI Password should result in no basic authentication",
- aaiClient.useBasicAuth());
- }
-
- @Test
- public void testGetUrls() {
- Properties props = new Properties();
- props.put(ModelLoaderConfig.PROP_AAI_MODEL_RESOURCE_URL, "/aai/v*/service-design-and-creation/models/model/");
- props.put(ModelLoaderConfig.PROP_AAI_NAMED_QUERY_RESOURCE_URL, "/aai/v*/service-design-and-creation/named-queries/named-query/");
- ModelLoaderConfig config = new ModelLoaderConfig(props, null);
-
- assertEquals("/aai/v9/service-design-and-creation/models/model/", config.getAaiModelUrl("v9"));
- assertEquals("/aai/v10/service-design-and-creation/named-queries/named-query/", config.getAaiNamedQueryUrl("v10"));
- }
-}
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.modelloader.config;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.jetty.util.security.Password;
+import org.junit.Test;
+import org.onap.aai.modelloader.config.ModelLoaderConfig;
+import org.onap.aai.modelloader.restclient.AaiRestClient;
+import org.openecomp.sdc.utils.ArtifactTypeEnum;
+
+public class ModelLoaderConfigTest {
+
+ @Test
+ public void testYangModelArtifactType() {
+ Properties props = new Properties();
+ props.setProperty("ml.distribution.ARTIFACT_TYPES",
+ "MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+
+ List<String> types = config.getRelevantArtifactTypes();
+
+ System.out.println("ArtifactType: " + types.get(0));
+ assertEquals(0,
+ types.get(0).compareToIgnoreCase(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.toString()));
+
+ System.out.println("ArtifactType: " + types.get(1));
+ assertEquals(0, types.get(1).compareToIgnoreCase(ArtifactTypeEnum.MODEL_QUERY_SPEC.toString()));
+
+ System.out.println("ArtifactType: " + types.get(2));
+ assertEquals(0, types.get(2).compareToIgnoreCase(ArtifactTypeEnum.VNF_CATALOG.toString()));
+
+ assertEquals(3, types.size());
+ }
+
+ @Test
+ public void testDecryptPassword() {
+ Properties props = new Properties();
+ String testPass = "youshallnotpass";
+ String encryptedTestPass = Password.obfuscate(testPass);
+
+ System.out.println("Encrypt " + testPass + " ==> " + encryptedTestPass);
+
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_PASSWORD, encryptedTestPass);
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+
+ assertEquals(testPass, config.getPassword());
+ }
+
+ @Test
+ public void testDecryptKeystorePassword() {
+ Properties props = new Properties();
+ String testPass = "youshallnotpass";
+ String encryptedTestPass = Password.obfuscate(testPass);
+
+ System.out.println("Encrypt " + testPass + " ==> " + encryptedTestPass);
+
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD, encryptedTestPass);
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+
+ assertEquals(testPass, config.getKeyStorePassword());
+ }
+
+ @Test
+ public void testDecryptAAIPassword() {
+ Properties props = new Properties();
+ String testPassword = "myvoiceismypassword";
+ String encryptedTestPassword = Password.obfuscate(testPassword);
+
+ props.put(ModelLoaderConfig.PROP_AAI_AUTHENTICATION_PASSWORD, encryptedTestPassword);
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+
+ assertEquals(testPassword, config.getAaiAuthenticationPassword());
+ }
+
+ @Test
+ public void testNoAAIAuth() throws IOException {
+ Properties props = new Properties();
+ props.load(
+ new FileInputStream("src/test/resources/model-loader-empty-auth-password.properties"));
+
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ AaiRestClient aaiClient = new AaiRestClient(config);
+
+ assertFalse("Empty AAI Password should result in no basic authentication",
+ aaiClient.useBasicAuth());
+
+ props.load(new FileInputStream("src/test/resources/model-loader-no-auth-password.properties"));
+ config = new ModelLoaderConfig(props, null);
+ aaiClient = new AaiRestClient(config);
+
+ assertFalse("No AAI Password should result in no basic authentication",
+ aaiClient.useBasicAuth());
+ }
+
+ @Test
+ public void testGetUrls() {
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_AAI_MODEL_RESOURCE_URL, "/aai/v*/service-design-and-creation/models/model/");
+ props.put(ModelLoaderConfig.PROP_AAI_NAMED_QUERY_RESOURCE_URL,
+ "/aai/v*/service-design-and-creation/named-queries/named-query/");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+
+ assertEquals("/aai/v9/service-design-and-creation/models/model/", config.getAaiModelUrl("v9"));
+ assertEquals("/aai/v10/service-design-and-creation/named-queries/named-query/",
+ config.getAaiNamedQueryUrl("v10"));
+ }
+
+ @Test
+ public void testActivateServerTLSAuth(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH, "true");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ boolean authValue = config.activateServerTLSAuth();
+ assertTrue(authValue);
+
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH, "");
+ ModelLoaderConfig config1 = new ModelLoaderConfig(props, null);
+ boolean authValue1 = config.activateServerTLSAuth();
+ assertFalse(authValue1);
+ }
+
+ @Test
+ public void testGetAsdcAddress(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_ASDC_ADDRESS, "address-1");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ String asdcAddr = config.getAsdcAddress();
+ assertEquals(asdcAddr, "address-1");
+ }
+
+ @Test
+ public void testGetConsumerGroup(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_CONSUMER_GROUP, "group-1");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ String ret = config.getConsumerGroup();
+ assertEquals(ret, "group-1");
+ }
+
+ @Test
+ public void testGetConsumerID(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_CONSUMER_ID, "id-1");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ String ret = config.getConsumerID();
+ assertEquals(ret, "id-1");
+ }
+
+ @Test
+ public void testGetEnvironmentName(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME, "local");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ String ret = config.getEnvironmentName();
+ assertEquals(ret, "local");
+ }
+
+ @Test
+ public void testGetKeyStorePath(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_KEYSTORE_FILE, "keystore-file");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, "local/");
+ String ret = config.getKeyStorePath();
+ assertEquals(ret, "local/keystore-file");
+ }
+
+ @Test
+ public void testGetPollingInterval(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_POLLING_INTERVAL, "60");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ int ret = config.getPollingInterval();
+ assertTrue(ret == 60);
+ }
+
+ @Test
+ public void testGetPollingTimeout(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_POLLING_TIMEOUT, "30");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ int ret = config.getPollingTimeout();
+ assertTrue(ret == 30);
+ }
+
+ @Test
+ public void testGetUser(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_USER, "user-1");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ String ret = config.getUser();
+ assertEquals(ret, "user-1");
+ }
+
+ @Test
+ public void testIsFilterInEmptyResources(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_POLLING_TIMEOUT, "30");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ Boolean ret = config.isFilterInEmptyResources();
+ assertFalse(ret);
+ }
+
+ @Test
+ public void testIsUseHttpsWithDmaap(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP, "true");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ Boolean ret = config.isUseHttpsWithDmaap();
+ assertTrue(ret);
+ }
+
+ @Test
+ public void testGetAaiKeyStorePath(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_AAI_KEYSTORE_FILE, "keystore-file");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, "local");
+ String ret = config.getAaiKeyStorePath();
+ assertEquals(ret, "local/keystore-file");
+ }
+
+ @Test
+ public void testGetAaiKeyStorePassword(){
+ Properties props = new Properties();
+ String testPass = "youshallnotpass";
+ String encryptedTestPass = Password.obfuscate(testPass);
+
+ props.put(ModelLoaderConfig.PROP_AAI_KEYSTORE_PASSWORD, encryptedTestPass);
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+
+ assertEquals(testPass, config.getAaiKeyStorePassword());
+ }
+
+ @Test
+ public void testGetIngestSimulatorEnabled(){
+ Properties props = new Properties();
+ props.put(ModelLoaderConfig.PROP_DEBUG_INGEST_SIMULATOR, "enabled");
+ ModelLoaderConfig config = new ModelLoaderConfig(props, null);
+ boolean ret = config.getIngestSimulatorEnabled();
+ assertTrue(ret);
+
+ props.put(ModelLoaderConfig.PROP_DEBUG_INGEST_SIMULATOR, "disabled");
+ ModelLoaderConfig config1 = new ModelLoaderConfig(props, null);
+ boolean ret1 = config.getIngestSimulatorEnabled();
+ assertFalse(ret1);
+ }
+}
diff --git a/src/test/java/org/onap/aai/modelloader/notification/DistributionStatusMsgTest.java b/src/test/java/org/onap/aai/modelloader/notification/DistributionStatusMsgTest.java
new file mode 100644
index 0000000..052a648
--- /dev/null
+++ b/src/test/java/org/onap/aai/modelloader/notification/DistributionStatusMsgTest.java
@@ -0,0 +1,43 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.modelloader.notification;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.sdc.utils.DistributionStatusEnum;
+
+public class DistributionStatusMsgTest {
+
+ @Test
+ public void testEntireClass(){
+ DistributionStatusMsg statusMsg = new DistributionStatusMsg(DistributionStatusEnum.DEPLOY_OK, "id-1",
+ "consumer-1", "http://dummyurl");
+
+ Assert.assertEquals(statusMsg.getStatus(), DistributionStatusEnum.DEPLOY_OK);
+ Assert.assertEquals(statusMsg.getDistributionID(), "id-1");
+ Assert.assertEquals(statusMsg.getConsumerID(), "consumer-1");
+ Assert.assertEquals(statusMsg.getArtifactURL(), "http://dummyurl");
+ Assert.assertNotNull(statusMsg.getTimestamp());
+ }
+}
diff --git a/src/test/java/org/onap/aai/modelloader/notification/EventCallbackTest.java b/src/test/java/org/onap/aai/modelloader/notification/EventCallbackTest.java
new file mode 100644
index 0000000..79c29bf
--- /dev/null
+++ b/src/test/java/org/onap/aai/modelloader/notification/EventCallbackTest.java
@@ -0,0 +1,613 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.modelloader.notification;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.InstanceCreator;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.aai.modelloader.config.ModelLoaderConfig;
+import org.openecomp.sdc.api.IDistributionClient;
+import org.openecomp.sdc.api.consumer.INotificationCallback;
+import org.openecomp.sdc.api.notification.IArtifactInfo;
+import org.openecomp.sdc.api.notification.INotificationData;
+import org.openecomp.sdc.api.notification.IResourceInstance;
+import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
+import org.openecomp.sdc.api.results.IDistributionClientResult;
+import org.openecomp.sdc.impl.DistributionClientFactory;
+import org.openecomp.sdc.impl.DistributionClientImpl;
+import org.openecomp.sdc.utils.DistributionActionResultEnum;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+public class EventCallbackTest {
+
+ ModelLoaderConfig config;
+ DistributionClientImpl client;
+ EventCallback callBack;
+
+ @Before
+ public void init(){
+ MockitoAnnotations.initMocks(this);
+ Properties props = new Properties();
+ props.setProperty("ml.distribution.ARTIFACT_TYPES",
+ "MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG");
+ config = new ModelLoaderConfig(props, null);
+ client = Mockito.spy(DistributionClientImpl.class);
+ callBack = new EventCallback(client, config);
+ }
+
+ @Test
+ public void testActivateCallBack_PublishFailure(){
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ NotificationDataInstance notification = gson.fromJson(getNotificationWithMultipleResources(),
+ NotificationDataInstance.class);
+
+ TestConfiguration testConfig = new TestConfiguration();
+ Mockito.when(client.getConfiguration()).thenReturn(testConfig);
+ callBack.activateCallback(notification);
+ }
+
+ @Test
+ public void testActivateCallBack_PublishSuccess(){
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ NotificationDataInstance notification = gson.fromJson(getNotificationWithMultipleResources(),
+ NotificationDataInstance.class);
+
+ TestConfiguration testConfig = new TestConfiguration();
+ Mockito.when(client.download(Mockito.any(IArtifactInfo.class))).thenReturn(buildSuccessResult());
+ Mockito.when(client.getConfiguration()).thenReturn(testConfig);
+ callBack.activateCallback(notification);
+ }
+
+ private static IDistributionClientDownloadResult buildSuccessResult() {
+ return new IDistributionClientDownloadResult() {
+
+ @Override
+ public byte[] getArtifactPayload() {
+ return new byte[0];
+ }
+
+ @Override
+ public String getArtifactName() {
+ return "";
+ }
+
+ @Override
+ public String getArtifactFilename() {
+ return "";
+ }
+
+ @Override
+ public String getDistributionMessageResult() {
+ return "";
+ }
+
+ @Override
+ public DistributionActionResultEnum getDistributionActionResult() {
+ return DistributionActionResultEnum.SUCCESS;
+ }
+ };
+ }
+
+ private String getNotificationWithMultipleResources(){
+ return "{\"distributionID\" : \"bcc7a72e-90b1-4c5f-9a37-28dc3cd86416\",\r\n" +
+ " \"serviceName\" : \"Testnotificationser1\",\r\n" +
+ " \"serviceVersion\" : \"1.0\",\r\n" +
+ " \"serviceUUID\" : \"7f7f94f4-373a-4b71-a0e3-80ae2ba4eb5d\",\r\n" +
+ " \"serviceDescription\" : \"TestNotificationVF1\",\r\n" +
+ " \"resources\" : [{\r\n" +
+ " \"resourceInstanceName\" : \"testnotificationvf11\",\r\n" +
+ " \"resourceName\" : \"TestNotificationVF1\",\r\n" +
+ " \"resourceVersion\" : \"1.0\",\r\n" +
+ " \"resoucreType\" : \"VF\",\r\n" +
+ " \"resourceUUID\" : \"907e1746-9f69-40f5-9f2a-313654092a2d\",\r\n" +
+ " \"artifacts\" : [{\r\n" +
+ " \"artifactName\" : \"sample-xml-alldata-1-1.xml\",\r\n" +
+ " \"artifactType\" : \"YANG_XML\",\r\n" +
+ " \"artifactURL\" : \"/sdc/v1/catalog/services/Testnotificationser1/1.0/" +
+ " resourceInstances/testnotificationvf11/artifacts/" +
+ " sample-xml-alldata-1-1.xml\",\r\n" +
+ " \"artifactChecksum\" : \"MTUxODFkMmRlOTNhNjYxMGYyYTI1ZjA5Y2QyNWQyYTk\\u003d\",\r\n" +
+ " \"artifactDescription\" : \"MyYang\",\r\n" +
+ " \"artifactTimeout\" : 0,\r\n" +
+ " \"artifactUUID\" : \"0005bc4a-2c19-452e-be6d-d574a56be4d0\",\r\n" +
+ " \"artifactVersion\" : \"1\"\r\n" +
+ " }" +
+ " ]\r\n" +
+ " },\r\n" +
+ " {\r\n" +
+ " \"resourceInstanceName\" : \"testnotificationvf12\",\r\n" +
+ " \"resourceName\" : \"TestNotificationVF1\",\r\n" +
+ " \"resourceVersion\" : \"1.0\",\r\n" +
+ " \"resoucreType\" : \"VF\",\r\n" +
+ " \"resourceUUID\" : \"907e1746-9f69-40f5-9f2a-313654092a2e\",\r\n" +
+ " \"artifacts\" : [{\r\n" +
+ " \"artifactName\" : \"heat.yaml\",\r\n" +
+ " \"artifactType\" : \"HEAT\",\r\n" +
+ " \"artifactURL\" : \"/sdc/v1/catalog/services/Testnotificationser1/1.0/" +
+ " resourceInstances/testnotificationvf11/artifacts/" +
+ " heat.yaml\",\r\n" +
+ " \"artifactChecksum\" : \"ODEyNjE4YTMzYzRmMTk2ODVhNTU2NTg3YWEyNmIxMTM\\u003d\",\r\n" +
+ " \"artifactDescription\" : \"heat\",\r\n" +
+ " \"artifactTimeout\" : 60,\r\n" +
+ " \"artifactUUID\" : \"8df6123c-f368-47d3-93be-1972cefbcc35\",\r\n" +
+ " \"artifactVersion\" : \"1\"\r\n" +
+ " }" +
+ " ]\r\n" +
+ " }\r\n" +
+ " ]}";
+ }
+}
+
+class NotificationDataInstance implements INotificationData{
+
+ private String distributionID;
+ private String serviceName;
+ private String serviceVersion;
+ private String serviceUUID;
+ private String serviceDescription;
+ private String serviceInvariantUUID;
+ private List<JsonContainerResourceInstance> resources;
+ private List<ArtifactInfoImpl> serviceArtifacts;
+ private String workloadContext;
+
+ @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 void setDistributionID(String distributionID) {
+ this.distributionID = distributionID;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public void setServiceVersion(String serviceVersion) {
+ this.serviceVersion = serviceVersion;
+ }
+
+ public void setServiceUUID(String serviceUUID) {
+ this.serviceUUID = serviceUUID;
+ }
+
+
+
+ public String getServiceDescription() {
+ return serviceDescription;
+ }
+
+ public void setServiceDescription(String serviceDescription) {
+ this.serviceDescription = serviceDescription;
+ }
+
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ 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() {
+ List<IResourceInstance> ret = new ArrayList<IResourceInstance>();
+ if( resources != null ){
+ ret.addAll(resources);
+ }
+ return ret;
+ }
+
+ public void setResources(List<IResourceInstance> resources){
+ this.resources = JsonContainerResourceInstance.convertToJsonContainer(resources);
+ }
+
+ public List<JsonContainerResourceInstance> getResourcesImpl(){
+ return resources;
+ }
+
+ List<ArtifactInfoImpl> getServiceArtifactsImpl(){
+ return serviceArtifacts;
+ }
+
+ @Override
+ public List<IArtifactInfo> getServiceArtifacts() {
+
+ List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
+ if( serviceArtifacts != null ){
+ temp.addAll(serviceArtifacts);
+ }
+ return temp;
+ }
+
+ void setServiceArtifacts(List<ArtifactInfoImpl> relevantServiceArtifacts) {
+ serviceArtifacts = relevantServiceArtifacts;
+
+ }
+
+ @Override
+ public String getServiceInvariantUUID() {
+ return serviceInvariantUUID;
+ }
+
+
+ public void setServiceInvariantUUID(String serviceInvariantUUID) {
+ this.serviceInvariantUUID = serviceInvariantUUID;
+ }
+ @Override
+ public IArtifactInfo getArtifactMetadataByUUID(String artifactUUID){
+ IArtifactInfo ret = findArtifactInfoByUUID(artifactUUID, serviceArtifacts);
+ if( ret == null && resources != null ){
+ for( JsonContainerResourceInstance currResourceInstance : resources ){
+ ret = findArtifactInfoByUUID(artifactUUID, currResourceInstance.getArtifactsImpl());
+ if( ret != null ){
+ break;
+ }
+ }
+ }
+ return ret;
+
+ }
+
+ private IArtifactInfo findArtifactInfoByUUID(String artifactUUID, List<ArtifactInfoImpl> listToCheck) {
+ IArtifactInfo ret = null;
+ if( listToCheck != null ){
+ for(IArtifactInfo curr: listToCheck ){
+ if(curr.getArtifactUUID().equals(artifactUUID) ){
+ ret = curr;
+ break;
+ }
+ }
+ }
+ return ret;
+ }
+}
+
+class ArtifactInfoImpl implements IArtifactInfo{
+
+ private String artifactName;
+ private String artifactType;
+ private String artifactURL;
+ private String artifactChecksum;
+ private String artifactDescription;
+ private Integer artifactTimeout;
+ private String artifactVersion;
+ private String artifactUUID;
+ private String generatedFromUUID;
+ private IArtifactInfo generatedArtifact;
+ private List<String> relatedArtifacts;
+ private List<IArtifactInfo> relatedArtifactsInfo;
+ ArtifactInfoImpl(){}
+
+ private ArtifactInfoImpl(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();
+ relatedArtifactsInfo = iArtifactInfo.getRelatedArtifacts();
+ relatedArtifacts = fillRelatedArtifactsUUID(relatedArtifactsInfo);
+
+ }
+
+
+ private List<String> fillRelatedArtifactsUUID(List<IArtifactInfo> relatedArtifactsInfo) {
+ List<String> relatedArtifactsUUID = null;
+ if( relatedArtifactsInfo != null && !relatedArtifactsInfo.isEmpty()){
+ relatedArtifactsUUID = new ArrayList<>();
+ for(IArtifactInfo curr: relatedArtifactsInfo){
+ relatedArtifactsUUID.add(curr.getArtifactUUID());
+ }
+ }
+ return relatedArtifactsUUID;
+ }
+
+ public static List<ArtifactInfoImpl> convertToArtifactInfoImpl(List<IArtifactInfo> list){
+ List<ArtifactInfoImpl> ret = new ArrayList<ArtifactInfoImpl>();
+ if( list != null ){
+ for(IArtifactInfo artifactInfo : list ){
+ ret.add(new ArtifactInfoImpl(artifactInfo));
+ }
+ }
+ return ret;
+ }
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ public void setArtifactType(String artifactType) {
+ this.artifactType = artifactType;
+ }
+
+ public String getArtifactURL() {
+ return artifactURL;
+ }
+
+ public void setArtifactURL(String artifactURL) {
+ this.artifactURL = artifactURL;
+ }
+
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
+
+ public void setArtifactChecksum(String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ }
+
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ public void setArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ public Integer getArtifactTimeout() {
+ return artifactTimeout;
+ }
+
+ public void setArtifactTimeout(Integer artifactTimeout) {
+ this.artifactTimeout = artifactTimeout;
+ }
+
+ @Override
+ public String toString() {
+ return "BaseArtifactInfoImpl [artifactName=" + artifactName
+ + ", artifactType=" + artifactType + ", artifactURL="
+ + artifactURL + ", artifactChecksum=" + artifactChecksum
+ + ", artifactDescription=" + artifactDescription
+ + ", artifactVersion=" + artifactVersion
+ + ", artifactUUID=" + artifactUUID
+ + ", artifactTimeout=" + artifactTimeout + "]";
+ }
+
+ public String getArtifactVersion() {
+ return artifactVersion;
+ }
+
+ public void setArtifactVersion(String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ }
+
+ public String getArtifactUUID() {
+ return artifactUUID;
+ }
+
+ public void setArtifactUUID(String artifactUUID) {
+ this.artifactUUID = artifactUUID;
+ }
+
+ public String getGeneratedFromUUID() {
+ return generatedFromUUID;
+ }
+
+ public void setGeneratedFromUUID(String generatedFromUUID) {
+ this.generatedFromUUID = generatedFromUUID;
+ }
+
+ public IArtifactInfo getGeneratedArtifact() {
+ return generatedArtifact;
+ }
+
+ public void setGeneratedArtifact(IArtifactInfo generatedArtifact) {
+ this.generatedArtifact = generatedArtifact;
+ }
+
+ public List<IArtifactInfo> getRelatedArtifacts(){
+ List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
+ if( relatedArtifactsInfo != null ){
+ temp.addAll(relatedArtifactsInfo);
+ }
+ return temp;
+ }
+
+ public void setRelatedArtifacts(List<String> relatedArtifacts) {
+ this.relatedArtifacts = relatedArtifacts;
+ }
+
+ public void setRelatedArtifactsInfo(List<IArtifactInfo> relatedArtifactsInfo) {
+ this.relatedArtifactsInfo = relatedArtifactsInfo;
+ }
+
+ public List<String> getRelatedArtifactsUUID(){
+ return relatedArtifacts;
+ }
+}
+
+class JsonContainerResourceInstance implements IResourceInstance{
+ JsonContainerResourceInstance (){}
+ private String resourceInstanceName;
+ private String resourceCustomizationUUID;
+ private String resourceName;
+ private String resourceVersion;
+ private String resoucreType;
+ private String resourceUUID;
+ private String resourceInvariantUUID;
+ private String category;
+ private String subcategory;
+ private List<ArtifactInfoImpl> artifacts;
+
+ private JsonContainerResourceInstance(IResourceInstance resourceInstance){
+ resourceInstanceName = resourceInstance.getResourceInstanceName();
+ resourceCustomizationUUID = resourceInstance.getResourceCustomizationUUID();
+ resourceName = resourceInstance.getResourceName();
+ resourceVersion = resourceInstance.getResourceVersion();
+ resoucreType = resourceInstance.getResourceType();
+ resourceUUID = resourceInstance.getResourceUUID();
+ resourceInvariantUUID = resourceInstance.getResourceInvariantUUID();
+ category = resourceInstance.getCategory();
+ subcategory = resourceInstance.getSubcategory();
+ artifacts = ArtifactInfoImpl.convertToArtifactInfoImpl(resourceInstance.getArtifacts());
+ }
+
+ public static List<JsonContainerResourceInstance> convertToJsonContainer(List<IResourceInstance> resources){
+ List<JsonContainerResourceInstance> buildResources = new ArrayList<JsonContainerResourceInstance>();
+ if( resources != null ){
+ for( IResourceInstance resourceInstance : resources ){
+ buildResources.add(new JsonContainerResourceInstance(resourceInstance));
+ }
+ }
+ return buildResources;
+ }
+
+ @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 resoucreType;
+ }
+
+ public void setResoucreType(String resoucreType) {
+ this.resoucreType = resoucreType;
+ }
+
+ @Override
+ public String getResourceUUID() {
+ return resourceUUID;
+ }
+
+ public void setResourceUUID(String resourceUUID) {
+ this.resourceUUID = resourceUUID;
+ }
+
+ @Override
+ public List<IArtifactInfo> getArtifacts() {
+ List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
+ if( artifacts != null ){
+ temp.addAll(artifacts);
+ }
+ return temp;
+ }
+
+ public void setArtifacts(List<ArtifactInfoImpl> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ public List<ArtifactInfoImpl> 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/aai/modelloader/notification/TestConfiguration.java b/src/test/java/org/onap/aai/modelloader/notification/TestConfiguration.java
new file mode 100644
index 0000000..cf971a1
--- /dev/null
+++ b/src/test/java/org/onap/aai/modelloader/notification/TestConfiguration.java
@@ -0,0 +1,295 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.modelloader.notification;
+
+import org.openecomp.sdc.api.consumer.IConfiguration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestConfiguration implements IConfiguration{
+
+
+ private String asdcAddress;
+ private String user;
+ private String password;
+ private int pollingInterval = 15;
+ private int pollingTimeout = 15;
+ private List<String> relevantArtifactTypes;
+ private String consumerGroup;
+ private String environmentName;
+ private String comsumerID;
+ private String keyStorePath;
+ private String keyStorePassword;
+ private boolean activateServerTLSAuth;
+ private boolean isFilterInEmptyResources;
+ private boolean useHttpsWithDmaap;
+
+ public TestConfiguration(IConfiguration other) {
+ this.asdcAddress = other.getAsdcAddress();
+ this.comsumerID = other.getConsumerID();
+ this.consumerGroup = other.getConsumerGroup();
+ this.environmentName = other.getEnvironmentName();
+ this.password = other.getPassword();
+ this.pollingInterval = other.getPollingInterval();
+ this.pollingTimeout = other.getPollingTimeout();
+ this.relevantArtifactTypes = other.getRelevantArtifactTypes();
+ this.user = other.getUser();
+ this.keyStorePath = other.getKeyStorePath();
+ this.keyStorePassword = other.getKeyStorePassword();
+ this.activateServerTLSAuth = other.activateServerTLSAuth();
+ this.isFilterInEmptyResources = other.isFilterInEmptyResources();
+ }
+
+ public TestConfiguration() {
+ this.asdcAddress = "localhost:8443";
+ this.comsumerID = "mso-123456";
+ this.consumerGroup = "mso-group";
+ this.environmentName = "PROD";
+ this.password = "password";
+ this.pollingInterval = 20;
+ this.pollingTimeout = 20;
+ this.relevantArtifactTypes = new ArrayList<String>();
+ this.relevantArtifactTypes.add("HEAT");
+ this.user = "mso-user";
+ this.keyStorePath = "etc/asdc-client.jks";
+ this.keyStorePassword = "Aa123456";
+ this.activateServerTLSAuth = false;
+ this.isFilterInEmptyResources = false;
+ }
+
+ @Override
+ public String getAsdcAddress() {
+ return asdcAddress;
+ }
+
+ @Override
+ public String getUser() {
+ return user;
+ }
+
+ @Override
+ public String getPassword() {
+ return password;
+ }
+
+ @Override
+ public int getPollingInterval() {
+ return pollingInterval;
+ }
+
+ @Override
+ public int getPollingTimeout() {
+ return pollingTimeout;
+ }
+
+ @Override
+ public List<String> getRelevantArtifactTypes() {
+ return relevantArtifactTypes;
+ }
+
+ @Override
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+ @Override
+ public String getEnvironmentName() {
+ return environmentName;
+ }
+
+ @Override
+ public String getConsumerID() {
+ return comsumerID;
+ }
+
+ @Override
+ public String getKeyStorePath() {
+ return keyStorePath;
+ }
+
+ @Override
+ public String getKeyStorePassword() {
+ return keyStorePassword;
+ }
+
+ public String getComsumerID() {
+ return comsumerID;
+ }
+
+ public void setComsumerID(String comsumerID) {
+ this.comsumerID = comsumerID;
+ }
+
+ public void setAsdcAddress(String asdcAddress) {
+ this.asdcAddress = asdcAddress;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public void setPollingInterval(int pollingInterval) {
+ this.pollingInterval = pollingInterval;
+ }
+
+ public void setPollingTimeout(int pollingTimeout) {
+ this.pollingTimeout = pollingTimeout;
+ }
+
+ public void setRelevantArtifactTypes(List<String> relevantArtifactTypes) {
+ this.relevantArtifactTypes = relevantArtifactTypes;
+ }
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+ public void setEnvironmentName(String environmentName) {
+ this.environmentName = environmentName;
+ }
+
+ public void setKeyStorePath(String keyStorePath) {
+ this.keyStorePath = keyStorePath;
+ }
+
+ public void setKeyStorePassword(String keyStorePassword) {
+ this.keyStorePassword = keyStorePassword;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((asdcAddress == null) ? 0 : asdcAddress.hashCode());
+ result = prime * result + ((comsumerID == null) ? 0 : comsumerID.hashCode());
+ result = prime * result + ((consumerGroup == null) ? 0 : consumerGroup.hashCode());
+ result = prime * result + ((environmentName == null) ? 0 : environmentName.hashCode());
+ result = prime * result + ((password == null) ? 0 : password.hashCode());
+ result = prime * result + pollingInterval;
+ result = prime * result + pollingTimeout;
+ result = prime * result + ((relevantArtifactTypes == null) ? 0 : relevantArtifactTypes.hashCode());
+ result = prime * result + ((user == null) ? 0 : user.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean activateServerTLSAuth() {
+
+ return activateServerTLSAuth;
+ }
+
+ public void setactivateServerTLSAuth(boolean activateServerTLSAuth) {
+ this.activateServerTLSAuth = activateServerTLSAuth;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TestConfiguration other = (TestConfiguration) obj;
+ if (asdcAddress == null) {
+ if (other.asdcAddress != null)
+ return false;
+ } else if (!asdcAddress.equals(other.asdcAddress))
+ return false;
+ if (comsumerID == null) {
+ if (other.comsumerID != null)
+ return false;
+ } else if (!comsumerID.equals(other.comsumerID))
+ return false;
+ if (consumerGroup == null) {
+ if (other.consumerGroup != null)
+ return false;
+ } else if (!consumerGroup.equals(other.consumerGroup))
+ return false;
+ if (environmentName == null) {
+ if (other.environmentName != null)
+ return false;
+ } else if (!environmentName.equals(other.environmentName))
+ return false;
+ if (password == null) {
+ if (other.password != null)
+ return false;
+ } else if (!password.equals(other.password))
+ return false;
+ if (pollingInterval != other.pollingInterval)
+ return false;
+ if (pollingTimeout != other.pollingTimeout)
+ return false;
+ if (relevantArtifactTypes == null) {
+ if (other.relevantArtifactTypes != null)
+ return false;
+ } else if (!relevantArtifactTypes.equals(other.relevantArtifactTypes))
+ return false;
+ if (user == null) {
+ if (other.user != null)
+ return false;
+ } else if (!user.equals(other.user))
+ return false;
+ if (keyStorePath == null) {
+ if (other.keyStorePath != null)
+ return false;
+ } else if (!keyStorePath.equals(other.keyStorePath))
+ return false;
+ if (keyStorePassword == null) {
+ if (other.keyStorePassword != null)
+ return false;
+ } else if (!keyStorePassword.equals(other.keyStorePassword))
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "TestConfiguration [asdcAddress=" + asdcAddress + ", user=" + user + ", password=" + password +
+ ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout +
+ ", relevantArtifactTypes=" + relevantArtifactTypes + ", consumerGroup=" + consumerGroup +
+ ", environmentName=" + environmentName + ", comsumerID=" + comsumerID + "]";
+ }
+
+ @Override
+ public boolean isFilterInEmptyResources() {
+ return isFilterInEmptyResources;
+ }
+
+
+ public void setFilterInEmptyResources(boolean isFilterInEmptyResources) {
+ this.isFilterInEmptyResources = isFilterInEmptyResources;
+ }
+
+ @Override
+ public Boolean isUseHttpsWithDmaap() {
+ return this.useHttpsWithDmaap;
+ }
+}
diff --git a/src/test/java/org/onap/aai/modelloader/service/ModelLoaderServiceTest.java b/src/test/java/org/onap/aai/modelloader/service/ModelLoaderServiceTest.java
new file mode 100644
index 0000000..3285746
--- /dev/null
+++ b/src/test/java/org/onap/aai/modelloader/service/ModelLoaderServiceTest.java
@@ -0,0 +1,87 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.modelloader.service;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+public class ModelLoaderServiceTest {
+
+ ModelLoaderService service;
+ @Before
+ public void init() throws IOException, NoSuchFieldException, IllegalAccessException {
+ System.setProperty("AJSC_HOME", new File(".").getCanonicalPath().replace('\\', '/'));
+ setFinalStatic(System.getProperty("AJSC_HOME")+"/src/test/resources/model-loader.properties");
+ service = new ModelLoaderService();
+ }
+
+ @Test
+ public void testLoadModel(){
+ Response response = service.loadModel("model-1");
+ Assert.assertNotNull(response);
+ }
+
+ @Test
+ public void testSaveModel(){
+ Response response = service.saveModel("model-1", "name-1");
+ Assert.assertNotNull(response);
+ }
+
+ @Test
+ public void testIngestModel() throws IOException {
+ HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
+ Response response = service.ingestModel("model-id-1", req, "payload");
+ Assert.assertNotNull(response);
+ }
+
+ static void setFinalStatic(String fieldValue) throws NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException {
+ Field configField = ModelLoaderService.class.getDeclaredField("CONFIG_FILE");
+ configField.setAccessible(true);
+
+ Field modifiersField = Field.class.getDeclaredField( "modifiers" );
+ modifiersField.setAccessible( true );
+ modifiersField.setInt( configField, configField.getModifiers() & ~Modifier.FINAL );
+
+ configField.set(null, fieldValue);
+
+ Field authField = ModelLoaderService.class.getDeclaredField("CONFIG_AUTH_LOCATION");
+ authField.setAccessible(true);
+
+ Field modifiersField1 = Field.class.getDeclaredField( "modifiers" );
+ modifiersField1.setAccessible( true );
+ modifiersField1.setInt( authField, authField.getModifiers() & ~Modifier.FINAL );
+
+ authField.set(null, System.getProperty("AJSC_HOME"));
+ }
+}