Search in sources :

Example 1 with NamingRequestObject

use of org.onap.so.client.namingservice.NamingRequestObject in project so by onap.

the class NamingServiceCreateTasks method createVpnBondingServiceName.

public void createVpnBondingServiceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
    ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
    L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
    VpnBinding vpnBinding = extractPojosForBB.extractByKey(execution, ResourceKey.VPN_ID);
    NamingRequestObject namingRequestObject = new NamingRequestObject();
    namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
    namingRequestObject.setPolicyInstanceNameValue(serviceInstance.getModelInfoServiceInstance().getNamingPolicy());
    namingRequestObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
    namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName());
    namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion());
    namingRequestObject.setNetworkNameValue(network.getNetworkName());
    namingRequestObject.setVpnNameValue(vpnBinding.getVpnName());
    namingRequestObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
    String generatedVpnBondingServiceName = "";
    try {
        generatedVpnBondingServiceName = namingServiceResources.generateServiceInstanceName(namingRequestObject);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
    serviceInstance.setServiceInstanceName(generatedVpnBondingServiceName);
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) NamingRequestObject(org.onap.so.client.namingservice.NamingRequestObject) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 2 with NamingRequestObject

use of org.onap.so.client.namingservice.NamingRequestObject in project so by onap.

the class NamingServiceDeleteTasks method deleteServiceInstanceName.

public void deleteServiceInstanceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
    ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
    NamingRequestObject namingRequestObject = new NamingRequestObject();
    namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
    try {
        namingServiceResources.deleteServiceInstanceName(namingRequestObject);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) NamingRequestObject(org.onap.so.client.namingservice.NamingRequestObject) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 3 with NamingRequestObject

use of org.onap.so.client.namingservice.NamingRequestObject in project so by onap.

the class NamingServiceResourcesTest method deleteServiceInstanceNameTest.

@Test
public void deleteServiceInstanceNameTest() throws Exception {
    NameGenDeleteRequest req = new NameGenDeleteRequest();
    doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenDeleteRequestMapper(isA(List.class));
    NamingRequestObject nrObject = new NamingRequestObject();
    nrObject.setExternalKeyValue("testExternalKey");
    nrObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
    namingServiceResources.deleteServiceInstanceName(nrObject);
    verify(MOCK_namingClient, times(1)).deleteNameGenRequest(any(NameGenDeleteRequest.class));
}
Also used : NameGenDeleteRequest(org.onap.namingservice.model.NameGenDeleteRequest) List(java.util.List) NamingRequestObject(org.onap.so.client.namingservice.NamingRequestObject) Test(org.junit.Test)

Example 4 with NamingRequestObject

use of org.onap.so.client.namingservice.NamingRequestObject in project so by onap.

the class NamingServiceResourcesTest method generateServiceInstanceNameTest.

@Test
public void generateServiceInstanceNameTest() throws Exception {
    NameGenRequest req = new NameGenRequest();
    doReturn("generatedServiceInstanceName").when(MOCK_namingClient).postNameGenRequest(isA(NameGenRequest.class));
    doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenRequestMapper(isA(List.class));
    NamingRequestObject nrObject = new NamingRequestObject();
    nrObject.setExternalKeyValue("testExternalKey");
    nrObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
    nrObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
    nrObject.setPolicyInstanceNameValue(execution.getVariable("policyInstanceName"));
    nrObject.setServiceModelNameValue("testServiceInstanceModelName");
    nrObject.setModelVersionValue("testServiceInstanceModelVersion");
    nrObject.setZoneIdValue(execution.getVariable("zoneId"));
    String generatedName = namingServiceResources.generateServiceInstanceName(nrObject);
    verify(MOCK_namingClient, times(1)).postNameGenRequest(any(NameGenRequest.class));
    assertEquals("generatedServiceInstanceName", generatedName);
}
Also used : NameGenRequest(org.onap.namingservice.model.NameGenRequest) List(java.util.List) NamingRequestObject(org.onap.so.client.namingservice.NamingRequestObject) Test(org.junit.Test)

Example 5 with NamingRequestObject

use of org.onap.so.client.namingservice.NamingRequestObject in project so by onap.

the class NamingServiceCreateTasks method createWanTransportServiceName.

public void createWanTransportServiceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
    ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
    NamingRequestObject namingRequestObject = new NamingRequestObject();
    namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
    namingRequestObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
    namingRequestObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
    namingRequestObject.setPolicyInstanceNameValue(serviceInstance.getModelInfoServiceInstance().getNamingPolicy());
    namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName());
    namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion());
    String generatedWanTransportServiceName = "";
    try {
        generatedWanTransportServiceName = namingServiceResources.generateServiceInstanceName(namingRequestObject);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
    serviceInstance.setServiceInstanceName(generatedWanTransportServiceName);
}
Also used : ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) NamingRequestObject(org.onap.so.client.namingservice.NamingRequestObject) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Aggregations

NamingRequestObject (org.onap.so.client.namingservice.NamingRequestObject)5 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)3 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)3 List (java.util.List)2 Test (org.junit.Test)2 NameGenDeleteRequest (org.onap.namingservice.model.NameGenDeleteRequest)1 NameGenRequest (org.onap.namingservice.model.NameGenRequest)1 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)1 VpnBinding (org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding)1