use of com.linkedin.restli.server.twitter.TwitterAccountsResource in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAction_SimpleParameters.
@Test
public void testAction_SimpleParameters() throws Exception {
ResourceModel accountsResourceModel = buildResourceModel(TwitterAccountsResource.class);
ResourceMethodDescriptor methodDescriptor;
TwitterAccountsResource accountsResource;
// #1 no defaults provided
methodDescriptor = accountsResourceModel.findActionMethod("register", ResourceLevel.COLLECTION);
accountsResource = getMockResource(TwitterAccountsResource.class);
accountsResource.register(eq("alfred"), eq("hitchcock"), eq("alfred@test.linkedin.com"), eq("genentech"), eq(false));
EasyMock.expectLastCall().once();
String jsonEntityBody = RestLiTestHelper.doubleQuote("{'first': 'alfred', 'last': 'hitchcock', 'email': 'alfred@test.linkedin.com', " + "'company': 'genentech', 'openToMarketingEmails': false}");
checkInvocation(accountsResource, methodDescriptor, "POST", version, "/accounts?action=register", jsonEntityBody);
// #2 defaults filled in
methodDescriptor = accountsResourceModel.findActionMethod("register", ResourceLevel.COLLECTION);
accountsResource = getMockResource(TwitterAccountsResource.class);
accountsResource.register(eq("alfred"), eq("hitchcock"), eq("alfred@test.linkedin.com"), eq((String) null), eq(true));
EasyMock.expectLastCall().once();
jsonEntityBody = RestLiTestHelper.doubleQuote("{'first': 'alfred', 'last': 'hitchcock', 'email': 'alfred@test.linkedin.com'}");
checkInvocation(accountsResource, methodDescriptor, "POST", version, "/accounts?action=register", jsonEntityBody);
// #3 no-arg method
methodDescriptor = accountsResourceModel.findActionMethod("noArgMethod", ResourceLevel.COLLECTION);
accountsResource = getMockResource(TwitterAccountsResource.class);
accountsResource.noArgMethod();
EasyMock.expectLastCall().once();
jsonEntityBody = RestLiTestHelper.doubleQuote("{}");
checkInvocation(accountsResource, methodDescriptor, "POST", version, "/accounts?action=noArgMethod", jsonEntityBody);
// #4 primitive response
methodDescriptor = accountsResourceModel.findActionMethod("primitiveResponse", ResourceLevel.COLLECTION);
accountsResource = getMockResource(TwitterAccountsResource.class);
EasyMock.expect(accountsResource.primitiveResponse()).andReturn(1).once();
jsonEntityBody = RestLiTestHelper.doubleQuote("{'value': 1}");
checkInvocation(accountsResource, methodDescriptor, "POST", version, "/accounts?action=primitiveResponse", jsonEntityBody);
}
use of com.linkedin.restli.server.twitter.TwitterAccountsResource in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testInvoke_testComplexParameters.
@Test
public void testInvoke_testComplexParameters() throws Exception {
ResourceModel accountsResourceModel = buildResourceModel(TwitterAccountsResource.class);
ResourceMethodDescriptor methodDescriptor;
TwitterAccountsResource accountsResource;
// #1 no defaults provided
methodDescriptor = accountsResourceModel.findActionMethod("closeAccounts", ResourceLevel.COLLECTION);
accountsResource = getMockResource(TwitterAccountsResource.class);
StringArray emailAddresses = new StringArray("bob@test.linkedin.com", "joe@test.linkedin.com");
EasyMock.expect(accountsResource.closeAccounts(eq(emailAddresses), eq(true), eq((StringMap) null))).andReturn((new StringMap())).once();
String jsonEntityBody = RestLiTestHelper.doubleQuote("{'emailAddresses': ['bob@test.linkedin.com', 'joe@test.linkedin.com'], 'someFlag': true}");
checkInvocation(accountsResource, methodDescriptor, "POST", version, "/accounts?action=closeAccounts", jsonEntityBody);
}
Aggregations