private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/activities/john.doe/@" + group.toString(); RestHandler operation = registry.getRestHandler(path, "GET"); List<Activity> activityList = ImmutableList.of(); RestfulCollection<Activity> data = new RestfulCollection<Activity>(activityList); org.easymock.EasyMock.expect(activityService.getActivities(eq(JOHN_DOE), eq(new GroupId(group, null)), (String)isNull(), eq(ImmutableSet.<String>of()), org.easymock.EasyMock.isA(CollectionOptions.class), eq(token))). andReturn(ImmediateFuture.newInstance(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
/** * If the given object is an objectId, create and store * Else we need the string representation to store, including the "@" * * @param objectId Object * @throws IllegalArgumentException */ public GroupId(Object objectId) throws IllegalArgumentException { if(objectId == null) { this.objectId = new ObjectId(""); // If it is an objectId, store as is } else if(objectId instanceof ObjectId) { this.objectId = (ObjectId) objectId; // Else it must be a string, store as such } else { if(Type.objectId.equals(getType(objectId))) { this.objectId = new ObjectId(objectId.toString()); } else { this.objectId = objectId.toString(); } } }
/** * Backwards Compatibility. * * @param type * @param objectId * @throws IllegalArgumentException when the provided objectId is not valid */ public GroupId(Type type, String objectId) throws IllegalArgumentException { // If Type is an objectId, convert objectId to ObjectId and store if(type.equals(Type.objectId)) { this.objectId = new ObjectId(objectId); // Else store the string representation of the type } else if(Type.custom.equals(type)){ //Custom @ id this.objectId = objectId; } else { this.objectId = typeToString(type); } }
/** * If the given object is an objectId, create and store * Else we need the string representation to store, including the "@" * * @param objectId Object * @throws IllegalArgumentException */ public GroupId(Object objectId) throws IllegalArgumentException { if(objectId == null) { this.objectId = new ObjectId(""); // If it is an objectId, store as is } else if(objectId instanceof ObjectId) { this.objectId = (ObjectId) objectId; // Else it must be a string, store as such } else { if(Type.objectId.equals(getType(objectId))) { this.objectId = new ObjectId(objectId.toString()); } else { this.objectId = objectId.toString(); } } }
/** * Backwards Compatibility. * * @param type * @param objectId * @throws IllegalArgumentException when the provided objectId is not valid */ public GroupId(Type type, String objectId) throws IllegalArgumentException { // If Type is an objectId, convert objectId to ObjectId and store if(type.equals(Type.objectId)) { this.objectId = new ObjectId(objectId); // Else store the string representation of the type } else if(Type.custom.equals(type)){ //Custom @ id this.objectId = objectId; } else { this.objectId = typeToString(type); } }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/activitystreams/john.doe/@" + group.toString(); RestHandler operation = registry.getRestHandler(path, "GET"); List<ActivityEntry> entries = ImmutableList.of(); RestfulCollection<ActivityEntry> data = new RestfulCollection<ActivityEntry>(entries); org.easymock.EasyMock.expect(service.getActivityEntries(eq(JOHN_DOE), eq(new GroupId(group, null)), (String)isNull(), eq(ImmutableSet.<String>of()), org.easymock.EasyMock.isA(CollectionOptions.class), eq(token))). andReturn(Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/activities/john.doe/@" + group.toString(); RestHandler operation = registry.getRestHandler(path, "GET"); List<Activity> activityList = ImmutableList.of(); RestfulCollection<Activity> data = new RestfulCollection<Activity>(activityList); org.easymock.EasyMock.expect(activityService.getActivities(eq(JOHN_DOE), eq(new GroupId(group, null)), (String)isNull(), eq(ImmutableSet.<String>of()), org.easymock.EasyMock.isA(CollectionOptions.class), eq(token))). andReturn(Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/activitystreams/john.doe/@" + group.toString(); RestHandler operation = registry.getRestHandler(path, "GET"); List<ActivityEntry> entries = ImmutableList.of(); RestfulCollection<ActivityEntry> data = new RestfulCollection<ActivityEntry>(entries); org.easymock.EasyMock.expect(service.getActivityEntries(eq(JOHN_DOE), eq(new GroupId(group, null)), (String)isNull(), eq(ImmutableSet.<String>of()), org.easymock.EasyMock.isA(CollectionOptions.class), eq(token))). andReturn(Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
/** * Set the objectId with a String * * @param objectId String * @throws IllegalArgumentException */ public void setObjectId(String objectId) throws IllegalArgumentException { if(getType(objectId).equals(Type.objectId)) { this.objectId = new ObjectId(objectId); } else { this.objectId = objectId; } }
/** * Set the objectId with a String * * @param objectId String * @throws IllegalArgumentException */ public void setObjectId(String objectId) throws IllegalArgumentException { if(getType(objectId).equals(Type.objectId)) { this.objectId = new ObjectId(objectId); } else { this.objectId = objectId; } }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/appdata/john.doe/@" + group.toString() + "/appId"; RestHandler operation = registry.getRestHandler(path, "GET"); DataCollection data = new DataCollection(null); org.easymock.EasyMock.expect(appDataService.getPersonData(eq(JOHN_DOE), eq(new GroupId(group, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(token))) .andReturn(Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/activities/john.doe/@" + group.toString(); RestHandler operation = registry.getRestHandler(path, "GET"); List<Activity> activityList = ImmutableList.of(); RestfulCollection<Activity> data = new RestfulCollection<Activity>(activityList); org.easymock.EasyMock.expect(activityService.getActivities(eq(JOHN_DOE), eq(new GroupId(group, null)), (String)isNull(), eq(ImmutableSet.<String>of()), org.easymock.EasyMock.isA(CollectionOptions.class), eq(token))). andReturn(Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
public static GroupId fromJson(String jsonId) { Type idSpecEnum = Type.jsonValueOf(jsonId); if (idSpecEnum != null) { return new GroupId(idSpecEnum, null); } return new GroupId(Type.groupId, jsonId); }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/appdata/john.doe/@" + group.toString() + "/appId"; RestHandler operation = registry.getRestHandler(path, "GET"); DataCollection data = new DataCollection(null); org.easymock.EasyMock.expect(appDataService.getPersonData(eq(JOHN_DOE), eq(new GroupId(group, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(token))) .andReturn(Futures.immediateFuture(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); }
private void assertHandleGetForGroup(GroupId.Type group) throws Exception { String path = "/appdata/john.doe/@" + group.toString() + "/appId"; RestHandler operation = registry.getRestHandler(path, "GET"); DataCollection data = new DataCollection(null); org.easymock.EasyMock.expect(appDataService.getPersonData(eq(JOHN_DOE), eq(new GroupId(group, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(token))) .andReturn(ImmediateFuture.newInstance(data)); replay(); assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); }