use of org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException in project so by onap.
the class MultipleObjectsFoundExceptionTest method messageAndCauseConstructorTest.
@Test
public void messageAndCauseConstructorTest() {
MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE, CAUSE);
assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage());
assertEquals(CAUSE, MultipleObjectsFoundException.getCause());
}
use of org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException in project so by onap.
the class MultipleObjectsFoundExceptionTest method causeConstructorTest.
@Test
public void causeConstructorTest() {
MultipleObjectsFoundException = new MultipleObjectsFoundException(CAUSE);
assertEquals(CAUSE.toString(), MultipleObjectsFoundException.getMessage());
assertEquals(CAUSE, MultipleObjectsFoundException.getCause());
}
use of org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException in project so by onap.
the class MultipleObjectsFoundExceptionTest method messageConstructorTest.
@Test
public void messageConstructorTest() {
MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE);
assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage());
assertEquals(null, MultipleObjectsFoundException.getCause());
}
use of org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException in project so by onap.
the class BBInputSetupUtils method getRelatedServiceInstanceFromInstanceGroup.
public Optional<ServiceInstance> getRelatedServiceInstanceFromInstanceGroup(String instanceGroupId) throws Exception {
AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroupId)).relatedTo(Types.SERVICE_INSTANCES.getFragment());
Optional<ServiceInstances> serviceInstances = injectionHelper.getAaiClient().get(ServiceInstances.class, uri);
ServiceInstance serviceInstance = null;
if (!serviceInstances.isPresent()) {
logger.debug("No ServiceInstances were found");
return Optional.empty();
} else {
if (serviceInstances.get().getServiceInstance().isEmpty()) {
throw new NoServiceInstanceFoundException("No ServiceInstances Returned");
} else if (serviceInstances.get().getServiceInstance().size() > 1) {
String message = String.format("Mulitple service instances were found for instance-group-id: %s.", instanceGroupId);
throw new MultipleObjectsFoundException(message);
} else {
serviceInstance = serviceInstances.get().getServiceInstance().get(0);
}
return Optional.of(serviceInstance);
}
}
use of org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException in project so by onap.
the class BBInputSetupUtils method getRelatedNetworkByNameFromServiceInstance.
public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName) throws MultipleObjectsFoundException {
AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)).relatedTo(Types.L3_NETWORKS.getFragment()).queryParam("network-name", networkName);
Optional<L3Networks> networks = injectionHelper.getAaiClient().get(L3Networks.class, uri);
L3Network network = null;
if (!networks.isPresent()) {
logger.debug("No Networks matched by name");
return Optional.empty();
} else {
if (networks.get().getL3Network().size() > 1) {
String message = String.format("Multiple networks found for service-instance-id: %s and network-name: %s.", serviceInstanceId, networkName);
throw new MultipleObjectsFoundException(message);
} else {
network = networks.get().getL3Network().get(0);
}
return Optional.of(network);
}
}
Aggregations