use of com.linkedin.restli.examples.groups.api.GroupMembership in project rest.li by linkedin.
the class GroupMembershipsResource3 method toGroupMembership.
// This is a hack for the sample resource. So as not to write a separate persistence for this resource,
// convert from and to GroupMembership.
private static GroupMembership toGroupMembership(ComplexKeyGroupMembership complexKeyMembership) {
GroupMembership groupMembership = new GroupMembership(complexKeyMembership.data());
GroupMembershipKey complexKey = complexKeyMembership.getId();
CompoundKey compoundKey = new CompoundKey().append(GROUP_ID, complexKey.getGroupID()).append(MEMBER_ID, complexKey.getMemberID());
groupMembership.setId(URIParamUtils.encodeKeyForBody(compoundKey, true, AllProtocolVersions.BASELINE_PROTOCOL_VERSION));
groupMembership.setMemberID(complexKey.getMemberID());
groupMembership.setGroupID(complexKey.getGroupID());
return groupMembership;
}
use of com.linkedin.restli.examples.groups.api.GroupMembership in project rest.li by linkedin.
the class TestGroupsClient method buildGroupMembership.
private static GroupMembership buildGroupMembership(Integer id, String contactEmail, String firstName, String lastName) {
GroupMembership groupMembership = new GroupMembership();
if (id != null) {
groupMembership.setMemberID(id);
}
groupMembership.setContactEmail(contactEmail);
groupMembership.setFirstName(firstName);
groupMembership.setLastName(lastName);
// These fields must be set when creating a stand-alone group membership,
// lest the membership be considered incomplete.
groupMembership.setAllowMessagesFromMembers(true);
groupMembership.setEmailAnnouncementsFromManagers(true);
groupMembership.setEmailDigestFrequency(EmailDigestFrequency.WEEKLY);
groupMembership.setEmailForEveryNewPost(true);
groupMembership.setIsPublicized(true);
groupMembership.setMembershipLevel(MembershipLevel.MEMBER);
groupMembership.setWriteLevel(WriteLevel.DEFAULT);
return groupMembership;
}
use of com.linkedin.restli.examples.groups.api.GroupMembership in project rest.li by linkedin.
the class TestGroupsRequestBuilders method testAssociationBatchGetEntityByAssociationMultipleCompoundKeys2.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestMembershipsBatchDataProvider")
public void testAssociationBatchGetEntityByAssociationMultipleCompoundKeys2(URIDetails expectedURIDetails) throws IOException, RestException, URISyntaxException {
GroupMembershipsBuilders.Key key1 = new GroupMembershipsBuilders.Key().setGroupId(1).setMemberId(1);
GroupMembershipsBuilders.Key key2 = new GroupMembershipsBuilders.Key().setGroupId(2).setMemberId(1);
GroupMembershipsBuilders.Key key3 = new GroupMembershipsBuilders.Key().setGroupId(2).setMemberId(2);
Request<BatchKVResponse<CompoundKey, EntityResponse<GroupMembership>>> request = new GroupMembershipsRequestBuilders().batchGet().ids(key1, key2, key3).build();
checkRequestBuilder(request, ResourceMethod.BATCH_GET, BatchEntityResponseDecoder.class, expectedURIDetails, null);
}
use of com.linkedin.restli.examples.groups.api.GroupMembership in project rest.li by linkedin.
the class TestGroupsRequestBuilders method requestMembershipsBuilderDataProviderEntity.
@DataProvider(name = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestMembershipsBuilderDataProviderEntity")
private static Object[][] requestMembershipsBuilderDataProviderEntity() {
//Sample URIs:
//"groupMemberships/groupID=7&memberID=1"
//"groupMemberships/(groupID:7,memberID:1)"
final URIDetails uriDetails1 = new URIDetails(AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), "groupMemberships/groupID=7&memberID=1", null, null, null);
final URIDetails uriDetails2 = new URIDetails(AllProtocolVersions.RESTLI_PROTOCOL_2_0_0.getProtocolVersion(), "groupMemberships/(groupID:7,memberID:1)", null, null, null);
return new Object[][] { { new RootBuilderWrapper<CompoundKey, GroupMembership>(new GroupMembershipsBuilders()), uriDetails1 }, { new RootBuilderWrapper<CompoundKey, GroupMembership>(new GroupMembershipsBuilders()), uriDetails2 }, { new RootBuilderWrapper<CompoundKey, GroupMembership>(new GroupMembershipsRequestBuilders()), uriDetails1 }, { new RootBuilderWrapper<CompoundKey, GroupMembership>(new GroupMembershipsRequestBuilders()), uriDetails2 } };
}
use of com.linkedin.restli.examples.groups.api.GroupMembership in project rest.li by linkedin.
the class TestGroupsRequestBuilders method requestMembershipsBuilderDataProviderEntityFinderByGroupWithOptional.
@DataProvider(name = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestMembershipsBuilderDataProviderEntityFinderByGroupWithOptional")
private static Object[][] requestMembershipsBuilderDataProviderEntityFinderByGroupWithOptional() {
//Sample URIs:
//"groupMemberships/groupID=1?firstName=Bruce&q=group"
//"groupMemberships/(groupID:1)?firstName=Bruce&q=group"
final Map<String, String> queryParamsMap = new HashMap<String, String>();
queryParamsMap.put("firstName", "Bruce");
queryParamsMap.put("q", "group");
final URIDetails uriDetails1 = new URIDetails(AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), "groupMemberships/groupID=1", null, queryParamsMap, null);
final URIDetails uriDetails2 = new URIDetails(AllProtocolVersions.RESTLI_PROTOCOL_2_0_0.getProtocolVersion(), "groupMemberships/(groupID:1)", null, queryParamsMap, null);
return new Object[][] { { new RootBuilderWrapper<CompoundKey, GroupMembership>(new GroupMembershipsBuilders()), uriDetails1 }, { new RootBuilderWrapper<CompoundKey, GroupMembership>(new GroupMembershipsBuilders()), uriDetails2 }, { new RootBuilderWrapper<CompoundKey, GroupMembership>(new GroupMembershipsRequestBuilders()), uriDetails1 }, { new RootBuilderWrapper<CompoundKey, GroupMembership>(new GroupMembershipsRequestBuilders()), uriDetails2 } };
}
Aggregations