Search in sources :

Example 6 with ServiceInstance

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

the class BBInputSetupUtilsTest method getAAIServiceInstanceByNameTest.

@Test
public void getAAIServiceInstanceByNameTest() throws Exception {
    final String serviceInstanceName = "serviceInstanceName";
    ServiceInstance expectedServiceInstance = new ServiceInstance();
    expectedServiceInstance.setServiceInstanceId("serviceInstanceId");
    ServiceSubscription serviceSubscription = new ServiceSubscription();
    serviceSubscription.setServiceType("serviceType");
    Customer customer = new Customer();
    customer.setGlobalCustomerId("globalCustomerId");
    customer.setServiceSubscription(serviceSubscription);
    ServiceInstances serviceInstances = new ServiceInstances();
    serviceInstances.getServiceInstance().add(expectedServiceInstance);
    AAIPluralResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()).serviceSubscription(customer.getServiceSubscription().getServiceType()).serviceInstances()).queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO);
    bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer);
    verify(MOCK_aaiResourcesClient, times(1)).getOne(org.onap.aai.domain.yang.ServiceInstances.class, org.onap.aai.domain.yang.ServiceInstance.class, expectedUri);
}
Also used : ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ServiceInstances(org.onap.aai.domain.yang.ServiceInstances) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 7 with ServiceInstance

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

the class AaiResourceIdValidatorTest method validateServiceResourceIdInAAISameModelVersionId.

@Test
public void validateServiceResourceIdInAAISameModelVersionId() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    reqDetails.getModelInfo().setModelVersionId("1234567");
    ServiceInstance si = new ServiceInstance();
    si.setServiceInstanceId("siId123");
    si.setModelVersionId("1234567");
    Optional<ServiceInstance> siOp = Optional.of(si);
    when(bbInputSetupUtilsMock.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
    String id = testedObject.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails);
    assertEquals("siId123", id);
}
Also used : ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 8 with ServiceInstance

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

the class AaiResourceIdValidatorTest method validateResourceIdInAAIMultipleSITest.

@Test
public void validateResourceIdInAAIMultipleSITest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    reqDetails.getModelInfo().setModelVersionId("1234567");
    ServiceInstance si = new ServiceInstance();
    ServiceInstances serviceInstances = new ServiceInstances();
    serviceInstances.getServiceInstance().add(si);
    ServiceInstance si2 = new ServiceInstance();
    serviceInstances.getServiceInstance().add(si2);
    when(bbInputSetupUtilsMock.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
    this.expectedException.expect(DuplicateNameException.class);
    this.expectedException.expectMessage(containsString("serviceInstance with name (siName123) and multiple combination of model-version-id + service-type + global-customer-id already exists. The name must be unique."));
    testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails, new WorkflowResourceIds());
}
Also used : ServiceInstances(org.onap.aai.domain.yang.ServiceInstances) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Test(org.junit.Test)

Example 9 with ServiceInstance

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

the class AaiResourceIdValidatorTest method validateServiceResourceIdInAAIDuplicateNameMultipleTest.

@Test
public void validateServiceResourceIdInAAIDuplicateNameMultipleTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    ServiceInstances serviceInstances = new ServiceInstances();
    serviceInstances.getServiceInstance().add(new ServiceInstance());
    serviceInstances.getServiceInstance().add(new ServiceInstance());
    when(bbInputSetupUtilsMock.getAAIServiceInstancesGloballyByName("siName")).thenReturn(serviceInstances);
    this.expectedException.expect(DuplicateNameException.class);
    this.expectedException.expectMessage(containsString("serviceInstance with name (siName) and multiple combination of model-version-id + service-type + global-customer-id already exists. The name must be unique."));
    testedObject.validateServiceResourceIdInAAI("generatedId123", "siName", reqDetails);
}
Also used : ServiceInstances(org.onap.aai.domain.yang.ServiceInstances) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 10 with ServiceInstance

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

the class AaiResourceIdValidatorTest method validateServiceResourceIdInAAIDuplicateNameTest.

@Test
public void validateServiceResourceIdInAAIDuplicateNameTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    ServiceInstance si = new ServiceInstance();
    si.setModelVersionId("1234567");
    ServiceInstances serviceInstances = new ServiceInstances();
    serviceInstances.getServiceInstance().add(si);
    when(bbInputSetupUtilsMock.getAAIServiceInstancesGloballyByName("siName")).thenReturn(serviceInstances);
    this.expectedException.expect(DuplicateNameException.class);
    this.expectedException.expectMessage(containsString("serviceInstance with name (siName) and global-customer-id (null), service-type (null), model-version-id (1234567) already exists. The name must be unique."));
    testedObject.validateServiceResourceIdInAAI("generatedId123", "siName", reqDetails);
}
Also used : ServiceInstances(org.onap.aai.domain.yang.ServiceInstances) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Aggregations

ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)33 Test (org.junit.Test)27 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)14 ArrayList (java.util.ArrayList)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 List (java.util.List)12 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)12 ServiceInstances (org.onap.aai.domain.yang.ServiceInstances)11 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)11 RelationshipList (org.onap.aai.domain.yang.RelationshipList)9 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)9 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)8 GenericVnf (org.onap.aai.domain.yang.GenericVnf)8 VfModule (org.onap.aai.domain.yang.VfModule)8 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)8 OrchestrationFlow (org.onap.so.db.catalog.beans.macro.OrchestrationFlow)8 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)6 IOException (java.io.IOException)4 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)4 Relationship (org.onap.aai.domain.yang.Relationship)4