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);
}
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);
}
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());
}
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);
}
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);
}
Aggregations