Search in sources :

Example 6 with GroupMembership

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;
}
Also used : CompoundKey(com.linkedin.restli.common.CompoundKey) GroupMembershipKey(com.linkedin.restli.examples.groups.api.GroupMembershipKey) GroupMembership(com.linkedin.restli.examples.groups.api.GroupMembership) ComplexKeyGroupMembership(com.linkedin.restli.examples.groups.api.ComplexKeyGroupMembership)

Example 7 with 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;
}
Also used : GroupMembership(com.linkedin.restli.examples.groups.api.GroupMembership) ComplexKeyGroupMembership(com.linkedin.restli.examples.groups.api.ComplexKeyGroupMembership)

Example 8 with 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);
}
Also used : GroupMembershipsRequestBuilders(com.linkedin.restli.examples.groups.client.GroupMembershipsRequestBuilders) GroupMembership(com.linkedin.restli.examples.groups.api.GroupMembership) GroupMembershipsBuilders(com.linkedin.restli.examples.groups.client.GroupMembershipsBuilders) CompoundKey(com.linkedin.restli.common.CompoundKey) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) Test(org.testng.annotations.Test)

Example 9 with GroupMembership

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 } };
}
Also used : URIDetails(com.linkedin.restli.internal.testutils.URIDetails) CompoundKey(com.linkedin.restli.common.CompoundKey) GroupMembershipsRequestBuilders(com.linkedin.restli.examples.groups.client.GroupMembershipsRequestBuilders) GroupMembership(com.linkedin.restli.examples.groups.api.GroupMembership) GroupMembershipsBuilders(com.linkedin.restli.examples.groups.client.GroupMembershipsBuilders) DataProvider(org.testng.annotations.DataProvider)

Example 10 with GroupMembership

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 } };
}
Also used : URIDetails(com.linkedin.restli.internal.testutils.URIDetails) HashMap(java.util.HashMap) CompoundKey(com.linkedin.restli.common.CompoundKey) GroupMembershipsRequestBuilders(com.linkedin.restli.examples.groups.client.GroupMembershipsRequestBuilders) GroupMembership(com.linkedin.restli.examples.groups.api.GroupMembership) GroupMembershipsBuilders(com.linkedin.restli.examples.groups.client.GroupMembershipsBuilders) DataProvider(org.testng.annotations.DataProvider)

Aggregations

GroupMembership (com.linkedin.restli.examples.groups.api.GroupMembership)19 CompoundKey (com.linkedin.restli.common.CompoundKey)15 HashMap (java.util.HashMap)8 GroupMembershipsBuilders (com.linkedin.restli.examples.groups.client.GroupMembershipsBuilders)7 GroupMembershipsRequestBuilders (com.linkedin.restli.examples.groups.client.GroupMembershipsRequestBuilders)7 ComplexKeyGroupMembership (com.linkedin.restli.examples.groups.api.ComplexKeyGroupMembership)6 Test (org.testng.annotations.Test)6 BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)4 URIDetails (com.linkedin.restli.internal.testutils.URIDetails)4 DataProvider (org.testng.annotations.DataProvider)4 UpdateResponse (com.linkedin.restli.server.UpdateResponse)3 Map (java.util.Map)3 DataProcessingException (com.linkedin.data.transform.DataProcessingException)2 EmptyRecord (com.linkedin.restli.common.EmptyRecord)2 EntityResponse (com.linkedin.restli.common.EntityResponse)2 PatchRequest (com.linkedin.restli.common.PatchRequest)2 BatchUpdateResult (com.linkedin.restli.server.BatchUpdateResult)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 RestLiResponseException (com.linkedin.restli.client.RestLiResponseException)1