Search in sources :

Example 6 with AAICommonObjectMapperProvider

use of org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider in project so by onap.

the class BBInputSetupTest method testMapPlatform.

@Test
public void testMapPlatform() throws JsonProcessingException {
    org.onap.aai.domain.yang.Platform expectedAAI = new org.onap.aai.domain.yang.Platform();
    Platform expected = new Platform();
    AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
    doReturn(expected).when(bbInputSetupMapperLayer).mapAAIPlatform(isA(org.onap.aai.domain.yang.Platform.class));
    GenericVnf vnf = new GenericVnf();
    SPY_bbInputSetup.mapPlatform(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }), vnf);
    assertEquals(expected, vnf.getPlatform());
}
Also used : Platform(org.onap.so.bpmn.servicedecomposition.bbobjects.Platform) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 7 with AAICommonObjectMapperProvider

use of org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider in project so by onap.

the class BBInputSetupTest method testMapLineOfBusiness.

@Test
public void testMapLineOfBusiness() throws JsonProcessingException {
    org.onap.aai.domain.yang.LineOfBusiness expectedAAI = new org.onap.aai.domain.yang.LineOfBusiness();
    LineOfBusiness expected = new LineOfBusiness();
    AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
    doReturn(expected).when(bbInputSetupMapperLayer).mapAAILineOfBusiness(isA(org.onap.aai.domain.yang.LineOfBusiness.class));
    GenericVnf vnf = new GenericVnf();
    SPY_bbInputSetup.mapLineOfBusiness(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }), vnf);
    assertEquals(expected, vnf.getLineOfBusiness());
}
Also used : ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) LineOfBusiness(org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 8 with AAICommonObjectMapperProvider

use of org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider in project so by onap.

the class CreateAAInventory method doExecute.

@Override
public void doExecute(TestContext context) {
    final Logger logger = LoggerFactory.getLogger(CreateAAInventory.class);
    try {
        String stackName = context.getVariable("stackName");
        if (stackName != null && stackName.equals("replace_module")) {
            String vServerId = "92272b67-d23f-42ca-87fa-7b06a9ec81f3";
            AAIResourcesClient aaiResourceClient = new AAIResourcesClient();
            AAICommonObjectMapperProvider aaiMapper = new AAICommonObjectMapperProvider();
            InputStream vserverFile = new ClassPathResource("openstack/gr_api/CreateAAIInventory.json").getInputStream();
            Vserver vserver = aaiMapper.getMapper().readValue(vserverFile, Vserver.class);
            AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion("cloudOwner", "regionOne").tenant("0422ffb57ba042c0800a29dc85ca70f8").vserver(vServerId));
            aaiResourceClient.create(vserverURI, vserver);
        }
    } catch (Exception e) {
        logger.debug("Exception in CreateAAInventory.doExecute", e);
    }
}
Also used : Vserver(org.onap.aai.domain.yang.Vserver) InputStream(java.io.InputStream) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Logger(org.slf4j.Logger) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 9 with AAICommonObjectMapperProvider

use of org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider in project so by onap.

the class HeatBridgeImplTest method testUpdateVserversToAaiNoHypervisorName.

@Test
@Ignore
public void testUpdateVserversToAaiNoHypervisorName() throws HeatBridgeException, JsonProcessingException {
    AaiHelper aaiHelper = new AaiHelper();
    VfModule module = new VfModule();
    RelationshipList relationships = new RelationshipList();
    List<Relationship> listRelationships = relationships.getRelationship();
    Relationship vnfcRelationship = new Relationship();
    vnfcRelationship.setRelationshipLabel("org.onap.relationships.inventory.Uses");
    vnfcRelationship.setRelatedTo("vnfc");
    vnfcRelationship.setRelatedLink("/aai/v22/network/vnfcs/vnfc/test-server1-name");
    listRelationships.add(vnfcRelationship);
    module.setRelationshipList(relationships);
    AAIResultWrapper wrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(module));
    when(aaiResourcesClient.get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test-genericVnf-id").vfModule("test-vfModule-id")))).thenReturn(wrapper);
    aaiHelper.setAAIResourcesClient(aaiResourcesClient);
    heatbridge.setAAIHelper(aaiHelper);
    // Arrange
    Server server1 = mock(Server.class);
    when(server1.getId()).thenReturn("test-server1-id");
    when(server1.getHypervisorHostname()).thenReturn("");
    when(server1.getName()).thenReturn("test-server1-name");
    when(server1.getStatus()).thenReturn(Status.ACTIVE);
    when(server1.getLinks()).thenReturn(new ArrayList<>());
    Server server2 = mock(Server.class);
    when(server2.getId()).thenReturn("test-server2-id");
    when(server2.getName()).thenReturn("test-server2-name");
    when(server2.getStatus()).thenReturn(Status.ACTIVE);
    when(server2.getLinks()).thenReturn(new ArrayList<>());
    List<Server> servers = Arrays.asList(server1, server2);
    Image image = mock(Image.class);
    when(server1.getImage()).thenReturn(image);
    when(server2.getImage()).thenReturn(image);
    when(image.getId()).thenReturn("test-image-id");
    Flavor flavor = mock(Flavor.class);
    when(server1.getFlavor()).thenReturn(flavor);
    when(server2.getFlavor()).thenReturn(flavor);
    when(flavor.getId()).thenReturn("test-flavor-id");
    // Act
    heatbridge.buildAddVserversToAaiAction("test-genericVnf-id", "test-vfModule-id", servers);
    // Assert
    ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class);
    verify(transaction, times(2)).create(captor.capture(), any());
    List<AAIResourceUri> uris = captor.getAllValues();
    assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server1.getId())), uris.get(0));
    assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server2.getId())), uris.get(1));
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) Server(org.openstack4j.model.compute.Server) AaiHelper(org.onap.so.heatbridge.helpers.AaiHelper) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Image(org.openstack4j.model.compute.Image) VfModule(org.onap.aai.domain.yang.VfModule) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) Flavor(org.openstack4j.model.compute.Flavor) Relationship(org.onap.aai.domain.yang.Relationship) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with AAICommonObjectMapperProvider

use of org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider in project so by onap.

the class HeatBridgeImplTest method testUpdateVserversToAai.

@Test
@Ignore
public void testUpdateVserversToAai() throws HeatBridgeException, JsonProcessingException {
    AaiHelper helper = new AaiHelper();
    helper.setAAIResourcesClient(resourcesClient);
    heatbridge.setAAIHelper(helper);
    VfModule module = new VfModule();
    RelationshipList relationships = new RelationshipList();
    List<Relationship> listRelationships = relationships.getRelationship();
    Relationship vnfcRelationship = new Relationship();
    vnfcRelationship.setRelationshipLabel("org.onap.relationships.inventory.Uses");
    vnfcRelationship.setRelatedTo("vnfc");
    vnfcRelationship.setRelatedLink("/aai/v22/network/vnfcs/vnfc/test-server1-name");
    listRelationships.add(vnfcRelationship);
    module.setRelationshipList(relationships);
    AAIResultWrapper wrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(module));
    when(aaiResourcesClient.get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test-genericVnf-id").vfModule("test-vfModule-id")))).thenReturn(wrapper);
    // Arrange
    Server server1 = mock(Server.class);
    when(server1.getId()).thenReturn("test-server1-id");
    when(server1.getHypervisorHostname()).thenReturn("test-hypervisor");
    when(server1.getName()).thenReturn("test-server1-name");
    when(server1.getStatus()).thenReturn(Status.ACTIVE);
    when(server1.getLinks()).thenReturn(new ArrayList<>());
    Server server2 = mock(Server.class);
    when(server2.getId()).thenReturn("test-server2-id");
    when(server2.getHypervisorHostname()).thenReturn("");
    when(server2.getName()).thenReturn("test-server2-name");
    when(server2.getStatus()).thenReturn(Status.ACTIVE);
    when(server2.getLinks()).thenReturn(new ArrayList<>());
    List<Server> servers = Arrays.asList(server1, server2);
    Image image = mock(Image.class);
    when(server1.getImage()).thenReturn(image);
    when(server2.getImage()).thenReturn(image);
    when(image.getId()).thenReturn("test-image-id");
    Flavor flavor = mock(Flavor.class);
    when(server1.getFlavor()).thenReturn(flavor);
    when(server2.getFlavor()).thenReturn(flavor);
    when(flavor.getId()).thenReturn("test-flavor-id");
    // Act
    heatbridge.buildAddVserversToAaiAction("test-genericVnf-id", "test-vfModule-id", servers);
    // Assert
    ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class);
    verify(transaction, times(2)).create(captor.capture(), any());
    List<AAIResourceUri> uris = captor.getAllValues();
    assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server1.getId())), uris.get(0));
    assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server2.getId())), uris.get(1));
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) Server(org.openstack4j.model.compute.Server) AaiHelper(org.onap.so.heatbridge.helpers.AaiHelper) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Image(org.openstack4j.model.compute.Image) VfModule(org.onap.aai.domain.yang.VfModule) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) Flavor(org.openstack4j.model.compute.Flavor) Relationship(org.onap.aai.domain.yang.Relationship) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)22 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)20 Test (org.junit.Test)17 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)8 ArrayList (java.util.ArrayList)7 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)5 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 Relationship (org.onap.aai.domain.yang.Relationship)3 RelationshipList (org.onap.aai.domain.yang.RelationshipList)3 VfModule (org.onap.aai.domain.yang.VfModule)3 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)3 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)3 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)3 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)3 AaiHelper (org.onap.so.heatbridge.helpers.AaiHelper)3 Server (org.openstack4j.model.compute.Server)3 Ignore (org.junit.Ignore)2 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)2 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)2 Flavor (org.openstack4j.model.compute.Flavor)2