public void testPutNonTemporaryBlip() throws Exception { // Non temporary blip is ignored Conversation conversation = mock(Conversation.class); ConversationBlip blip = mock(ConversationBlip.class); String blipId = "b+1234"; when(blip.getId()).thenReturn(blipId); when(conversation.getBlip(blipId)).thenReturn(blip); operationContext.putBlip(blip.getId(), blip); assertEquals(operationContext.getBlip(conversation, blipId), blip); }
public void testPutTemporaryBlip() throws Exception { Conversation conversation = mock(Conversation.class); ConversationBlip blip = mock(ConversationBlip.class); String tempBlipId = OperationContextImpl.TEMP_ID_MARKER + "random"; String blipId = "b+1234"; when(blip.getId()).thenReturn(blipId); when(conversation.getBlip(blipId)).thenReturn(blip); operationContext.putBlip(tempBlipId, blip); assertEquals("Expected blip for the given tempId", operationContext.getBlip(conversation, tempBlipId), blip); assertEquals("Expected blip when its non temporary id is given", operationContext.getBlip(conversation, blipId), blip); } }
public void testPutTemporaryBlip() throws Exception { Conversation conversation = mock(Conversation.class); ConversationBlip blip = mock(ConversationBlip.class); String tempBlipId = OperationContextImpl.TEMP_ID_MARKER + "random"; String blipId = "b+1234"; when(blip.getId()).thenReturn(blipId); when(conversation.getBlip(blipId)).thenReturn(blip); operationContext.putBlip(tempBlipId, blip); assertEquals("Expected blip for the given tempId", operationContext.getBlip(conversation, tempBlipId), blip); assertEquals("Expected blip when its non temporary id is given", operationContext.getBlip(conversation, blipId), blip); } }
/** * Tests opening a wavelet that has to be retrieved using the * {@link WaveletProvider}. */ public void testOpenWaveletFromWaveletProvider() throws Exception { OpBasedWavelet opBasedWavelet = wavelet.getOpBasedWavelet(PARTICIPANT); assertEquals(opBasedWavelet, operationContext.openWavelet(WAVE_ID, WAVELET_ID, PARTICIPANT)); }
public void testPutNonTemporaryBlip() throws Exception { // Non temporary blip is ignored Conversation conversation = mock(Conversation.class); ConversationBlip blip = mock(ConversationBlip.class); String blipId = "b+1234"; when(blip.getId()).thenReturn(blipId); when(conversation.getBlip(blipId)).thenReturn(blip); operationContext.putBlip(blip.getId(), blip); assertEquals(operationContext.getBlip(conversation, blipId), blip); }
/** * Tests opening a wavelet that has to be retrieved using the * {@link WaveletProvider}. */ public void testOpenWaveletFromWaveletProvider() throws Exception { OpBasedWavelet opBasedWavelet = wavelet.getOpBasedWavelet(PARTICIPANT); assertEquals(opBasedWavelet, operationContext.openWavelet(WAVE_ID, WAVELET_ID, PARTICIPANT)); }
public void testConstructResponse() { Map<ParamsProperty, Object> data = Maps.newHashMap(); data.put(ParamsProperty.PARTICIPANT_ID, USERNAME); operationContext.constructResponse(request, data); JsonRpcResponse response = operationContext.getResponse(request.getId()); assertFalse("Expected non-error response", response.isError()); assertEquals("Expected operation id not to change", OPERATION_ID, response.getId()); assertEquals("Expected payload not to change", data, response.getData()); }
public void testConstructResponse() { Map<ParamsProperty, Object> data = Maps.newHashMap(); data.put(ParamsProperty.PARTICIPANT_ID, USERNAME); operationContext.constructResponse(request, data); JsonRpcResponse response = operationContext.getResponse(request.getId()); assertFalse("Expected non-error response", response.isError()); assertEquals("Expected operation id not to change", OPERATION_ID, response.getId()); assertEquals("Expected payload not to change", data, response.getData()); }
public void testPutNonTemporaryWavelet() throws Exception { OpBasedWavelet opBasedWavelet = wavelet.getOpBasedWavelet(PARTICIPANT); operationContext.putWavelet(WAVE_ID, WAVELET_ID, wavelet); assertEquals(opBasedWavelet, operationContext.openWavelet(WAVE_ID, WAVELET_ID, PARTICIPANT)); }
public void testPutTemporaryWavelet() throws Exception { OpBasedWavelet opBasedWavelet = wavelet.getOpBasedWavelet(PARTICIPANT); WaveId tempWaveId = WaveId.of("example.com", OperationContextImpl.TEMP_ID_MARKER + "random"); WaveletId tempWaveletId = WaveletId.of("example.com", "conv+root"); operationContext.putWavelet(tempWaveId, tempWaveletId, wavelet); assertEquals( opBasedWavelet, operationContext.openWavelet(tempWaveId, tempWaveletId, PARTICIPANT)); assertEquals(opBasedWavelet, operationContext.openWavelet(WAVE_ID, WAVELET_ID, PARTICIPANT)); }
public void testPutNonTemporaryWavelet() throws Exception { OpBasedWavelet opBasedWavelet = wavelet.getOpBasedWavelet(PARTICIPANT); operationContext.putWavelet(WAVE_ID, WAVELET_ID, wavelet); assertEquals(opBasedWavelet, operationContext.openWavelet(WAVE_ID, WAVELET_ID, PARTICIPANT)); }
public void testPutTemporaryWavelet() throws Exception { OpBasedWavelet opBasedWavelet = wavelet.getOpBasedWavelet(PARTICIPANT); WaveId tempWaveId = WaveId.of("example.com", OperationContextImpl.TEMP_ID_MARKER + "random"); WaveletId tempWaveletId = WaveletId.of("example.com", "conv+root"); operationContext.putWavelet(tempWaveId, tempWaveletId, wavelet); assertEquals( opBasedWavelet, operationContext.openWavelet(tempWaveId, tempWaveletId, PARTICIPANT)); assertEquals(opBasedWavelet, operationContext.openWavelet(WAVE_ID, WAVELET_ID, PARTICIPANT)); }
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()); }
public void testContextIsBound() throws Exception { assertTrue("Bound contexts should return true", boundOperationContext.isBound()); Map<WaveletName, RobotWaveletData> openWavelets = boundOperationContext.getOpenWavelets(); assertEquals("Bound wavelet should be open", openWavelets.get(WAVELET_NAME), wavelet); assertFalse("Unbound contexts should return false", operationContext.isBound()); }
public void testContextIsBound() throws Exception { assertTrue("Bound contexts should return true", boundOperationContext.isBound()); Map<WaveletName, RobotWaveletData> openWavelets = boundOperationContext.getOpenWavelets(); assertEquals("Bound wavelet should be open", openWavelets.get(WAVELET_NAME), wavelet); assertFalse("Unbound contexts should return false", operationContext.isBound()); }
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()); }
public void testProcessEvent() throws Exception { // A randomly selected non-error event Event event = new WaveletBlipCreatedEvent(null, null, USERNAME, 0L, "root", "newBlip"); operationContext.processEvent(request, event); JsonRpcResponse response = operationContext.getResponse(request.getId()); assertFalse("Expected non-error response", response.isError()); assertEquals("Expected operation id not to change", OPERATION_ID, response.getId()); }
public void testProcessEvent() throws Exception { // A randomly selected non-error event Event event = new WaveletBlipCreatedEvent(null, null, USERNAME, 0L, "root", "newBlip"); operationContext.processEvent(request, event); JsonRpcResponse response = operationContext.getResponse(request.getId()); assertFalse("Expected non-error response", response.isError()); assertEquals("Expected operation id not to change", OPERATION_ID, response.getId()); }