Search in sources :

Example 16 with Status

use of org.onap.appc.client.lcm.model.Status in project so by onap.

the class ApplicationControllerTaskImplTest method testExcute_lock.

@Test
public void testExcute_lock() throws JsonProcessingException, ApplicationControllerOrchestratorException {
    request.setAction(Action.Lock);
    Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), "testControllerType", listener, "testRequestorId")).thenReturn(new Status());
    Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
    Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), "testControllerType", listener, "testRequestorId");
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Test(org.junit.Test)

Example 17 with Status

use of org.onap.appc.client.lcm.model.Status in project so by onap.

the class ApplicationControllerTaskImplTest method testExcute_distributeTraffic.

@Test
public void testExcute_distributeTraffic() throws JsonProcessingException, ApplicationControllerOrchestratorException {
    request.setAction(Action.DistributeTraffic);
    Parameters parameters = new Parameters();
    ConfigurationParameters configParams = new ConfigurationParameters();
    configParams.setBookName(request.getBookName());
    configParams.setNodeList(request.getNodeList());
    configParams.setFileParameterContent(request.getFileParameters());
    configParams.setVnfName(request.getApplicationControllerVnf().getVnfName());
    parameters.setConfigurationParameters(configParams);
    Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
    Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", listener, "testRequestorId")).thenReturn(new Status());
    Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
    Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", listener, "testRequestorId");
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Parameters(org.onap.so.adapters.appc.orchestrator.client.beans.Parameters) ConfigurationParameters(org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters) RequestParameters(org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters) ConfigurationParameters(org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters) Test(org.junit.Test)

Example 18 with Status

use of org.onap.appc.client.lcm.model.Status in project so by onap.

the class ApplicationControllerTaskImplTest method testExcute_resumeTraffic.

@Test
public void testExcute_resumeTraffic() throws JsonProcessingException, ApplicationControllerOrchestratorException {
    request.setAction(Action.ResumeTraffic);
    Parameters parameters = new Parameters();
    ConfigurationParameters configParams = new ConfigurationParameters();
    configParams.setVnfName(request.getApplicationControllerVnf().getVnfName());
    parameters.setConfigurationParameters(configParams);
    Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
    Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", listener, "testRequestorId")).thenReturn(new Status());
    Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
    Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", listener, "testRequestorId");
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Parameters(org.onap.so.adapters.appc.orchestrator.client.beans.Parameters) ConfigurationParameters(org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters) RequestParameters(org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters) ConfigurationParameters(org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters) Test(org.junit.Test)

Example 19 with Status

use of org.onap.appc.client.lcm.model.Status in project so by onap.

the class ApplicationControllerTaskImplTest method testExcute_upgradeBackup.

@Test
public void testExcute_upgradeBackup() throws JsonProcessingException, ApplicationControllerOrchestratorException {
    request.setAction(Action.UpgradeBackup);
    Parameters parameters = new Parameters();
    parameters.setExistingSoftwareVersion(request.getExistingSoftwareVersion());
    parameters.setNewSoftwareVersion(request.getNewSoftwareVersion());
    Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters)));
    Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", listener, "testRequestorId")).thenReturn(new Status());
    Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener);
    Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", listener, "testRequestorId");
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Parameters(org.onap.so.adapters.appc.orchestrator.client.beans.Parameters) ConfigurationParameters(org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters) RequestParameters(org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters) Test(org.junit.Test)

Example 20 with Status

use of org.onap.appc.client.lcm.model.Status in project so by onap.

the class ApplicationControllerClient method runCommand.

public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener, String requestorId) throws ApplicationControllerOrchestratorException {
    Status status;
    Object requestObject;
    requestObject = createRequest(action, actionIdentifiers, payload, requestID, requestorId);
    appCSupport.logLCMMessage(requestObject);
    LifeCycleManagerStateful client = getAppCClient();
    Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, true);
    try {
        Object response = lcmMethod.invoke(client, requestObject, listener);
        if (response != null) {
            return appCSupport.getStatusFromGenericResponse(response);
        } else {
            return new Status();
        }
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        throw new RuntimeException(String.format("%s : %s", "Unable to invoke action", action.toString()), e);
    }
}
Also used : Status(org.onap.appc.client.lcm.model.Status) LifeCycleManagerStateful(org.onap.appc.client.lcm.api.LifeCycleManagerStateful) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Status (org.onap.appc.client.lcm.model.Status)42 Test (org.junit.Test)27 HashMap (java.util.HashMap)14 Action (org.onap.appc.client.lcm.model.Action)10 BaseTest (org.onap.so.BaseTest)10 ConfigurationParameters (org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters)8 Parameters (org.onap.so.adapters.appc.orchestrator.client.beans.Parameters)8 RequestParameters (org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters)8 JSONObject (org.json.JSONObject)4 ArrayList (java.util.ArrayList)3 ResumeTrafficOutput (org.onap.appc.client.lcm.model.ResumeTrafficOutput)3 AppcClientException (org.onap.appc.client.lcm.exceptions.AppcClientException)2 ActionIdentifiers (org.onap.appc.client.lcm.model.ActionIdentifiers)2 Payload (org.onap.appc.client.lcm.model.Payload)2 ApplicationControllerCallback (org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback)2 Identity (org.onap.so.adapters.appc.orchestrator.client.beans.Identity)2 ApplicationControllerTaskRequest (org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1