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