/** * Returns a view of this blip that will proxy for the specified id. * * A shallow copy of the current blip is returned with the {@code proxyingFor} * field set. Any modifications made to this copy will be done using the * {@code proxyForId}, i.e. the {@code robot+<proxyForId>@appspot.com} address * will be used. * * @param proxyForId the id to proxy. Please note that this parameter should * be properly encoded to ensure that the resulting participant id is * valid (see {@link Util#checkIsValidProxyForId(String)} for more * details). * @return a shallow copy of this blip with the proxying information set. */ public Blip proxyFor(String proxyForId) { Util.checkIsValidProxyForId(proxyForId); OperationQueue proxiedOperationQueue = operationQueue.proxyFor(proxyForId); return new Blip(this, proxiedOperationQueue); }
/** * Returns a view of this wavelet that will proxy for the specified id. * * A shallow copy of the current wavelet is returned with the * {@code proxyingFor} field set. Any modifications made to this copy will be * done using the {@code proxyForId}, i.e. the * {@code robot+<proxyForId>@appspot.com} address will be used. * * If the wavelet was retrieved using the Active Robot API, that is * by {@code fetchWavelet}, then the address of the robot must be added to the * wavelet by calling {@code setRobotAddress} with the robot's address * before calling {@code proxy_for}. * * @param proxyForId the id to proxy. Please note that this parameter should * be properly encoded to ensure that the resulting participant id is * valid (see {@link Util#checkIsValidProxyForId(String)} for more * details). * @return a shallow copy of this wavelet with the proxying information set. */ public Wavelet proxyFor(String proxyForId) { Util.checkIsValidProxyForId(proxyForId); addProxyingParticipant(proxyForId); OperationQueue proxiedOperationQueue = operationQueue.proxyFor(proxyForId); return new Wavelet(this, proxiedOperationQueue); }
public void testProxyFor() throws Exception { OperationQueue proxiedQueue = mock(OperationQueue.class); when(opQueue.proxyFor("user2")).thenReturn(proxiedQueue); wavelet.setRobotAddress("foo+user1#5@appspot.com"); Wavelet proxiedWavelet = wavelet.proxyFor("user2"); assertTrue(wavelet.getParticipants().contains("foo+user2#5@appspot.com")); assertEquals(proxiedQueue, proxiedWavelet.getOperationQueue()); }
public void testProxyFor() throws Exception { OperationQueue proxiedQueue = mock(OperationQueue.class); when(opQueue.proxyFor("user2")).thenReturn(proxiedQueue); wavelet.setRobotAddress("foo+user1#5@appspot.com"); Wavelet proxiedWavelet = wavelet.proxyFor("user2"); assertTrue(wavelet.getParticipants().contains("foo+user2#5@appspot.com")); assertEquals(proxiedQueue, proxiedWavelet.getOperationQueue()); }
public void testProxyFor() throws Exception { OperationQueue queue = new OperationQueue(); queue.createWavelet("google.com", Collections.<String>emptySet()); OperationQueue proxyingForQueue = queue.proxyFor("foo"); assertEquals(1, proxyingForQueue.getPendingOperations().size()); proxyingForQueue.setTitleOfWavelet(wavelet, "My title"); List<OperationRequest> ops = proxyingForQueue.getPendingOperations(); assertEquals(2, ops.size()); assertEquals(OperationType.ROBOT_CREATE_WAVELET.method(), ops.get(0).getMethod()); assertNull(ops.get(0).getParameter(ParamsProperty.PROXYING_FOR)); assertEquals(OperationType.WAVELET_SET_TITLE.method(), ops.get(1).getMethod()); assertEquals("foo", ops.get(1).getParameter(ParamsProperty.PROXYING_FOR)); OperationQueue nonProxyingForQueue = proxyingForQueue.proxyFor(null); nonProxyingForQueue.fetchWavelet(WaveId.of("example.com", "wave2"), WaveletId.of("example.com", "wavelet2")); ops = nonProxyingForQueue.getPendingOperations(); assertEquals(3, ops.size()); assertNull(ops.get(2).getParameter(ParamsProperty.PROXYING_FOR)); }
public void testProxyFor() throws Exception { OperationQueue queue = new OperationQueue(); queue.createWavelet("google.com", Collections.<String>emptySet()); OperationQueue proxyingForQueue = queue.proxyFor("foo"); assertEquals(1, proxyingForQueue.getPendingOperations().size()); proxyingForQueue.setTitleOfWavelet(wavelet, "My title"); List<OperationRequest> ops = proxyingForQueue.getPendingOperations(); assertEquals(2, ops.size()); assertEquals(OperationType.ROBOT_CREATE_WAVELET.method(), ops.get(0).getMethod()); assertNull(ops.get(0).getParameter(ParamsProperty.PROXYING_FOR)); assertEquals(OperationType.WAVELET_SET_TITLE.method(), ops.get(1).getMethod()); assertEquals("foo", ops.get(1).getParameter(ParamsProperty.PROXYING_FOR)); OperationQueue nonProxyingForQueue = proxyingForQueue.proxyFor(null); nonProxyingForQueue.fetchWavelet(WaveId.of("example.com", "wave2"), WaveletId.of("example.com", "wavelet2")); ops = nonProxyingForQueue.getPendingOperations(); assertEquals(3, ops.size()); assertNull(ops.get(2).getParameter(ParamsProperty.PROXYING_FOR)); }