use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.
the class ServiceLevelUpgradeTest method workflow_validInput_expectedOutput.
@Test
public void workflow_validInput_expectedOutput() throws InterruptedException {
mockCatalogDb();
mockRequestDb();
mockAai();
grpcNettyServer.resetList();
final String msoRequestId = UUID.randomUUID().toString();
executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId);
final String testBusinessKey = UUID.randomUUID().toString();
logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey);
ProcessInstance pi = runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables);
int waitCount = 10;
while (!isProcessInstanceEnded() && waitCount >= 0) {
Thread.sleep(WORKFLOW_WAIT_TIME);
waitCount--;
}
// Layout is to reflect the bpmn visual layout
assertThat(pi).isEnded().hasPassedInOrder("Event_02mc8tr", "Activity_18vue7u", "Activity_09bqns0", "Activity_02vp5np", "Activity_0n17xou", "Gateway_1nr51kr", "Activity_0snmatn", "Activity_0e6w886", "Activity_1q4o9fx", "Gateway_02fectw", "Activity_1hp67qz", "Gateway_18ch73t", "Activity_0ft7fa2", "Gateway_1vq11i7", "Activity_0o2rrag", "Activity_1n4rk7m", "Activity_1lz38px", "Event_12983th");
List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
assertEquals(10, detailedMessages.size());
int count = 0;
String action = "";
try {
for (ExecutionServiceInput eSI : detailedMessages) {
action = actionNames[count];
if (action.equals(eSI.getActionIdentifiers().getActionName()) && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) {
checkWithActionName(eSI, action, pnfNames[count]);
count++;
}
}
} catch (Exception e) {
e.printStackTrace();
fail("GenericPnfSoftwareUpgrade request exception", e);
}
assertTrue(count == actionNames.length);
}
use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.
the class CDSProcessingClientTest method testSendMessage.
@Test
public void testSendMessage() throws Exception {
ExecutionServiceInput fakeRequest1 = ExecutionServiceInput.newBuilder().setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("request1").build()).build();
ExecutionServiceOutput fakeResponse1 = ExecutionServiceOutput.newBuilder().setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("response1").build()).build();
ExecutionServiceOutput fakeResponse2 = ExecutionServiceOutput.newBuilder().setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("response2").build()).build();
CountDownLatch finishLatch = client.sendRequest(fakeRequest1);
// request message sent and delivered for one time
assertTrue(allRequestsDelivered.await(1, TimeUnit.SECONDS));
assertEquals(Collections.singletonList("request1"), messagesDelivered);
// Let the server send out two simple response messages
// and verify that the client receives them.
responseObserverRef.get().onNext(fakeResponse1);
verify(listener).onMessage(fakeResponse1);
responseObserverRef.get().onNext(fakeResponse2);
verify(listener).onMessage(fakeResponse2);
// let server complete.
responseObserverRef.get().onCompleted();
assertTrue(finishLatch.await(1, TimeUnit.SECONDS));
}
use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.
the class CDSProcessingClientTest method setUp.
@Before
public void setUp() throws Exception {
String serverName = InProcessServerBuilder.generateName();
grpcCleanup.register(InProcessServerBuilder.forName(serverName).fallbackHandlerRegistry(serviceRegistry).directExecutor().build().start());
handler = new CDSProcessingHandler(listener);
client = new CDSProcessingClient(InProcessChannelBuilder.forName(serverName).directExecutor().build(), handler);
final BluePrintProcessingServiceImplBase routeChatImpl = new BluePrintProcessingServiceImplBase() {
@Override
public StreamObserver<ExecutionServiceInput> process(StreamObserver<ExecutionServiceOutput> responseObserver) {
responseObserverRef.set(responseObserver);
StreamObserver<ExecutionServiceInput> requestObserver = new StreamObserver<ExecutionServiceInput>() {
@Override
public void onNext(ExecutionServiceInput message) {
messagesDelivered.add(message.getActionIdentifiers().getActionName());
}
@Override
public void onError(Throwable t) {
}
@Override
public void onCompleted() {
allRequestsDelivered.countDown();
}
};
return requestObserver;
}
};
serviceRegistry.addService(routeChatImpl);
}
use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.
the class CDSProcessingClientTest method testSendMessageFail.
@Test
public void testSendMessageFail() throws Exception {
ExecutionServiceInput fakeRequest1 = ExecutionServiceInput.newBuilder().setActionIdentifiers(ActionIdentifiers.newBuilder().setActionName("request1").build()).build();
CountDownLatch finishLatch = client.sendRequest(fakeRequest1);
responseObserverRef.get().onError(new Throwable("fail test"));
verify(listener).onError(any(Throwable.class));
assertTrue(finishLatch.await(1, TimeUnit.SECONDS));
}
Aggregations