/** * Returns the wave id where this request should be invoked on. This might not * be applicable to all requests. * * @return the wave id. */ public String getWaveId() { return (String) getParameter(ParamsProperty.WAVE_ID); }
/** * Returns the wavelet id where this request should be invoked on. This might * not be applicable to all requests. * * @return the wavelet id. */ public String getWaveletId() { return (String) getParameter(ParamsProperty.WAVELET_ID); }
/** * Returns the blip id where this request should be invoked on. This might not * be applicable to all requests. * * @return the blip id. */ public String getBlipId() { return (String) getParameter(ParamsProperty.BLIP_ID); }
@Override protected void setUp() { MockitoAnnotations.initMocks(this); when(operation.getParameter(ParamsProperty.QUERY)).thenReturn("in:inbox"); service = new SearchService(searchProvider); }
@Override protected void setUp() { MockitoAnnotations.initMocks(this); when(operation.getParameter(ParamsProperty.QUERY)).thenReturn("in:inbox"); service = new SearchService(searchProvider); }
public void testComputeParticipantWithValidProxyFor() throws Exception { String validProxyFor = "foo"; String participantAddress = "foo@bar.com"; OperationRequest operation = mock(OperationRequest.class); when(operation.getParameter(ParamsProperty.PROXYING_FOR)).thenReturn(validProxyFor); try { OperationUtil.computeParticipant(operation, ParticipantId.of(participantAddress)); } catch (InvalidRequestException e) { fail("Exception is thrown for a valid address."); } verify(operation).getParameter(ParamsProperty.PROXYING_FOR); } }
public void testComputeParticipantWithInvalidProxyFor() throws Exception { String invalidProxyFor = "~@#+^+"; String participantAddress = "foo@bar.com"; OperationRequest operation = mock(OperationRequest.class); when(operation.getParameter(ParamsProperty.PROXYING_FOR)).thenReturn(invalidProxyFor); try { OperationUtil.computeParticipant(operation, ParticipantId.of(participantAddress)); fail("InvalidRequestException should be thrown."); } catch (InvalidRequestException e) { // Pass. } verify(operation).getParameter(ParamsProperty.PROXYING_FOR); }
public void testSearchThrowsOnMissingQueryParameter() { when(operation.getParameter(ParamsProperty.QUERY)).thenReturn(null); try { service.execute(operation, context, USER); fail("Should have thrown an invalid request exception"); } catch (InvalidRequestException e) { // pass. } }
public void testComputeParticipantWithInvalidProxyFor() throws Exception { String invalidProxyFor = "~@#+^+"; String participantAddress = "foo@bar.com"; OperationRequest operation = mock(OperationRequest.class); when(operation.getParameter(ParamsProperty.PROXYING_FOR)).thenReturn(invalidProxyFor); try { OperationUtil.computeParticipant(operation, ParticipantId.of(participantAddress)); fail("InvalidRequestException should be thrown."); } catch (InvalidRequestException e) { // Pass. } verify(operation).getParameter(ParamsProperty.PROXYING_FOR); }
public void testSearchThrowsOnMissingQueryParameter() { when(operation.getParameter(ParamsProperty.QUERY)).thenReturn(null); try { service.execute(operation, context, USER); fail("Should have thrown an invalid request exception"); } catch (InvalidRequestException e) { // pass. } }
@Override protected void setUp() { MockitoAnnotations.initMocks(this); FetchProfilesRequest request = new FetchProfilesRequest(Lists.newArrayList(ADDRESS)); when(operation.getParameter(ParamsProperty.FETCH_PROFILES_REQUEST)).thenReturn(request); when(fakeProfilesFetcher.fetchProfile(ADDRESS)).thenReturn( new ParticipantProfile(ADDRESS, NAME, IMAGE_URL, PROFILE_URL)); service = new FetchProfilesService(fakeProfilesFetcher); }
@Override protected void setUp() { MockitoAnnotations.initMocks(this); FetchProfilesRequest request = new FetchProfilesRequest(Lists.newArrayList(ADDRESS)); when(operation.getParameter(ParamsProperty.FETCH_PROFILES_REQUEST)).thenReturn(request); when(fakeProfilesFetcher.fetchProfile(ADDRESS)).thenReturn( new ParticipantProfile(ADDRESS, NAME, IMAGE_URL, PROFILE_URL)); service = new FetchProfilesService(fakeProfilesFetcher); }
public void testDocumentModifyParametersForClearAnnotation() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().clearAnnotation("key"); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("key", action.getAnnotationKey()); }
public void testDocumentModifyParametersForClearAnnotation() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().clearAnnotation("key"); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("key", action.getAnnotationKey()); }
@SuppressWarnings("unchecked") public void testDocumentModifyParametersForUpdateElement() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); Map<String, String> newProperties = new HashMap<String, String>(); newProperties.put("url", "http://www.google.com/gadget.xml"); blip.first(ElementType.GADGET).updateElement(newProperties); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(0).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("http://www.google.com/gadget.xml", action.getElement(0).getProperty("url")); }
@SuppressWarnings("unchecked") public void testDocumentModifyParametersForUpdateElement() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); Map<String, String> newProperties = new HashMap<String, String>(); newProperties.put("url", "http://www.google.com/gadget.xml"); blip.first(ElementType.GADGET).updateElement(newProperties); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(0).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("http://www.google.com/gadget.xml", action.getElement(0).getProperty("url")); }
public void testDocumentModifyParametersForAnnotate() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().replace("foo foo foo"); blip.all("foo").annotate("key", "value1", "value2", "value3"); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("key", action.getAnnotationKey()); assertEquals(Arrays.asList("value1", "value2", "value3"), action.getValues()); }
public void testDocumentModifyParametersForAnnotate() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().replace("foo foo foo"); blip.all("foo").annotate("key", "value1", "value2", "value3"); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("key", action.getAnnotationKey()); assertEquals(Arrays.asList("value1", "value2", "value3"), action.getValues()); }
public void testProxyFor() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); Blip proxiedBlip = blip.proxyFor("proxyuser"); assertEquals(blip.getBlipId(), proxiedBlip.getBlipId()); assertEquals(blip.getWaveId(), proxiedBlip.getWaveId()); assertEquals(blip.getWaveletId(), proxiedBlip.getWaveletId()); proxiedBlip.reply(); List<OperationRequest> pendingOps = proxiedBlip.getOperationQueue().getPendingOperations(); assertEquals(1, pendingOps.size()); assertEquals("proxyuser", pendingOps.get(0).getParameter(ParamsProperty.PROXYING_FOR)); }
public void testProxyFor() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); Blip proxiedBlip = blip.proxyFor("proxyuser"); assertEquals(blip.getBlipId(), proxiedBlip.getBlipId()); assertEquals(blip.getWaveId(), proxiedBlip.getWaveId()); assertEquals(blip.getWaveletId(), proxiedBlip.getWaveletId()); proxiedBlip.reply(); List<OperationRequest> pendingOps = proxiedBlip.getOperationQueue().getPendingOperations(); assertEquals(1, pendingOps.size()); assertEquals("proxyuser", pendingOps.get(0).getParameter(ParamsProperty.PROXYING_FOR)); }