HttpResponseHandler implements IResponseHandler<ChannelHandlerContext, FullHttpResponse> { @Override public void handle(final ChannelHandlerContext ctx, final FullHttpResponse response) throws ResponseHandlerException { try { ScopeProvider.setCurrentScope(currentScope); IOC.resolve(Keys.getOrAdd("cancelTimerOnRequest"), uuid); isReceived = true; FullHttpResponse responseCopy = response.copy(); ITask task = () -> { try { IObject environment = getEnvironment(responseCopy); IMessageProcessingSequence processingSequence = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.message_processing_interfaces.message_processing.IMessageProcessingSequence"), stackDepth, receiverChain); IMessageProcessor messageProcessor = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.message_processing_interfaces.message_processing.IMessageProcessor"), taskQueue, processingSequence); IFieldName messageFieldName = null; messageFieldName = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "message"); IFieldName contextFieldName = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.ifield_name.IFieldName"), "context"); IObject message = (IObject) environment.getValue(messageFieldName); message.setValue(messageMapIdFieldName, messageMapId); IObject context = (IObject) environment.getValue(contextFieldName); messageProcessor.process(message, context); } catch (ChangeValueException | ReadValueException | InvalidArgumentException | ResponseHandlerException | ResolutionException | MessageProcessorProcessException e) { throw new TaskExecutionException(e); } }; taskQueue.put(task); } catch (ScopeProviderException | InterruptedException | ResolutionException e) { throw new ResponseHandlerException(e); } } HttpResponseHandler(final IQueue<ITask> taskQueue, final int stackDepth, final Object receiverChain,
                               final IObject request, final IScope scope); @Override void handle(final ChannelHandlerContext ctx, final FullHttpResponse response);  }
@Test public void testNewTaskAddedToQueue() throws InvalidArgumentException, DeserializationException, InterruptedException, ResponseHandlerException { String chainName = "chainName"; when(response.headers()).thenReturn(headers); when(headers.get("messageMapId")).thenReturn("messageMap"); when(strategy.deserialize(any())).thenReturn(new DSObject("{\"foo\": \"bar\"}")); responseHandler.handle(ctx, response); verify(taskQueue, times(1)).put(any()); }