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);
}
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);
}
Aggregations