use of org.onap.aai.domain.yang.L3Network in project so by onap.
the class ProcessNetwork method doExecute.
@Override
public void doExecute(TestContext context) {
final Logger logger = LoggerFactory.getLogger(ProcessNetwork.class);
try {
int random = (new SecureRandom()).nextInt(50) + 1;
AAIResourcesClient aaiResourceClient = new AAIResourcesClient();
if (context.getVariable("action").equals("assign")) {
String networkId = context.getVariable("generatedNetworkId");
AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId));
L3Network network = new L3Network();
network.setNetworkId(networkId);
network.setNetworkName(context.getVariable("networkName"));
network.setNetworkType(context.getVariable("networkType"));
network.setNetworkTechnology("SR_IOV");
network.setPhysicalNetworkName("PhysicalNetwork" + random);
aaiResourceClient.create(networkURI, network);
} else if (context.getVariable("action").equals("delete")) {
String networkId = context.getVariable("networkId");
AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId));
aaiResourceClient.delete(networkURI);
}
} catch (Exception e) {
logger.debug("Exception in ProcessNetwork.doExecute", e);
}
}
use of org.onap.aai.domain.yang.L3Network in project so by onap.
the class BBInputSetupUtilsTest method getRelatedNetworkByNameFromServiceInstanceTest.
@Test
public void getRelatedNetworkByNameFromServiceInstanceTest() throws Exception {
final String networkId = "id123";
final String networkName = "name123";
Optional<L3Networks> expected = Optional.of(new L3Networks());
L3Network network = new L3Network();
network.setNetworkId(networkId);
network.setNetworkName(networkName);
expected.get().getL3Network().add(network);
doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIPluralResourceUri.class));
Optional<L3Network> actual = bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(networkId, networkName);
assertTrue(actual.isPresent());
assertEquals(networkId, actual.get().getNetworkId());
assertEquals(networkName, actual.get().getNetworkName());
assertEquals(expected.get().getL3Network().get(0).getNetworkId(), actual.get().getNetworkId());
}
use of org.onap.aai.domain.yang.L3Network in project so by onap.
the class BBInputSetupUtilsTest method getAICVpnBindingFromNetwork_noVpnBindingTest.
@Test
public void getAICVpnBindingFromNetwork_noVpnBindingTest() throws IOException {
L3Network l3Network = mapper.readValue(new File(RESOURCE_PATH + "aaiL3NetworkInputWithSubnets.json"), L3Network.class);
Optional<VpnBinding> actual = bbInputSetupUtils.getAICVpnBindingFromNetwork(l3Network);
assertEquals(Optional.empty(), actual);
}
use of org.onap.aai.domain.yang.L3Network in project so by onap.
the class NetworkBBUtilsTest method isRelationshipRelatedToExistsFalseTest.
@Test
public void isRelationshipRelatedToExistsFalseTest() throws Exception {
final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAAIResponse.json")));
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
assertFalse(isVfModule);
}
use of org.onap.aai.domain.yang.L3Network in project so by onap.
the class AaiResourceIdValidatorTest method validateNetworkResourceIdInAAISameModelCustIdTest.
@Test
public void validateNetworkResourceIdInAAISameModelCustIdTest() 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);
when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
String id = testedObject.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
assertEquals("id123", id);
}
Aggregations