[MSO-8] Second step of the rebase for MSO
[so.git] / asdc-controller / src / test / java / org / openecomp / mso / asdc / client / tests / ASDCElementInfoTest.java
index 63da38d..d6453b5 100644 (file)
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-
-package org.openecomp.mso.asdc.client.tests;
-
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collections;
-import java.util.UUID;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-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.notification.IVfModuleMetadata;
-import org.openecomp.mso.asdc.client.ASDCConfiguration;
-import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
-import org.openecomp.mso.asdc.installer.ASDCElementInfo;
-import org.openecomp.mso.asdc.installer.VfModuleStructure;
-import org.openecomp.mso.asdc.installer.VfResourceStructure;
-import org.openecomp.mso.asdc.installer.IVfModuleData;
-
-public class ASDCElementInfoTest {
-
-       @Test
-       public void createASDCElementInfoWithNullParameterTest() {
-               ASDCElementInfo elementInfoFromNullVfArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(null);
-               ASDCElementInfo elementInfoFromNullVfModuleStructure = ASDCElementInfo.createElementFromVfModuleStructure(null);
-               ASDCElementInfo elementInfoFromNullVfResourceStructure = ASDCElementInfo.createElementFromVfResourceStructure(null);
-
-               elementInfoFromNullVfArtifact.addElementInfo(null, null);
-               elementInfoFromNullVfModuleStructure.addElementInfo(null, "someValue");
-               elementInfoFromNullVfResourceStructure.addElementInfo("someKey", null);
-
-               assertEquals(elementInfoFromNullVfArtifact.toString(), "");
-               assertEquals(elementInfoFromNullVfModuleStructure.toString(), "");
-               assertEquals(elementInfoFromNullVfResourceStructure.toString(), "");
-
-               assertNotNull(elementInfoFromNullVfArtifact);
-               assertNotNull(elementInfoFromNullVfModuleStructure);
-               assertNotNull(elementInfoFromNullVfResourceStructure);
-
-               assertNotNull(ASDCElementInfo.EMPTY_INSTANCE);
-
-               assertEquals(elementInfoFromNullVfArtifact, ASDCElementInfo.EMPTY_INSTANCE);
-               assertEquals(elementInfoFromNullVfModuleStructure, ASDCElementInfo.EMPTY_INSTANCE);
-               assertEquals(elementInfoFromNullVfResourceStructure, ASDCElementInfo.EMPTY_INSTANCE);
-
-               assertEquals(ASDCElementInfo.EMPTY_INSTANCE.getType(), "");
-               assertEquals(ASDCElementInfo.EMPTY_INSTANCE.toString(), "");
-
-               assertEquals(elementInfoFromNullVfArtifact.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
-               assertEquals(elementInfoFromNullVfModuleStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
-               assertEquals(elementInfoFromNullVfResourceStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
-       }
-
-       @Test
-       public void createASDCElementInfoFromVfResourceTest() {
-
-               String resourceInstanceName = "Resource 1";
-
-               UUID generatedUUID = UUID.randomUUID();
-
-               INotificationData notificationData = Mockito.mock(INotificationData.class);
-               IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
-
-               Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
-               Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
-
-               VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
-
-               ASDCElementInfo elementInfoFromVfResource = ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure);
-
-               assertTrue(elementInfoFromVfResource.toString().contains(resourceInstanceName));
-               assertTrue(elementInfoFromVfResource.toString().contains(generatedUUID.toString()));
-
-               assertFalse(ASDCConfiguration.VF_MODULES_METADATA.equals(elementInfoFromVfResource.getType()));
-               assertEquals(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name(), elementInfoFromVfResource.getType());
-
-               assertFalse(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));
-               elementInfoFromVfResource.addElementInfo("MyInfo1", "someValue");
-               assertTrue(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));
-       }
-
-       @Test
-       public void createASDCElementInfoFromVfModuleTest() throws ArtifactInstallerException {
-
-               String resourceInstanceName = "Resource 1";
-
-               UUID generatedUUID = UUID.randomUUID();
-
-               INotificationData notificationData = Mockito.mock(INotificationData.class);
-               IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
-
-               Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
-               Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
-
-               VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
-
-               // Create module structure now
-
-               String vfModuleModelName = "Module Model XYZ";
-
-               UUID generatedUUIDForModule = UUID.randomUUID();
-
-               IVfModuleData moduleMetadata = Mockito.mock(IVfModuleData.class);
-               Mockito.when(moduleMetadata.getVfModuleModelName()).thenReturn(vfModuleModelName);
-               Mockito.when(moduleMetadata.getVfModuleModelInvariantUUID()).thenReturn(generatedUUIDForModule.toString());
-               Mockito.when(moduleMetadata.getArtifacts()).thenReturn(Collections.<String> emptyList());
-
-               VfModuleStructure vfModuleStructure = new VfModuleStructure(vfResourceStructure, moduleMetadata);
-
-               ASDCElementInfo elementInfoFromVfModule = ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure);
-
-               assertTrue(elementInfoFromVfModule.toString().contains(vfModuleModelName));
-               assertTrue(elementInfoFromVfModule.toString().contains(generatedUUIDForModule.toString()));
-
-               assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromVfModule.getType()));
-               assertEquals(ASDCConfiguration.VF_MODULES_METADATA, elementInfoFromVfModule.getType());
-
-               assertFalse(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
-               elementInfoFromVfModule.addElementInfo("MyInfo2", "someValue");
-               assertTrue(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
-       }
-
-       @Test
-       public void createASDCElementInfoFromArtifact() {
-               for (String eVal : ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST) {
-                       String generatedArtifactName = eVal + " 1";
-                       UUID generatedUUIDForArtifact = UUID.randomUUID();
-
-                       IArtifactInfo artifactInfo = Mockito.mock(IArtifactInfo.class);
-                       Mockito.when(artifactInfo.getArtifactType()).thenReturn(eVal);
-                       Mockito.when(artifactInfo.getArtifactName()).thenReturn(generatedArtifactName);
-                       Mockito.when(artifactInfo.getArtifactUUID()).thenReturn(generatedUUIDForArtifact.toString());
-
-                       ASDCElementInfo elementInfoFromArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(artifactInfo);
-
-                       assertTrue(elementInfoFromArtifact.toString().contains(generatedArtifactName));
-                       assertTrue(elementInfoFromArtifact.toString().contains(generatedUUIDForArtifact.toString()));
-
-                       assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromArtifact.getType()));
-                       assertEquals(eVal, elementInfoFromArtifact.getType());
-
-                       assertFalse(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));
-                       elementInfoFromArtifact.addElementInfo("MyInfo3", "someValue");
-                       assertTrue(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));
-               }
-       }
-}
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * OPENECOMP - MSO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. 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
+\r
+\r
+package org.openecomp.mso.asdc.client.tests;\r
+\r
+\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertFalse;\r
+import static org.junit.Assert.assertNotNull;\r
+import static org.junit.Assert.assertTrue;\r
+\r
+import java.util.Collections;\r
+import java.util.UUID;\r
+\r
+import org.junit.Test;\r
+import org.mockito.Mockito;\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.notification.IVfModuleMetadata;\r
+import org.openecomp.mso.asdc.client.ASDCConfiguration;\r
+import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;\r
+import org.openecomp.mso.asdc.installer.ASDCElementInfo;\r
+import org.openecomp.mso.asdc.installer.VfModuleStructure;\r
+import org.openecomp.mso.asdc.installer.VfResourceStructure;\r
+import org.openecomp.mso.asdc.installer.IVfModuleData;\r
+\r
+public class ASDCElementInfoTest {\r
+\r
+       @Test\r
+       public void createASDCElementInfoWithNullParameterTest() {\r
+               ASDCElementInfo elementInfoFromNullVfArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(null);\r
+               ASDCElementInfo elementInfoFromNullVfModuleStructure = ASDCElementInfo.createElementFromVfModuleStructure(null);\r
+               ASDCElementInfo elementInfoFromNullVfResourceStructure = ASDCElementInfo.createElementFromVfResourceStructure(null);\r
+\r
+               elementInfoFromNullVfArtifact.addElementInfo(null, null);\r
+               elementInfoFromNullVfModuleStructure.addElementInfo(null, "someValue");\r
+               elementInfoFromNullVfResourceStructure.addElementInfo("someKey", null);\r
+\r
+               assertEquals(elementInfoFromNullVfArtifact.toString(), "");\r
+               assertEquals(elementInfoFromNullVfModuleStructure.toString(), "");\r
+               assertEquals(elementInfoFromNullVfResourceStructure.toString(), "");\r
+\r
+               assertNotNull(elementInfoFromNullVfArtifact);\r
+               assertNotNull(elementInfoFromNullVfModuleStructure);\r
+               assertNotNull(elementInfoFromNullVfResourceStructure);\r
+\r
+               assertNotNull(ASDCElementInfo.EMPTY_INSTANCE);\r
+\r
+               assertEquals(elementInfoFromNullVfArtifact, ASDCElementInfo.EMPTY_INSTANCE);\r
+               assertEquals(elementInfoFromNullVfModuleStructure, ASDCElementInfo.EMPTY_INSTANCE);\r
+               assertEquals(elementInfoFromNullVfResourceStructure, ASDCElementInfo.EMPTY_INSTANCE);\r
+\r
+               assertEquals(ASDCElementInfo.EMPTY_INSTANCE.getType(), "");\r
+               assertEquals(ASDCElementInfo.EMPTY_INSTANCE.toString(), "");\r
+\r
+               assertEquals(elementInfoFromNullVfArtifact.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());\r
+               assertEquals(elementInfoFromNullVfModuleStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());\r
+               assertEquals(elementInfoFromNullVfResourceStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());\r
+       }\r
+\r
+       @Test\r
+       public void createASDCElementInfoFromVfResourceTest() {\r
+\r
+               String resourceInstanceName = "Resource 1";\r
+\r
+               UUID generatedUUID = UUID.randomUUID();\r
+\r
+               INotificationData notificationData = Mockito.mock(INotificationData.class);\r
+               IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);\r
+\r
+               Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);\r
+               Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());\r
+\r
+               VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);\r
+\r
+               ASDCElementInfo elementInfoFromVfResource = ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure);\r
+\r
+               assertTrue(elementInfoFromVfResource.toString().contains(resourceInstanceName));\r
+               assertTrue(elementInfoFromVfResource.toString().contains(generatedUUID.toString()));\r
+\r
+               assertFalse(ASDCConfiguration.VF_MODULES_METADATA.equals(elementInfoFromVfResource.getType()));\r
+               assertEquals(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name(), elementInfoFromVfResource.getType());\r
+\r
+               assertFalse(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));\r
+               elementInfoFromVfResource.addElementInfo("MyInfo1", "someValue");\r
+               assertTrue(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));\r
+       }\r
+\r
+       @Test\r
+       public void createASDCElementInfoFromVfModuleTest() throws ArtifactInstallerException {\r
+\r
+               String resourceInstanceName = "Resource 1";\r
+\r
+               UUID generatedUUID = UUID.randomUUID();\r
+\r
+               INotificationData notificationData = Mockito.mock(INotificationData.class);\r
+               IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);\r
+\r
+               Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);\r
+               Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());\r
+\r
+               VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);\r
+\r
+               // Create module structure now\r
+\r
+               String vfModuleModelName = "Module Model XYZ";\r
+\r
+               UUID generatedUUIDForModule = UUID.randomUUID();\r
+\r
+               IVfModuleData moduleMetadata = Mockito.mock(IVfModuleData.class);\r
+               Mockito.when(moduleMetadata.getVfModuleModelName()).thenReturn(vfModuleModelName);\r
+               Mockito.when(moduleMetadata.getVfModuleModelInvariantUUID()).thenReturn(generatedUUIDForModule.toString());\r
+               Mockito.when(moduleMetadata.getArtifacts()).thenReturn(Collections.<String> emptyList());\r
+\r
+               VfModuleStructure vfModuleStructure = new VfModuleStructure(vfResourceStructure, moduleMetadata);\r
+\r
+               ASDCElementInfo elementInfoFromVfModule = ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure);\r
+\r
+               assertTrue(elementInfoFromVfModule.toString().contains(vfModuleModelName));\r
+               assertTrue(elementInfoFromVfModule.toString().contains(generatedUUIDForModule.toString()));\r
+\r
+               assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromVfModule.getType()));\r
+               assertEquals(ASDCConfiguration.VF_MODULES_METADATA, elementInfoFromVfModule.getType());\r
+\r
+               assertFalse(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));\r
+               elementInfoFromVfModule.addElementInfo("MyInfo2", "someValue");\r
+               assertTrue(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));\r
+       }\r
+\r
+       @Test\r
+       public void createASDCElementInfoFromArtifact() {\r
+               for (String eVal : ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST) {\r
+                       String generatedArtifactName = eVal + " 1";\r
+                       UUID generatedUUIDForArtifact = UUID.randomUUID();\r
+\r
+                       IArtifactInfo artifactInfo = Mockito.mock(IArtifactInfo.class);\r
+                       Mockito.when(artifactInfo.getArtifactType()).thenReturn(eVal);\r
+                       Mockito.when(artifactInfo.getArtifactName()).thenReturn(generatedArtifactName);\r
+                       Mockito.when(artifactInfo.getArtifactUUID()).thenReturn(generatedUUIDForArtifact.toString());\r
+\r
+                       ASDCElementInfo elementInfoFromArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(artifactInfo);\r
+\r
+                       assertTrue(elementInfoFromArtifact.toString().contains(generatedArtifactName));\r
+                       assertTrue(elementInfoFromArtifact.toString().contains(generatedUUIDForArtifact.toString()));\r
+\r
+                       assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromArtifact.getType()));\r
+                       assertEquals(eVal, elementInfoFromArtifact.getType());\r
+\r
+                       assertFalse(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));\r
+                       elementInfoFromArtifact.addElementInfo("MyInfo3", "someValue");\r
+                       assertTrue(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));\r
+               }\r
+       }\r
+}\r