public void refactor_testSerializeAndDeserializeOperationErrorEvent() throws Exception { Wavelet wavelet = mock(Wavelet.class); EventMessageBundle bundle = new EventMessageBundle("http://10.1.1.1", "http://wave-active-api.example.com"); OperationErrorEvent expected = new OperationErrorEvent(wavelet, bundle, "foo@google.com", 123l, "op1", "Error!"); Context context = new Context(); Event actual = EventSerializer.deserialize(wavelet, bundle, EventSerializer.serialize(expected, context), context); assertEquals(expected, actual); }
@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); } }
break; case OPERATION_ERROR: onOperationError(OperationErrorEvent.as(event)); break;
public void refactor_testSerializeAndDeserializeOperationErrorEvent() throws Exception { Wavelet wavelet = mock(Wavelet.class); EventMessageBundle bundle = new EventMessageBundle("http://10.1.1.1", "http://wave-active-api.example.com"); OperationErrorEvent expected = new OperationErrorEvent(wavelet, bundle, "foo@google.com", 123l, "op1", "Error!"); Context context = new Context(); Event actual = EventSerializer.deserialize(wavelet, bundle, EventSerializer.serialize(expected, context), context); assertEquals(expected, actual); }
public void testProcessErrorEvent() throws Exception { // A randomly selected non-error event Event event = new OperationErrorEvent(null, null, USERNAME, 0L, OPERATION_ID, ERROR_MESSAGE); operationContext.processEvent(request, event); 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 testProcessErrorEvent() throws Exception { // A randomly selected non-error event Event event = new OperationErrorEvent(null, null, USERNAME, 0L, OPERATION_ID, ERROR_MESSAGE); operationContext.processEvent(request, event); 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()); }