Search in sources :

Example 6 with CustomLong

use of com.linkedin.restli.server.custom.types.CustomLong 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)

Example 7 with CustomLong

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

the class TestParameterDefaultValue method testCustomParamArray.

@Test
public void testCustomParamArray() {
    // Initialize the custom class to ensure the coercer is registered.
    Custom.initializeCustomClass(CustomLong.class);
    final ArrayDataSchema customLongRefArraySchema = ((ArrayDataSchema) DataTemplateUtil.parseSchema("{\"type\":\"array\",\"items\":{\"type\":\"typeref\",\"name\":\"CustomLongRef\",\"namespace\":\"com.linkedin.restli.examples.typeref.api\",\"ref\":\"long\",\"java\":{\"class\":\"com.linkedin.restli.examples.custom.types.CustomLong\"}}}"));
    Object result = test("[12345, 6789]", CustomLong[].class, customLongRefArraySchema);
    final CustomLong[] expectedCustomLongs = { new CustomLong(12345L), new CustomLong(6789L) };
    Assert.assertEquals(result, expectedCustomLongs);
    Assert.assertSame(result.getClass(), CustomLong[].class);
}
Also used : ArrayDataSchema(com.linkedin.data.schema.ArrayDataSchema) CustomLong(com.linkedin.restli.server.custom.types.CustomLong) Test(org.testng.annotations.Test) ArrayTest(com.linkedin.pegasus.generator.test.ArrayTest)

Aggregations

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