Search in sources :

Example 11 with ServiceInstances

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

the class BBInputSetupUtilsTest method getRelatedServiceInstanceFromInstanceGroupMultipleExceptionTest.

@Test
public void getRelatedServiceInstanceFromInstanceGroupMultipleExceptionTest() throws Exception {
    final String instanceGroupId = "ig-001";
    expectedException.expect(MultipleObjectsFoundException.class);
    Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances());
    ServiceInstance si1 = Mockito.mock(ServiceInstance.class);
    ServiceInstance si2 = Mockito.mock(ServiceInstance.class);
    serviceInstances.get().getServiceInstance().add(si1);
    serviceInstances.get().getServiceInstance().add(si2);
    doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIPluralResourceUri.class));
    this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
}
Also used : ServiceInstances(org.onap.aai.domain.yang.ServiceInstances) 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 12 with ServiceInstances

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

the class BBInputSetupUtilsTest method getAAIServiceInstancesGloballyByName_noAAIResourceTest.

@Test
public void getAAIServiceInstancesGloballyByName_noAAIResourceTest() {
    final String serviceInstanceName = "serviceInstanceName";
    doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIPluralResourceUri.class));
    ServiceInstances actualServiceInstances = bbInputSetupUtils.getAAIServiceInstancesGloballyByName(serviceInstanceName);
    assertNull(actualServiceInstances);
}
Also used : ServiceInstances(org.onap.aai.domain.yang.ServiceInstances) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 13 with ServiceInstances

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

the class AaiResourceIdValidatorTest method validateServiceResourceIdInAAIDifferentModelVersionId.

@Test
public void validateServiceResourceIdInAAIDifferentModelVersionId() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    reqDetails.getModelInfo().setModelVersionId("1234567");
    ServiceInstance si = new ServiceInstance();
    si.setModelVersionId("9999999");
    ServiceInstances serviceInstances = new ServiceInstances();
    serviceInstances.getServiceInstance().add(si);
    Optional<ServiceInstance> siOp = Optional.of(si);
    when(bbInputSetupUtilsMock.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
    this.expectedException.expect(DuplicateNameException.class);
    this.expectedException.expectMessage(containsString("serviceInstance with name (siName123) and different version id (1234567) already exists. The name must be unique."));
    String id = testedObject.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails);
    assertEquals("siId123", id);
}
Also used : ServiceInstances(org.onap.aai.domain.yang.ServiceInstances) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Aggregations

ServiceInstances (org.onap.aai.domain.yang.ServiceInstances)13 Test (org.junit.Test)11 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)11 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)6 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)3 HashMap (java.util.HashMap)1 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)1 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)1 DuplicateNameException (org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException)1 MultipleObjectsFoundException (org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException)1 NoServiceInstanceFoundException (org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException)1