@Test public void testGetExpectedActivitiesForPlural() throws Exception { RestfulCollection<Activity> responseItem = db.getActivities( ImmutableSet.of(CANON_USER, JOHN_DOE), SELF_GROUP, APP_ID, Collections.<String>emptySet(), null, new FakeGadgetToken()).get(); assertSame(3, responseItem.getTotalResults()); }
@Test public void testGetExpectedActivityEntriesForPlural() throws Exception { RestfulCollection<ActivityEntry> responseItem = db.getActivityEntries( ImmutableSet.of(CANON_USER, JOHN_DOE), SELF_GROUP, APP_ID, Collections.<String>emptySet(), null, new FakeGadgetToken()).get(); assertSame(3, responseItem.getTotalResults()); }
@Test public void testGetExpectedActivitiesForPlural() throws Exception { RestfulCollection<Activity> responseItem = db.getActivities( ImmutableSet.of(CANON_USER, JOHN_DOE), SELF_GROUP, APP_ID, Collections.<String>emptySet(), null, new FakeGadgetToken()).get(); assertSame(3, responseItem.getTotalResults()); }
@Test public void testGetExpectedActivityEntries() throws Exception { RestfulCollection<ActivityEntry> responseItem = db.getActivityEntries( ImmutableSet.of(JOHN_DOE), SELF_GROUP, APP_ID, Collections.<String>emptySet(), null, new FakeGadgetToken()).get(); assertSame(3, responseItem.getTotalResults()); }
@Before public void setUp() throws Exception { injector = Guice.createInjector(); converter = new BeanJsonConverter(injector); authContext = new FakeGadgetToken(); featureRegistryProvider = new FeatureRegistryProvider() { public FeatureRegistry get(String repository) throws GadgetException { return mockRegistry; } }; authContext.setAppUrl("http://www.example.com/gadget.xml"); }
@Before public void setUp() throws Exception { injector = Guice.createInjector(); converter = new BeanJsonConverter(injector); token = new FakeGadgetToken(); token.setAppUrl("http://www.example.com/gadget.xml"); }
@Test public void testGetExpectedAppData() throws Exception { DataCollection responseItem = db.getPersonData( ImmutableSet.of(CANON_USER), SELF_GROUP, APP_ID, Collections.<String>emptySet(), new FakeGadgetToken()).get(); assertFalse(responseItem.getEntry().isEmpty()); assertFalse(responseItem.getEntry().get(CANONICAL_USER_ID).isEmpty()); assertSame(2, responseItem.getEntry().get(CANONICAL_USER_ID).size()); assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("count")); assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("size")); }
@Test public void testGetExpectedAppData() throws Exception { DataCollection responseItem = db.getPersonData( ImmutableSet.of(CANON_USER), SELF_GROUP, APP_ID, Collections.<String>emptySet(), new FakeGadgetToken()).get(); assertFalse(responseItem.getEntry().isEmpty()); assertFalse(responseItem.getEntry().get(CANONICAL_USER_ID).isEmpty()); assertSame(2, responseItem.getEntry().get(CANONICAL_USER_ID).size()); assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("count")); assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("size")); }
@Test public void testGetExpectedAppData() throws Exception { DataCollection responseItem = db.getPersonData( ImmutableSet.of(CANON_USER), SELF_GROUP, APP_ID, Collections.<String>emptySet(), new FakeGadgetToken()).get(); assertFalse(responseItem.getEntry().isEmpty()); assertFalse(responseItem.getEntry().get(CANONICAL_USER_ID).isEmpty()); assertSame(2, responseItem.getEntry().get(CANONICAL_USER_ID).size()); assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("count")); assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("size")); }
@Test public void testGetExpectedActivityEntry() throws Exception { ActivityEntry entry = db.getActivityEntry(JOHN_DOE, SELF_GROUP, APP_ID, ImmutableSet.of("title"), "activity2", new FakeGadgetToken()).get(); assertNotNull(entry); // Check that some fields are fetched and others are not assertNotNull(entry.getTitle()); assertNull(entry.getPublished()); }
@Test public void testGetExpectedActivity() throws Exception { Activity activity = db.getActivity( CANON_USER, SELF_GROUP, APP_ID, ImmutableSet.of("appId", "body", "mediaItems"), APP_ID, new FakeGadgetToken()).get(); assertNotNull(activity); // Check that some fields are fetched and others are not assertNotNull(activity.getBody()); assertNull(activity.getBodyId()); }
@Test public void testGetExpectedActivity() throws Exception { Activity activity = db.getActivity( CANON_USER, SELF_GROUP, APP_ID, ImmutableSet.of("appId", "body", "mediaItems"), APP_ID, new FakeGadgetToken()).get(); assertNotNull(activity); // Check that some fields are fetched and others are not assertNotNull(activity.getBody()); assertNull(activity.getBodyId()); }
@Test public void testGetExpectedActivity() throws Exception { Activity activity = db.getActivity( CANON_USER, SELF_GROUP, APP_ID, ImmutableSet.of("appId", "body", "mediaItems"), APP_ID, new FakeGadgetToken()).get(); assertNotNull(activity); // Check that some fields are fetched and others are not assertNotNull(activity.getBody()); assertNull(activity.getBodyId()); }
@Test public void testToken() throws Exception { HttpServletRequest req = new FakeHttpServletRequest(); SecurityToken token = new FakeGadgetToken(); AuthInfoUtil.setSecurityTokenForRequest(req, token); assertEquals(token, AuthInfoUtil.getSecurityTokenFromRequest(req)); }
@Test public void testToken() throws Exception { HttpServletRequest req = new FakeHttpServletRequest(); SecurityToken token = new FakeGadgetToken(); AuthInfoUtil.setSecurityTokenForRequest(req, token); assertEquals(token, AuthInfoUtil.getSecurityTokenFromRequest(req)); }
@Test public void testBinding() throws Exception { HttpServletRequest req = new FakeHttpServletRequest(); SecurityToken token = new FakeGadgetToken(); new AuthInfo(req).setSecurityToken(token).setAuthType("FakeAuth"); Injector injector = Guice.createInjector(new TestModule(req)); AuthInfo injected = injector.getInstance(AuthInfo.class); assertEquals(token, injected.getSecurityToken()); assertEquals("FakeAuth", injected.getAuthType()); }
@Test public void testBinding() throws Exception { HttpServletRequest req = new FakeHttpServletRequest(); SecurityToken token = new FakeGadgetToken(); new AuthInfo(req).setSecurityToken(token).setAuthType("FakeAuth"); Injector injector = Guice.createInjector(new TestModule(req)); AuthInfo injected = injector.getInstance(AuthInfo.class); assertEquals(token, injected.getSecurityToken()); assertEquals("FakeAuth", injected.getAuthType()); }
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); token.setAppUrl("http://www.example.com/gadget.xml"); Injector injector = Guice.createInjector(); converter = new BeanJsonConverter(injector); HttpRequestHandler handler = new HttpRequestHandler(pipeline, rewriterRegistry, feedProcessorProvider); registry = new DefaultHandlerRegistry(injector, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); builder = new HttpResponseBuilder().setResponseString("CONTENT"); }
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); converter = mock(BeanJsonConverter.class); appDataService = mock(AppDataService.class); AppDataHandler handler = new AppDataHandler(appDataService); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); converter = mock(BeanJsonConverter.class); appDataService = mock(AppDataService.class); AppDataHandler handler = new AppDataHandler(appDataService); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }