use of org.onap.sdc.api.notification.INotificationData in project so by onap.
the class ASDCElementInfoTest method createASDCElementInfoFromVfModuleTest.
@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"));
}
use of org.onap.sdc.api.notification.INotificationData in project so by onap.
the class ASDCNotificationLoggingTest method dumpASDCNotificationTest.
@Test
public void dumpASDCNotificationTest() throws Exception {
INotificationData asdcNotification = iNotificationDataObject();
String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
assertTrue(!result.equalsIgnoreCase("NULL"));
}
use of org.onap.sdc.api.notification.INotificationData in project so by onap.
the class ToscaResourceInstallerTest method createServiceTest.
@Test
public void createServiceTest() {
ToscaResourceStructure toscaResourceStructure = mock(ToscaResourceStructure.class);
ResourceStructure resourceStructure = mock(ResourceStructure.class);
Metadata metadata = mock(Metadata.class);
INotificationData notification = mock(INotificationData.class);
doReturn("e2899e5c-ae35-434c-bada-0fabb7c1b44d").when(toscaResourceStructure).getServiceVersion();
doReturn(metadata).when(toscaResourceStructure).getServiceMetadata();
doReturn("production").when(notification).getWorkloadContext();
doReturn(notification).when(resourceStructure).getNotification();
String serviceType = "test-type";
String serviceRole = "test-role";
String category = "Network L4+";
String description = "Customer Orderable service description";
String name = "Customer Orderable Service";
String uuid = "72db5868-4575-4804-b546-0b0d3c3b5ac6";
String invariantUUID = "6f30bbe3-4590-4185-a7e0-4f9610926c6f";
String namingPolicy = "naming Policy";
String ecompGeneratedNaming = "true";
String environmentContext = "General_Revenue-Bearing";
doReturn(serviceType).when(metadata).getValue("serviceType");
doReturn(serviceRole).when(metadata).getValue("serviceRole");
doReturn(category).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
doReturn(description).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION);
doReturn(name).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
doReturn(uuid).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
doReturn(environmentContext).when(metadata).getValue(metadata.getValue("environmentContext"));
doReturn(invariantUUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
doReturn(namingPolicy).when(metadata).getValue("namingPolicy");
doReturn(ecompGeneratedNaming).when(metadata).getValue("ecompGeneratedNaming");
ISdcCsarHelper iSdcCsarHelper = mock(ISdcCsarHelper.class);
List<Input> serviceInputs = new ArrayList<Input>();
LinkedHashMap<String, Object> value = new LinkedHashMap<String, Object>();
value.put("controller_actor", "SO-REF-DATA");
value.put("type", "string");
Input input = new Input("controller_actor", value, null);
serviceInputs.add(0, input);
value = new LinkedHashMap<String, Object>();
value.put("cds_model_version", "v1.4.0");
value.put("type", "string");
input = new Input("cds_model_version", value, null);
serviceInputs.add(1, input);
value = new LinkedHashMap<String, Object>();
value.put("cds_model_name", "Blueprint140");
value.put("type", "string");
input = new Input("cds_model_name", value, null);
serviceInputs.add(2, input);
value = new LinkedHashMap<String, Object>();
value.put("skip_post_instantiation_configuration", "false");
value.put("type", "boolean");
input = new Input("skip_post_instantiation_configuration", value, null);
serviceInputs.add(3, input);
doReturn(iSdcCsarHelper).when(toscaResourceStructure).getSdcCsarHelper();
doReturn(serviceInputs).when(iSdcCsarHelper).getServiceInputs();
Service service = toscaInstaller.createService(toscaResourceStructure, resourceStructure);
assertNotNull(service);
verify(toscaResourceStructure, times(2)).getServiceVersion();
assertNotNull(service.getNamingPolicy());
assertEquals(serviceType, service.getServiceType());
assertEquals(serviceRole, service.getServiceRole());
assertEquals(category, service.getCategory());
assertEquals(description, service.getDescription());
assertEquals(uuid, service.getModelUUID());
assertEquals(invariantUUID, service.getModelInvariantUUID());
assertEquals(namingPolicy, service.getNamingPolicy());
assertTrue(service.getOnapGeneratedNaming());
}
use of org.onap.sdc.api.notification.INotificationData in project so by onap.
the class ASDCController method processNsstNotification.
private void processNsstNotification(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
try {
String category = serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
boolean isNeedInital = (category.contains("NSST") || category.equalsIgnoreCase("TN Network Requirement")) && iNotif.getResources().isEmpty();
if (isNeedInital) {
String artifactContent = null;
List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
Optional<IArtifactInfo> artifactOpt = serviceArtifacts.stream().filter(e -> e.getArtifactType().equalsIgnoreCase("WORKFLOW")).findFirst();
if (artifactOpt.isPresent()) {
IArtifactInfo artifactInfo = artifactOpt.get();
logger.debug("Ready to parse this serviceArtifactUUID: " + artifactInfo.getArtifactUUID());
String filePath = Paths.get(getMsoConfigPath(), "ASDC", artifactInfo.getArtifactVersion(), artifactInfo.getArtifactName()).normalize().toString();
ZipParser zipParserInstance = ZipParser.getInstance();
artifactContent = zipParserInstance.parseJsonForZip(filePath);
logger.debug("serviceArtifact parsing success! serviceArtifactUUID: " + artifactInfo.getArtifactUUID());
ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
resourceStructure.setResourceType(ResourceType.OTHER);
toscaInstaller.installNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure, artifactContent);
} else {
logger.debug("serviceArtifact is null");
toscaInstaller.installNsstService(toscaResourceStructure, null, null);
}
}
} catch (IOException e) {
logger.error("serviceArtifact parse failure for service uuid: " + serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
} catch (Exception e) {
logger.error("error NSST process resource failure ", e);
}
}
use of org.onap.sdc.api.notification.INotificationData in project so by onap.
the class NotificationLogging method registerForLog.
private static void registerForLog(INotificationData objectToLog) {
INotificationData proxy = (INotificationData) Proxy.newProxyInstance(INotificationData.class.getClassLoader(), new Class[] { INotificationData.class }, NotificationLogging.getHandler());
objectMethodsToLog.put(proxy, new ArrayList<>());
}
Aggregations