public void testFetchWave() throws Exception { String message = "A message"; OperationRequest operation = operationRequest(OperationType.ROBOT_FETCH_WAVE, Parameter.of(ParamsProperty.MESSAGE, message)); OperationContextImpl context = helper.getContext(); WaveletProvider waveletProvider = helper.getWaveletProvider(); when(waveletProvider.checkAccessPermission(WAVELET_NAME, ALEX)).thenReturn(true); service.execute(operation, context, ALEX); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertNotNull("expected a response", response); assertFalse("expected a success response", response.isError()); assertEquals("Expected the response to carry the message", message, response.getData().get(ParamsProperty.MESSAGE)); assertNotNull("Expected the response to carry a wavelet", response.getData().get(ParamsProperty.WAVELET_DATA)); assertEquals("Expected the response to carry root blip id", conversation.getRootThread().getFirstBlip().getId(), response.getData().get(ParamsProperty.BLIP_ID)); }
public void testFetchWaveWithMissingParamThrowsInvalidRequestException() throws Exception { // No wave id or wavelet id set. OperationRequest operation = new OperationRequest(OperationType.ROBOT_FETCH_WAVE.method(), OPERATION_ID); OperationContextImpl context = helper.getContext(); try { service.execute(operation, context, ALEX); fail("Expected InvalidRequestException because params were not set"); } catch (InvalidRequestException e) { // expected } } }
public void testFetchWaveWithMissingParamThrowsInvalidRequestException() throws Exception { // No wave id or wavelet id set. OperationRequest operation = new OperationRequest(OperationType.ROBOT_FETCH_WAVE.method(), OPERATION_ID); OperationContextImpl context = helper.getContext(); try { service.execute(operation, context, ALEX); fail("Expected InvalidRequestException because params were not set"); } catch (InvalidRequestException e) { // expected } } }
public void testFetchWave() throws Exception { String message = "A message"; OperationRequest operation = operationRequest(OperationType.ROBOT_FETCH_WAVE, Parameter.of(ParamsProperty.MESSAGE, message)); OperationContextImpl context = helper.getContext(); WaveletProvider waveletProvider = helper.getWaveletProvider(); when(waveletProvider.checkAccessPermission(WAVELET_NAME, ALEX)).thenReturn(true); service.execute(operation, context, ALEX); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertNotNull("expected a response", response); assertFalse("expected a success response", response.isError()); assertEquals("Expected the response to carry the message", message, response.getData().get(ParamsProperty.MESSAGE)); assertNotNull("Expected the response to carry a wavelet", response.getData().get(ParamsProperty.WAVELET_DATA)); assertEquals("Expected the response to carry root blip id", conversation.getRootThread().getFirstBlip().getId(), response.getData().get(ParamsProperty.BLIP_ID)); }