@Override public ObservableConversationView openConversation(WaveId waveId, WaveletId waveletId, ParticipantId participant) throws InvalidRequestException { WaveletName waveletName = WaveletName.of(waveId, waveletId); if (!openedConversations.containsKey(waveletName)) { openedConversations.put( waveletName, Maps.<ParticipantId, ObservableConversationView> newHashMap()); } Map<ParticipantId, ObservableConversationView> conversations = openedConversations.get(waveletName); if (!conversations.containsKey(participant)) { OpBasedWavelet wavelet = openWavelet(waveId, waveletId, participant); conversations.put(participant, conversationUtil.buildConversation(wavelet)); } return conversations.get(participant); }
/** * 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)); }
/** * 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 testOpenNonExistingWaveletThrowsInvalidRequestException() throws Exception { try { operationContext.openWavelet(WAVE_ID, WaveletId.of("example.com", "unreal"), PARTICIPANT); fail("Expected InvalidRequestException"); } catch (InvalidRequestException e) { // expected } }
public void testOpenNonExistingWaveletThrowsInvalidRequestException() throws Exception { try { operationContext.openWavelet(WAVE_ID, WaveletId.of("example.com", "unreal"), PARTICIPANT); fail("Expected InvalidRequestException"); } catch (InvalidRequestException e) { // expected } }
public void testOpenExistingWaveletForNonParticipantThrowsInvalidRequestException() throws Exception { ParticipantId nonExistingParticipant = ParticipantId.ofUnsafe("nonexisting@example.com"); assertFalse("This participant should not exist", waveletData.getParticipants().contains(nonExistingParticipant)); try { operationContext.openWavelet(WAVE_ID, WAVELET_ID, nonExistingParticipant); fail("Expected InvalidRequestException for a non-existing participant"); } catch (InvalidRequestException e) { // expected } }
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 testOpenExistingWaveletForNonParticipantThrowsInvalidRequestException() throws Exception { ParticipantId nonExistingParticipant = ParticipantId.ofUnsafe("nonexisting@example.com"); assertFalse("This participant should not exist", waveletData.getParticipants().contains(nonExistingParticipant)); try { operationContext.openWavelet(WAVE_ID, WAVELET_ID, nonExistingParticipant); fail("Expected InvalidRequestException for a non-existing participant"); } catch (InvalidRequestException e) { // expected } }
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)); }
@Override public OpBasedWavelet openWavelet(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 openWavelet(waveId, waveletId, participant); } catch (InvalidIdException e) { throw new InvalidRequestException("Invalid id", operation, e); } }
private ApiView getApiView() throws InvalidRequestException { ApiView view = new ApiView( getRootBlip().getContent(), helper.getContext().openWavelet(WAVE_ID, WAVELET_ID, ALEX)); return view; }
private ApiView getApiView() throws InvalidRequestException { ApiView view = new ApiView( getRootBlip().getContent(), helper.getContext().openWavelet(WAVE_ID, WAVELET_ID, ALEX)); return view; }
public void testInsertInlineBlip() throws Exception { OperationContextImpl context = helper.getContext(); OpBasedWavelet wavelet = context.openWavelet(WAVE_ID, WAVELET_ID, ALEX); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); int insertAtApiLocation = 2; ApiView apiView = new ApiView(conversation.getRootThread().getFirstBlip().getContent(), wavelet); int insertAtXmlLocation = apiView.transformToXmlOffset(insertAtApiLocation); // Append the inline blip to the root blip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.DOCUMENT_INSERT_INLINE_BLIP, rootBlipId, Parameter.of(ParamsProperty.BLIP_DATA, blipData), Parameter.of(ParamsProperty.INDEX, insertAtApiLocation)); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response); Iterator<? extends LocatedReplyThread<? extends ObservableConversationThread>> it = conversation.getRootThread().getFirstBlip().locateReplyThreads().iterator(); LocatedReplyThread<? extends ObservableConversationThread> inlineReplyThread = it.next(); assertEquals("The inline reply was not located where specified", insertAtXmlLocation, inlineReplyThread.getLocation()); }
public void testInsertInlineBlip() throws Exception { OperationContextImpl context = helper.getContext(); OpBasedWavelet wavelet = context.openWavelet(WAVE_ID, WAVELET_ID, ALEX); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); int insertAtApiLocation = 2; ApiView apiView = new ApiView(conversation.getRootThread().getFirstBlip().getContent(), wavelet); int insertAtXmlLocation = apiView.transformToXmlOffset(insertAtApiLocation); // Append the inline blip to the root blip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.DOCUMENT_INSERT_INLINE_BLIP, rootBlipId, Parameter.of(ParamsProperty.BLIP_DATA, blipData), Parameter.of(ParamsProperty.INDEX, insertAtApiLocation)); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response); Iterator<? extends LocatedReplyThread<? extends ObservableConversationThread>> it = conversation.getRootThread().getFirstBlip().locateReplyThreads().iterator(); LocatedReplyThread<? extends ObservableConversationThread> inlineReplyThread = it.next(); assertEquals("The inline reply was not located where specified", insertAtXmlLocation, inlineReplyThread.getLocation()); }