@Override public void processEvent(OperationRequest operation, Event event) throws InvalidRequestException { // Create JSON-RPC error response. if (event.getType() == EventType.OPERATION_ERROR) { constructErrorResponse(operation, OperationErrorEvent.as(event).getMessage()); return; } // Create JSON-RPC success response. try { constructResponse(operation, EventSerializer.extractPropertiesToParamsPropertyMap(event)); } catch (EventSerializationException e) { LOG.severe("Internal Error occurred, when serializing events", e); throw new InvalidRequestException("Unable to serialize events", operation); } }
public void testConstructErrorResponse() { operationContext.constructErrorResponse(request, ERROR_MESSAGE); JsonRpcResponse response = operationContext.getResponse(request.getId()); assertTrue("Expected error response", response.isError()); assertEquals("Expected provided error message", ERROR_MESSAGE, response.getErrorMessage()); assertEquals("Expected operation id not to change", OPERATION_ID, response.getId()); }
public void testConstructErrorResponse() { operationContext.constructErrorResponse(request, ERROR_MESSAGE); JsonRpcResponse response = operationContext.getResponse(request.getId()); assertTrue("Expected error response", response.isError()); assertEquals("Expected provided error message", ERROR_MESSAGE, response.getErrorMessage()); assertEquals("Expected operation id not to change", OPERATION_ID, response.getId()); }