ProtocolWaveletOperation.Builder protobufOp = ProtocolWaveletOperation.newBuilder();
/** * Deserialize a {@link ProtocolWaveletOperation} as a {@link WaveletOperation}. * * @param protobufOp protocol buffer wavelet operation to deserialize * @return deserialized wavelet operation */ public static WaveletOperation deserialize(ProtocolWaveletOperation protobufOp, WaveletOperationContext context) { if (protobufOp.hasNoOp()) { return new NoOp(context); } else if (protobufOp.hasAddParticipant()) { return new AddParticipant(context, new ParticipantId(protobufOp.getAddParticipant())); } else if (protobufOp.hasRemoveParticipant()) { return new RemoveParticipant(context, new ParticipantId(protobufOp.getRemoveParticipant())); } else if (protobufOp.hasMutateDocument()) { return new WaveletBlipOperation(protobufOp.getMutateDocument().getDocumentId(), new BlipContentOperation(context, deserialize(protobufOp.getMutateDocument().getDocumentOperation()))); } else { throw new IllegalArgumentException("Unsupported operation: " + protobufOp); } }
@Override protected void setUp() throws Exception { super.setUp(); addParticipantOp = ProtocolWaveletOperation.newBuilder() .setAddParticipant(AUTHOR) .build(); // An empty blip operation - creates a new document. addBlipOp = ProtocolWaveletOperation.newBuilder().setMutateDocument( MutateDocument.newBuilder().setDocumentId(BLIP_ID).setDocumentOperation( ProtocolDocumentOperation.newBuilder().build())).build(); WaveletNotificationSubscriber notifiee = mock(WaveletNotificationSubscriber.class); DeltaStore deltaStore = new MemoryDeltaStore(); WaveletState waveletState = DeltaStoreBasedWaveletState.create(deltaStore.open(WAVELET_NAME), PERSIST_EXECUTOR); AccessController accessController = mock(AccessController.class); wavelet = new LocalWaveletContainerImpl(WAVELET_NAME, notifiee, Futures.immediateFuture(waveletState), null, STORAGE_CONTINUATION_EXECUTOR, accessController); wavelet.awaitLoad(); }
@Override protected void setUp() throws Exception { super.setUp(); addParticipantOp = ProtocolWaveletOperation.newBuilder() .setAddParticipant(AUTHOR) .build(); // An empty blip operation - creates a new document. addBlipOp = ProtocolWaveletOperation.newBuilder().setMutateDocument( MutateDocument.newBuilder().setDocumentId(BLIP_ID).setDocumentOperation( ProtocolDocumentOperation.newBuilder().build())).build(); WaveletNotificationSubscriber notifiee = mock(WaveletNotificationSubscriber.class); DeltaStore deltaStore = new MemoryDeltaStore(); WaveletState waveletState = DeltaStoreBasedWaveletState.create(deltaStore.open(WAVELET_NAME), PERSIST_EXECUTOR); wavelet = new LocalWaveletContainerImpl(WAVELET_NAME, notifiee, Futures.immediateFuture(waveletState), null, STORAGE_CONTINUATION_EXECUTOR); wavelet.awaitLoad(); }
public void testConvertOfDelta() throws WaveletStateException, InvalidParticipantAddress { ProtocolWaveletDelta delta = DomainConverter.convertDelta(DELTA_ADD_USER, DOMAIN); assertEquals(USER, delta.getAuthor()); assertEquals(USER, delta.getOperation(0).getAddParticipant()); } }
public void testConvertOfDelta() throws WaveletStateException, InvalidParticipantAddress { ProtocolWaveletDelta delta = DomainConverter.convertDelta(DELTA_ADD_USER, DOMAIN); assertEquals(USER, delta.getAuthor()); assertEquals(USER, delta.getOperation(0).getAddParticipant()); } }