WaveletData waveletData = new WaveletData(); waveletData.setWaveId(ApiIdSerializer.instance().serialiseWaveId(waveId)); waveletData.setWaveletId(ApiIdSerializer.instance().serialiseWaveletId(waveletId)); waveletData.setCreator(creator); waveletData.setCreationTime(creationTime); waveletData.setLastModifiedTime(lastModifiedTime); waveletData.setRootBlipId(rootBlipId); waveletData.setRootThread(rootThread); waveletData.setTitle(title); tags.add(tag); waveletData.setTags(tags); participants.add(participant); Role role = getParticipants().getParticipantRole(participant); waveletData.setParticipantRole(participant, role.name()); waveletData.setParticipants(participants); dataDocuments.put(entry.getKey(), entry.getValue()); waveletData.setDataDocuments(dataDocuments);
public WaveletData(WaveletData wavelet) { this.creationTime = wavelet.getCreationTime(); this.creator = wavelet.getCreator(); this.lastModifiedTime = wavelet.getLastModifiedTime(); this.participants = wavelet.getParticipants(); this.participantRoles = new HashMap<String, String>(wavelet.getParticipantRoles()); this.rootBlipId = wavelet.getRootBlipId(); this.title = wavelet.getTitle(); this.version = wavelet.getVersion(); this.waveId = wavelet.getWaveId(); this.waveletId = wavelet.getWaveletId(); this.dataDocuments = new HashMap<String, String>(wavelet.getDataDocuments()); this.tags = new ArrayList<String>(wavelet.getTags()); }
@Override public WaveletData toWaveletData(Wavelet wavelet, Conversation conversation, EventMessageBundle eventMessageBundle) { final WaveletData waveletData = new WaveletData(); waveletData.setCreationTime(wavelet.getCreationTime()); waveletData.setCreator(wavelet.getCreatorId().getAddress()); waveletData.setWaveId(ApiIdSerializer.instance().serialiseWaveId(wavelet.getWaveId())); waveletData.setWaveletId(ApiIdSerializer.instance().serialiseWaveletId(wavelet.getId())); waveletData.setLastModifiedTime(wavelet.getLastModifiedTime()); waveletData.setParticipants(idsToParticipantIdList(wavelet.getParticipantIds())); waveletData.setRootBlipId(conversation.getRootThread().getFirstBlip().getId()); waveletData.setTitle(getTitle(wavelet, conversation)); waveletData.setVersion(wavelet.getVersion()); Document document = wavelet.getDocument(documentId); String val = XmlStringBuilder.innerXml(document).getXmlString(); waveletData.setDataDocument(parts[1], val); DocumentBasedRoles roles = DocumentBasedRoles.create(rolesDocument); for (ParticipantId participantId : wavelet.getParticipantIds()) { waveletData.setParticipantRole(participantId.getAddress(), roles.getRole(participantId).name());
for (String address : waveletData.getParticipants()) { try { participants.add(ParticipantId.of(address)); WaveId waveId = ApiIdSerializer.instance().deserialiseWaveId(waveletData.getWaveId()); WaveletId waveletId = ApiIdSerializer.instance().deserialiseWaveletId(waveletData.getWaveletId()); context.putWavelet(waveId, waveletId, newWavelet); } catch (InvalidIdException e) { throw new InvalidRequestException("Invalid id", operation, e); context.putBlip(waveletData.getRootBlipId(), rootBlip);
@Override protected void setUp() { service = CreateWaveletService.create(); waveletProvider = mock(WaveletProvider.class); converter = mock(EventDataConverter.class); waveletData = mock(WaveletData.class); when(waveletData.getWaveId()).thenReturn(TEMP_WAVE_ID); when(waveletData.getWaveletId()).thenReturn(WAVELET_ID); when(waveletData.getRootBlipId()).thenReturn("b+root"); ConversationUtil conversationUtil = new ConversationUtil(FakeIdGenerator.create()); context = new OperationContextImpl(waveletProvider, converter, conversationUtil); operation = new OperationRequest(OperationType.ROBOT_CREATE_WAVELET.method(), OPERATION_ID, Parameter.of(ParamsProperty.WAVELET_DATA, waveletData), Parameter.of(ParamsProperty.MESSAGE, MESSAGE)); }
WaveletData waveletData = new WaveletData("google.com!wave1", "google.com!conv+root", "blip1", null); waveletData.addParticipant("foo@google.com"); BlipSubmittedEvent event1 = new BlipSubmittedEvent(null, null, "foo@test.com", 1l, "blip1"); DocumentChangedEvent event2 = new DocumentChangedEvent(null, null, "foo@test.com", 1l, "blip1");
public void testCreateWaveletServiceThrowsOnInvalidParticipant() throws Exception { when(waveletData.getParticipants()).thenReturn(Collections.singletonList(MALFORMED_ADDRESS)); try { service.execute(operation, context, ALEX); fail("Expected InvalidRequestException"); } catch (InvalidRequestException e) { // expected } } }
@Override protected void setUp() { service = CreateWaveletService.create(); waveletProvider = mock(WaveletProvider.class); converter = mock(EventDataConverter.class); waveletData = mock(WaveletData.class); when(waveletData.getWaveId()).thenReturn(TEMP_WAVE_ID); when(waveletData.getWaveletId()).thenReturn(WAVELET_ID); when(waveletData.getRootBlipId()).thenReturn("b+root"); ConversationUtil conversationUtil = new ConversationUtil(FakeIdGenerator.create()); context = new OperationContextImpl(waveletProvider, converter, conversationUtil); operation = new OperationRequest(OperationType.ROBOT_CREATE_WAVELET.method(), OPERATION_ID, Parameter.of(ParamsProperty.WAVELET_DATA, waveletData), Parameter.of(ParamsProperty.MESSAGE, MESSAGE)); }
WaveletData waveletData = new WaveletData("google.com!wave1", "google.com!conv+root", "blip1", null); waveletData.addParticipant("foo@google.com"); BlipSubmittedEvent event1 = new BlipSubmittedEvent(null, null, "foo@test.com", 1l, "blip1"); DocumentChangedEvent event2 = new DocumentChangedEvent(null, null, "foo@test.com", 1l, "blip1");
public void testCreateWaveletServiceThrowsOnInvalidParticipant() throws Exception { when(waveletData.getParticipants()).thenReturn(Collections.singletonList(MALFORMED_ADDRESS)); try { service.execute(operation, context, ALEX); fail("Expected InvalidRequestException"); } catch (InvalidRequestException e) { // expected } } }
WaveletId waveletId; try { waveId = ApiIdSerializer.instance().deserialiseWaveId(waveletData.getWaveId()); waveletId = ApiIdSerializer.instance().deserialiseWaveletId(waveletData.getWaveletId()); } catch (InvalidIdException e) { throw new IllegalArgumentException(e); String creator = waveletData.getCreator(); long creationTime = waveletData.getCreationTime(); long lastModifiedTime = waveletData.getLastModifiedTime(); String rootBlipId = waveletData.getRootBlipId(); BlipThread originalRootThread = waveletData.getRootThread(); List<String> rootThreadBlipIds = originalRootThread == null ? new ArrayList<String>() : BlipThread rootThread = new BlipThread("", -1, rootThreadBlipIds, blips); String title = waveletData.getTitle(); Set<String> participants = new LinkedHashSet<String>(waveletData.getParticipants()); Set<String> tags = new LinkedHashSet<String>(waveletData.getTags()); Map<String, String> dataDocuments = waveletData.getDataDocuments(); Map<String, String> roles = waveletData.getParticipantRoles();
public void testCreateWaveletService() throws Exception { when(waveletData.getParticipants()).thenReturn(Collections.singletonList(BOB.getAddress()));
public void testCreateWaveletService() throws Exception { when(waveletData.getParticipants()).thenReturn(Collections.singletonList(BOB.getAddress()));