/** * Handles an {@link OperationResults} by submitting the deltas it generates * and sending off any events to the robot. Note that currently no events are * send off to the robot. * * @param results the results of the operations performed * @param account the account for which to handle results of robot operations. */ private void handleResults(OperationResults results, RobotAccountData account) { OperationUtil.submitDeltas(results, waveletProvider, LOGGING_REQUEST_LISTENER); // TODO(ljvderijk): In theory we should be sending off all events that are // generated by the operations. Currently not done in production. We should // make it possible though. boolean notifyOnError = account.getCapabilities().getCapabilitiesMap().containsKey(EventType.OPERATION_ERROR); } }
OperationResults results, HttpServletResponse resp, ProtocolVersion version) throws IOException { OperationUtil.submitDeltas(results, waveletProvider, LOGGING_REQUEST_LISTENER);
public void testSubmitDeltas() { HashedVersion hashedVersionZero = HASH_FACTORY.createVersionZero(WAVELET_NAME); ObservableWaveletData waveletData = WaveletDataUtil.createEmptyWavelet(WAVELET_NAME, ALEX, hashedVersionZero, 0L); DocInitialization content = new DocInitializationBuilder().build(); waveletData.createDocument("b+example", BOB, Collections.singletonList(BOB), content, 0L, 0); RobotWaveletData wavelet = new RobotWaveletData(waveletData, hashedVersionZero); // Perform an operation that will be put into a delta wavelet.getOpBasedWavelet(BOB).addParticipant(ALEX); OperationResults results = mock(OperationResults.class); when(results.getOpenWavelets()).thenReturn(Collections.singletonMap(WAVELET_NAME, wavelet)); SubmitRequestListener requestListener = mock(SubmitRequestListener.class); OperationUtil.submitDeltas(results, waveletProvider, requestListener); verify(waveletProvider).submitRequest( eq(WAVELET_NAME), any(ProtocolWaveletDelta.class), eq(requestListener)); }
public void testSubmitDeltas() { HashedVersion hashedVersionZero = HASH_FACTORY.createVersionZero(WAVELET_NAME); ObservableWaveletData waveletData = WaveletDataUtil.createEmptyWavelet(WAVELET_NAME, ALEX, hashedVersionZero, 0L); DocInitialization content = new DocInitializationBuilder().build(); waveletData.createDocument("b+example", BOB, Collections.singletonList(BOB), content, 0L, 0); RobotWaveletData wavelet = new RobotWaveletData(waveletData, hashedVersionZero); // Perform an operation that will be put into a delta wavelet.getOpBasedWavelet(BOB).addParticipant(ALEX); OperationResults results = mock(OperationResults.class); when(results.getOpenWavelets()).thenReturn(Collections.singletonMap(WAVELET_NAME, wavelet)); SubmitRequestListener requestListener = mock(SubmitRequestListener.class); OperationUtil.submitDeltas(results, waveletProvider, requestListener); verify(waveletProvider).submitRequest( eq(WAVELET_NAME), any(ProtocolWaveletDelta.class), eq(requestListener)); }