use of org.onap.aai.domain.yang.L3Network in project so by onap.
the class HeatBridgeImpl method buildAddNetworksToAaiAction.
public void buildAddNetworksToAaiAction(final String genericVnfId, final String vfModuleId, List<Network> networks) {
networks.forEach(network -> {
L3Network l3Network = aaiHelper.buildNetwork(network);
if (l3Network != null) {
l3Network.setSubnets(buildSunets(network));
RelationshipList relationshipList = new RelationshipList();
List<Relationship> relationships = relationshipList.getRelationship();
relationships.add(aaiHelper.getRelationshipToVfModule(genericVnfId, vfModuleId));
relationships.add(aaiHelper.getRelationshipToTenant(cloudOwner, cloudRegionId, tenantId));
l3Network.setRelationshipList(relationshipList);
transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(l3Network.getNetworkId())), Optional.of(l3Network));
}
});
}
use of org.onap.aai.domain.yang.L3Network in project so by onap.
the class BBInputSetupUtils method getRelatedNetworkByNameFromServiceInstance.
public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName) throws MultipleObjectsFoundException {
AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)).relatedTo(Types.L3_NETWORKS.getFragment()).queryParam("network-name", networkName);
Optional<L3Networks> networks = injectionHelper.getAaiClient().get(L3Networks.class, uri);
L3Network network = null;
if (!networks.isPresent()) {
logger.debug("No Networks matched by name");
return Optional.empty();
} else {
if (networks.get().getL3Network().size() > 1) {
String message = String.format("Multiple networks found for service-instance-id: %s and network-name: %s.", serviceInstanceId, networkName);
throw new MultipleObjectsFoundException(message);
} else {
network = networks.get().getL3Network().get(0);
}
return Optional.of(network);
}
}
use of org.onap.aai.domain.yang.L3Network in project so by onap.
the class NetworkBBUtilsTest method isRelationshipRelatedToExistsTrueTest.
@Test
public void isRelationshipRelatedToExistsTrueTest() throws Exception {
final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
assertTrue(isVfModule);
}
use of org.onap.aai.domain.yang.L3Network in project so by onap.
the class AaiResourceIdValidatorTest method validateNetworkResourceIdInAAIDuplicateNameTest.
@Test
public void validateNetworkResourceIdInAAIDuplicateNameTest() throws Exception {
RequestDetails reqDetails = setupRequestDetails();
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId("siId123");
L3Network network = new L3Network();
network.setModelCustomizationId("9999999");
Optional<L3Network> opNetwork = Optional.of(network);
when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
this.expectedException.expect(DuplicateNameException.class);
this.expectedException.expectMessage(containsString("l3Network with name (name123), same parent and different customization id (9999999) already exists. The name must be unique."));
testedObject.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
}
use of org.onap.aai.domain.yang.L3Network in project so by onap.
the class AaiResourceIdValidatorTest method validateResourceIdInAAINetworkTest.
@Test
public void validateResourceIdInAAINetworkTest() throws Exception {
RequestDetails reqDetails = setupRequestDetails();
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId("siId123");
L3Network network = new L3Network();
network.setNetworkId("id123");
network.setModelCustomizationId("1234567");
Optional<L3Network> opNetwork = Optional.of(network);
L3Network network2 = new L3Network();
network2.setNetworkId("id123");
network2.setModelCustomizationId("222");
Optional<L3Network> opNetwork2 = Optional.of(network2);
when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "networkName222")).thenReturn(opNetwork2);
String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123", reqDetails, workflowResourceIds);
assertEquals("id123", id);
String id2 = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111", reqDetails, workflowResourceIds);
assertEquals("generatedId123", id2);
this.expectedException.expect(DuplicateNameException.class);
this.expectedException.expectMessage(containsString("l3Network with name (networkName222), same parent and different customization id (222) already exists. The name must be unique."));
testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName222", reqDetails, workflowResourceIds);
}
Aggregations