Search in sources :

Example 1 with CustomString

use of com.linkedin.restli.server.custom.types.CustomString in project rest.li by linkedin.

the class TestRestLiMethodInvocation method testCustomTypeParametersCustomString.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "customStringParam")
public void testCustomTypeParametersCustomString(ProtocolVersion version, String uri) throws Exception {
    ResourceModel repliesResourceModel = buildResourceModel(RepliesCollectionResource.class);
    ResourceMethodDescriptor methodDescriptor = repliesResourceModel.findFinderMethod("customString");
    RepliesCollectionResource repliesResource = getMockResource(RepliesCollectionResource.class);
    repliesResource.customString(new CustomString("foo"));
    EasyMock.expectLastCall().andReturn(null).once();
    checkInvocation(repliesResource, methodDescriptor, "GET", version, uri);
}
Also used : PromiseRepliesCollectionResource(com.linkedin.restli.server.twitter.PromiseRepliesCollectionResource) RepliesCollectionResource(com.linkedin.restli.server.twitter.RepliesCollectionResource) AsyncRepliesCollectionResource(com.linkedin.restli.server.twitter.AsyncRepliesCollectionResource) ResourceMethodDescriptor(com.linkedin.restli.internal.server.model.ResourceMethodDescriptor) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RestLiTestHelper.buildResourceModel(com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel) CustomString(com.linkedin.restli.server.custom.types.CustomString) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with CustomString

use of com.linkedin.restli.server.custom.types.CustomString in project rest.li by linkedin.

the class TestConvertSimpleValue method testConvertCustomString.

@Test
public void testConvertCustomString() {
    CustomString forceRegistration = new CustomString("");
    Class<?> customStringClass = CustomString.class;
    Object convertedCustomString = ArgumentUtils.convertSimpleValue("aString", DataTemplateUtil.getSchema(CustomStringRef.class), customStringClass);
    Assert.assertTrue(convertedCustomString.getClass().equals(customStringClass));
    CustomString customString = (CustomString) convertedCustomString;
    Assert.assertTrue(customString.toString().equals("aString"));
}
Also used : CustomString(com.linkedin.restli.server.custom.types.CustomString) CustomStringRef(com.linkedin.restli.server.CustomStringRef) Test(org.testng.annotations.Test)

Example 3 with CustomString

use of com.linkedin.restli.server.custom.types.CustomString in project rest.li by linkedin.

the class TestParameterDefaultValue method testCustomParams.

@Test
public void testCustomParams() {
    // Initialize the custom class to ensure the coercer is registered.
    Custom.initializeCustomClass(CustomString.class);
    Object result = test("custom string ref", CustomString.class, new CustomStringRef().getSchema());
    final CustomString expectedCustomString = new CustomString("custom string ref");
    Assert.assertEquals(result, expectedCustomString);
    Assert.assertSame(result.getClass(), CustomString.class);
    result = test("12345", CustomLong.class, new CustomLongRef().getSchema());
    final CustomLong expectedCustomLong = new CustomLong(12345L);
    Assert.assertEquals(result, expectedCustomLong);
    Assert.assertSame(result.getClass(), CustomLong.class);
}
Also used : CustomString(com.linkedin.restli.server.custom.types.CustomString) CustomLong(com.linkedin.restli.server.custom.types.CustomLong) CustomLongRef(com.linkedin.restli.server.CustomLongRef) CustomStringRef(com.linkedin.restli.server.CustomStringRef) Test(org.testng.annotations.Test) ArrayTest(com.linkedin.pegasus.generator.test.ArrayTest)

Aggregations

CustomString (com.linkedin.restli.server.custom.types.CustomString)3 Test (org.testng.annotations.Test)3 CustomStringRef (com.linkedin.restli.server.CustomStringRef)2 ArrayTest (com.linkedin.pegasus.generator.test.ArrayTest)1 ResourceMethodDescriptor (com.linkedin.restli.internal.server.model.ResourceMethodDescriptor)1 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)1 CustomLongRef (com.linkedin.restli.server.CustomLongRef)1 CustomLong (com.linkedin.restli.server.custom.types.CustomLong)1 RestLiTestHelper.buildResourceModel (com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel)1 AsyncRepliesCollectionResource (com.linkedin.restli.server.twitter.AsyncRepliesCollectionResource)1 PromiseRepliesCollectionResource (com.linkedin.restli.server.twitter.PromiseRepliesCollectionResource)1 RepliesCollectionResource (com.linkedin.restli.server.twitter.RepliesCollectionResource)1 AfterTest (org.testng.annotations.AfterTest)1 BeforeTest (org.testng.annotations.BeforeTest)1