* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.clamp.clds.sdc.controller.installer;
import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException;
import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
import org.onap.clamp.clds.util.ResourceFileUtil;
-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.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.notification.INotificationData;
+import org.onap.sdc.api.notification.IResourceInstance;
+import org.onap.sdc.api.results.IDistributionClientDownloadResult;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
public class CsarHandlerTest {
private static final String CSAR_ARTIFACT_NAME = "testArtifact.csar";
private static final String SERVICE_UUID = "serviceUUID";
private static final String RESOURCE1_UUID = "resource1UUID";
- private static final String BLUEPRINT1_NAME = "blueprint1-name";
+ private static final String RESOURCE1_INSTANCE_NAME = "sim-1802 0";
+ private static final String RESOURCE1_INSTANCE_NAME_IN_CSAR = "sim18020";
+ private static final String BLUEPRINT1_NAME = "FOI.Simfoimap223S0112.event_proc_bp.yaml";
@Test
public void testConstructor() throws CsarHandlerException {
IResourceInstance resource1 = Mockito.mock(IResourceInstance.class);
Mockito.when(resource1.getResourceType()).thenReturn("VF");
Mockito.when(resource1.getResourceInvariantUUID()).thenReturn(RESOURCE1_UUID);
+ Mockito.when(resource1.getResourceInstanceName()).thenReturn(RESOURCE1_INSTANCE_NAME);
// Create a fake artifact for resource
IArtifactInfo blueprintArtifact = Mockito.mock(IArtifactInfo.class);
Mockito.when(blueprintArtifact.getArtifactType()).thenReturn(CsarHandler.BLUEPRINT_TYPE);
- Mockito.when(blueprintArtifact.getArtifactName()).thenReturn(BLUEPRINT1_NAME);
List<IArtifactInfo> artifactsListForResource = new ArrayList<>();
artifactsListForResource.add(blueprintArtifact);
Mockito.when(resource1.getArtifacts()).thenReturn(artifactsListForResource);
assertEquals(CSAR_ARTIFACT_NAME, csar.getArtifactElement().getArtifactName());
assertNotNull(csar.getSdcCsarHelper());
// Test dcaeBlueprint
- String blueprint = csar.getDcaeBlueprint();
+ String blueprint = csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getDcaeBlueprint();
assertNotNull(blueprint);
assertTrue(!blueprint.isEmpty());
assertTrue(blueprint.contains("DCAE-VES-PM-EVENT-v1"));
// Test additional properties from Sdc notif
- assertEquals(BLUEPRINT1_NAME, csar.getBlueprintArtifactName());
- assertEquals(RESOURCE1_UUID, csar.getBlueprintInvariantResourceUuid());
- assertEquals(SERVICE_UUID, csar.getBlueprintInvariantServiceUuid());
+ assertEquals(BLUEPRINT1_NAME,
+ csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintArtifactName());
+ assertEquals(RESOURCE1_UUID, csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getResourceAttached()
+ .getResourceInvariantUUID());
+ assertEquals(SERVICE_UUID,
+ csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintInvariantServiceUuid());
// Do some cleanup
Path path = Paths.get(SDC_FOLDER + "/test-controller/" + CSAR_ARTIFACT_NAME);
Files.deleteIfExists(path);
}
+
+ @Test
+ public void testDoubleSave()
+ throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException {
+ CsarHandler csar = new CsarHandler(buildFakeSdcNotification(), "test-controller", "/tmp/csar-handler-tests");
+ // Test the save
+ csar.save(buildFakeSdcResut());
+ assertTrue((new File(SDC_FOLDER + "/test-controller/" + CSAR_ARTIFACT_NAME)).exists());
+ assertEquals(CSAR_ARTIFACT_NAME, csar.getArtifactElement().getArtifactName());
+ assertNotNull(csar.getSdcCsarHelper());
+ // Test dcaeBlueprint
+ String blueprint = csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getDcaeBlueprint();
+ assertNotNull(blueprint);
+ assertTrue(!blueprint.isEmpty());
+ assertTrue(blueprint.contains("DCAE-VES-PM-EVENT-v1"));
+ // Test additional properties from Sdc notif
+ assertEquals(BLUEPRINT1_NAME,
+ csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintArtifactName());
+ assertEquals(RESOURCE1_UUID, csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getResourceAttached()
+ .getResourceInvariantUUID());
+ assertEquals(SERVICE_UUID,
+ csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintInvariantServiceUuid());
+ Path path = Paths.get(SDC_FOLDER + "/test-controller/" + CSAR_ARTIFACT_NAME);
+ // A double save should simply overwrite the existing
+ csar.save(buildFakeSdcResut());
+ // Do some cleanup
+ Files.deleteIfExists(path);
+ }
}