@Override public ObservableConversationView openConversation( OperationRequest operation, ParticipantId participant) throws InvalidRequestException { try { WaveId waveId = ApiIdSerializer.instance().deserialiseWaveId( OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVE_ID)); WaveletId waveletId = ApiIdSerializer.instance().deserialiseWaveletId( OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVELET_ID)); return openConversation(waveId, waveletId, participant); } catch (InvalidIdException e) { throw new InvalidRequestException("Invalid id", operation, e); } }
private ObservableConversationBlip getRootBlip() throws InvalidRequestException { ObservableConversationBlip rootBlip = helper.getContext().openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot().getRootThread() .getFirstBlip(); return rootBlip; } }
private ObservableConversationBlip getRootBlip() throws InvalidRequestException { ObservableConversationBlip rootBlip = helper.getContext().openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot().getRootThread() .getFirstBlip(); return rootBlip; } }
private ObservableConversationBlip getRootBlip() throws InvalidRequestException { ObservableConversationBlip rootBlip = helper.getContext().openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot().getRootThread() .getFirstBlip(); return rootBlip; } }
private ObservableConversationBlip getRootBlip() throws InvalidRequestException { ObservableConversationBlip rootBlip = helper.getContext().openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot().getRootThread() .getFirstBlip(); return rootBlip; } }
public void testAppendBlip() throws Exception { OperationRequest operation = operationRequest(OperationType.WAVELET_APPEND_BLIP, Parameter.of(ParamsProperty.BLIP_DATA, blipData)); OperationContextImpl context = helper.getContext(); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response); Iterator<? extends ObservableConversationBlip> it = conversation.getRootThread().getBlips().iterator(); it.next(); // skip, root assertEquals("New blip should be the second blip in the root thread", newBlip, it.next()); }
public void testAppendBlip() throws Exception { OperationRequest operation = operationRequest(OperationType.WAVELET_APPEND_BLIP, Parameter.of(ParamsProperty.BLIP_DATA, blipData)); OperationContextImpl context = helper.getContext(); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response); Iterator<? extends ObservableConversationBlip> it = conversation.getRootThread().getBlips().iterator(); it.next(); // skip, root assertEquals("New blip should be the second blip in the root thread", newBlip, it.next()); }
public void testContinueThread() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append a random blip to check that we actually append to the end of this // thread. conversation.getRootThread().appendBlip(); // Append to continue the thread of the root blip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.BLIP_CONTINUE_THREAD, rootBlipId, Parameter.of(ParamsProperty.BLIP_DATA, blipData)); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response); Iterator<? extends ObservableConversationBlip> it = conversation.getRootThread().getBlips().iterator(); it.next(); // skip, root it.next(); // skip, first reply assertEquals("New blip should be the third blip in the root thread", newBlip, it.next()); }
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 testInvalidParticipantAddress() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot(); String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, MALFORMED_ADDRESS)); try { service.execute(operation, context, ROBOT); fail("Addition of invalid particpant address should have generated error in service " + "execution."); } catch(InvalidRequestException e) { // Good. } } }
public void testInvalidParticipantAddress() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot(); String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, MALFORMED_ADDRESS)); try { service.execute(operation, context, ROBOT); fail("Addition of invalid particpant address should have generated error in service " + "execution."); } catch(InvalidRequestException e) { // Good. } } }
public void testAddThrowsOnDuplicateParticipant() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot(); String rootBlipId = ConversationUtil.getRootBlipId(conversation); // Confirm robot is on wave prior to operation to re-add it. Set<ParticipantId> participants = conversation.getParticipantIds(); assertTrue("Robot should be a participant on wavelet prior to test operation to add it.", participants.contains(ROBOT)); OperationRequest operation = operationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, ROBOT.getAddress())); try { service.execute(operation, context, ROBOT); fail("Duplicate add of participant should have generated error in service execution."); } catch(InvalidRequestException e) { // Good. } }
public void testDeleteBlip() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Delete the root blip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.BLIP_DELETE, rootBlipId); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); assertNull("Blip should have been deleted", conversation.getBlip(rootBlipId)); }
public void testDeleteBlip() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Delete the root blip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.BLIP_DELETE, rootBlipId); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); assertNull("Blip should have been deleted", conversation.getBlip(rootBlipId)); }
public void testCreateChild() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append a random blip to check that we actually make a new child blip conversation.getRootThread().appendBlip(); // Create a child to the rootblip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.BLIP_CREATE_CHILD, rootBlipId, Parameter.of(ParamsProperty.BLIP_DATA, blipData)); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response); Iterator<? extends ObservableConversationThread> it = conversation.getRootThread().getFirstBlip().getReplyThreads().iterator(); assertEquals("New blip should be the first blip in the first reply thread", it.next().getFirstBlip(), newBlip); }
public void testAppendBadMarkup() throws Exception { // Set markup with different end tag. String markup = "<custom>"+NEW_BLIP_CONTENT+"</diffcustom>"; OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append the custom markup to the newly created blip. ConversationBlip markupBlip = conversation.getRootThread().appendBlip(); OperationRequest operation = operationRequest(OperationType.DOCUMENT_APPEND_MARKUP, markupBlip.getId(), Parameter.of(ParamsProperty.CONTENT, markup)); try { service.execute(operation, context, ALEX); fail("Bad Markup should have generated error in service execution."); } catch(IllegalArgumentException e) { // Good. } }
public void testAppendBadMarkup() throws Exception { // Set markup with different end tag. String markup = "<custom>"+NEW_BLIP_CONTENT+"</diffcustom>"; OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append the custom markup to the newly created blip. ConversationBlip markupBlip = conversation.getRootThread().appendBlip(); OperationRequest operation = operationRequest(OperationType.DOCUMENT_APPEND_MARKUP, markupBlip.getId(), Parameter.of(ParamsProperty.CONTENT, markup)); try { service.execute(operation, context, ALEX); fail("Bad Markup should have generated error in service execution."); } catch(IllegalArgumentException e) { // Good. } }
public void testCreateChild() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append a random blip to check that we actually make a new child blip conversation.getRootThread().appendBlip(); // Create a child to the rootblip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.BLIP_CREATE_CHILD, rootBlipId, Parameter.of(ParamsProperty.BLIP_DATA, blipData)); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response); Iterator<? extends ObservableConversationThread> it = conversation.getRootThread().getFirstBlip().getReplyThreads().iterator(); assertEquals("New blip should be the first blip in the first reply thread", it.next().getFirstBlip(), newBlip); }
public void testAppendCustomMarkup() throws Exception { String markup = "<custom>this is custom markup</custom>"; OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append the custom markup to the newly created blip. ConversationBlip markupBlip = conversation.getRootThread().appendBlip(); OperationRequest operation = operationRequest(OperationType.DOCUMENT_APPEND_MARKUP, markupBlip.getId(), Parameter.of(ParamsProperty.CONTENT, markup)); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse("CustomMarkup generated error in service execution.", response.isError()); // The xml in new blip should match custom markup. String actualContent = markupBlip.getContent().toXmlString(); assertTrue("Expected the new blip to contain the custom markup as specified in the " + "operation. actualcontent: " + actualContent, actualContent.contains(markup)); }
public void testAppendCustomMarkup() throws Exception { String markup = "<custom>this is custom markup</custom>"; OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append the custom markup to the newly created blip. ConversationBlip markupBlip = conversation.getRootThread().appendBlip(); OperationRequest operation = operationRequest(OperationType.DOCUMENT_APPEND_MARKUP, markupBlip.getId(), Parameter.of(ParamsProperty.CONTENT, markup)); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse("CustomMarkup generated error in service execution.", response.isError()); // The xml in new blip should match custom markup. String actualContent = markupBlip.getContent().toXmlString(); assertTrue("Expected the new blip to contain the custom markup as specified in the " + "operation. actualcontent: " + actualContent, actualContent.contains(markup)); }