Search in sources :

Example 26 with Relationship

use of org.onap.aai.domain.yang.Relationship in project so by onap.

the class AAITransactionalClientTest method testUpdate.

@Test
public void testUpdate() throws IOException {
    final Relationship body = new Relationship();
    body.setRelatedLink(uriB.build().toString());
    AAIResourceUri uriAClone = uriA.clone().relationshipAPI();
    AAITransactionalClient transactions = aaiClient.beginTransaction().update(uriAClone, body);
    String serializedTransactions = mapper.writeValueAsString(transactions.getTransactions());
    Map<String, Object> actual = mapper.readValue(serializedTransactions, new TypeReference<Map<String, Object>>() {
    });
    Map<String, Object> expected = mapper.readValue(getJson("test-request-small.json").replace("put", "patch"), new TypeReference<Map<String, Object>>() {
    });
    assertEquals(actual, expected);
}
Also used : Relationship(org.onap.aai.domain.yang.Relationship) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 27 with Relationship

use of org.onap.aai.domain.yang.Relationship in project policy-models by onap.

the class AaiCqResponse method getDefaultGenericVnf.

/**
 * Get the generic vnf associated with the vserver in the custom query.
 *
 * @return Generic VNF
 */
public GenericVnf getDefaultGenericVnf() {
    GenericVnf genericVnf = null;
    // Get the vserver associated with the query
    var vserver = this.getVserver();
    // Get the relationships of the vserver
    List<Relationship> relations = vserver.getRelationshipList().getRelationship();
    // Find the relationship of the genericVNF
    var genericVnfId = "";
    List<RelationshipData> relationshipData = null;
    // relationship data
    for (Relationship r : relations) {
        // Get the name of generic-vnf related to this server
        if (GENERIC_VNF.equals(r.getRelatedTo())) {
            relationshipData = r.getRelationshipData();
        }
    }
    // Iterate through relationship data, and get vnf-id
    for (RelationshipData rd : relationshipData) {
        // Get the id of the generic-vnf
        if ("generic-vnf.vnf-id".equals(rd.getRelationshipKey())) {
            genericVnfId = rd.getRelationshipValue();
        }
    }
    // Get the list of generic vnfs
    List<GenericVnf> genericVnfList = this.getGenericVnfs();
    for (GenericVnf genVnf : genericVnfList) {
        if (genericVnfId.equals(genVnf.getVnfId())) {
            genericVnf = genVnf;
        }
    }
    return genericVnf;
}
Also used : RelationshipData(org.onap.aai.domain.yang.RelationshipData) GenericVnf(org.onap.aai.domain.yang.GenericVnf) Relationship(org.onap.aai.domain.yang.Relationship)

Example 28 with Relationship

use of org.onap.aai.domain.yang.Relationship in project so by onap.

the class GraphInventoryTransactionClient method buildRelationship.

private Relationship buildRelationship(SingleUri uri, Optional<EdgeLabel> label) {
    final Relationship result = new Relationship();
    result.setRelatedLink(uri.build().toString());
    if (label.isPresent()) {
        result.setRelationshipLabel(label.toString());
    }
    return result;
}
Also used : Relationship(org.onap.aai.domain.yang.Relationship)

Aggregations

Relationship (org.onap.aai.domain.yang.Relationship)28 Test (org.junit.Test)11 RelationshipList (org.onap.aai.domain.yang.RelationshipList)11 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)6 VfModule (org.onap.aai.domain.yang.VfModule)5 ArrayList (java.util.ArrayList)4 GenericVnf (org.onap.aai.domain.yang.GenericVnf)4 RelationshipData (org.onap.aai.domain.yang.RelationshipData)4 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)4 Server (org.openstack4j.model.compute.Server)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)3 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)3 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)3 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)3 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 IOException (java.io.IOException)2 List (java.util.List)2