use of com.linkedin.data.template.LongArray in project rest.li by linkedin.
the class ArrayGeneratorTest method testWithPrimitivesArray.
@Test
public void testWithPrimitivesArray() throws Throwable {
String json = load("WithPrimitivesArray.json");
WithPrimitivesArray original = new WithPrimitivesArray().setInts(new IntegerArray(Arrays.asList(1, 2, 3))).setLongs(new LongArray(10L, 20L, 30L)).setFloats(new FloatArray(1.1f, 2.2f, 3.3f)).setDoubles(new DoubleArray(11.1d, 22.2d, 33.3d)).setBooleans(new BooleanArray(false, true)).setStrings(new StringArray("a", "b", "c")).setBytes(new BytesArray(SchemaFixtures.bytes1, SchemaFixtures.bytes2));
assertJson(original, json);
WithPrimitivesArray roundTripped = new WithPrimitivesArray(roundTrip(original.data()));
assertJson(roundTripped, json);
}
use of com.linkedin.data.template.LongArray in project rest.li by linkedin.
the class TestComplexArrayResource method testAction.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testAction(RootBuilderWrapper<ComplexResourceKey<ComplexArray, ComplexArray>, Greeting> builders) throws RemoteInvocationException {
LongArray singleton = new LongArray(1L);
ComplexArray next = new ComplexArray().setArray(singleton);
ComplexArray array = new ComplexArray().setArray(singleton).setNext(next);
Request<Integer> request = builders.<Integer>action("Action").setActionParam("Array", array).build();
getClient().sendRequest(request).getResponse().getEntity();
}
use of com.linkedin.data.template.LongArray in project rest.li by linkedin.
the class TestComplexArrayResource method testGet.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testGet(RootBuilderWrapper<ComplexResourceKey<ComplexArray, ComplexArray>, Greeting> builders) throws RemoteInvocationException, CloneNotSupportedException {
// all array are singletons with single element
LongArray singleton = new LongArray(1L);
ComplexArray next = new ComplexArray().setArray(singleton);
ComplexArray key = new ComplexArray().setArray(singleton).setNext(next);
ComplexArray params = new ComplexArray().setArray(singleton).setNext(next);
ComplexResourceKey<ComplexArray, ComplexArray> complexKey = new ComplexResourceKey<>(key, params);
Request<Greeting> request = builders.get().id(complexKey).build();
getClient().sendRequest(request).getResponse().getEntity();
}
use of com.linkedin.data.template.LongArray in project rest.li by linkedin.
the class TestParameterDefaultValue method testWrappedArray.
@Test
public void testWrappedArray() {
Object result;
result = test("[\"Hello\", \"World\"]", StringArray.class);
Assert.assertEquals(result, new StringArray("Hello", "World"));
Assert.assertSame(result.getClass(), StringArray.class);
result = test("[false, true]", BooleanArray.class);
Assert.assertEquals(result, new BooleanArray(false, true));
Assert.assertSame(result.getClass(), BooleanArray.class);
result = test("[1, 2, 3]", IntegerArray.class);
Assert.assertEquals(result, new IntegerArray(Arrays.asList(1, 2, 3)));
Assert.assertSame(result.getClass(), IntegerArray.class);
result = test("[1.1, 2.2, 3.3]", IntegerArray.class);
Assert.assertEquals(result, new IntegerArray(Arrays.asList(1, 2, 3)));
Assert.assertSame(result.getClass(), IntegerArray.class);
result = test("[2, 3, 4]", LongArray.class);
Assert.assertEquals(result, new LongArray(2L, 3L, 4L));
Assert.assertSame(result.getClass(), LongArray.class);
result = test("[1.1, 2.2, 3.3]", FloatArray.class);
Assert.assertEquals(result, new FloatArray(1.1F, 2.2F, 3.3F));
Assert.assertSame(result.getClass(), FloatArray.class);
result = test("[2.2, 3.3, 4.4]", DoubleArray.class);
Assert.assertEquals(result, new DoubleArray(2.2D, 3.3D, 4.4D));
Assert.assertSame(result.getClass(), DoubleArray.class);
result = test("[\"APPLE\", \"BANANA\"]", EnumFruitsArray.class);
Assert.assertEquals(result, new EnumFruitsArray(EnumFruits.APPLE, EnumFruits.BANANA));
Assert.assertSame(result.getClass(), EnumFruitsArray.class);
result = test("[" + _bytes16Quoted + ", " + _bytes16Quoted + "]", BytesArray.class);
Assert.assertEquals(result, new BytesArray(ByteString.copyAvroString(_bytes16, true), ByteString.copyAvroString(_bytes16, true)));
Assert.assertSame(result.getClass(), BytesArray.class);
result = test("[" + _bytes16Quoted + ", " + _bytes16Quoted + "]", FixedMD5Array.class);
Assert.assertEquals(result, new FixedMD5Array(new FixedMD5(_bytes16), new FixedMD5(_bytes16)));
Assert.assertSame(result.getClass(), FixedMD5Array.class);
result = test("[{\"string\": \"String in union\"}, {\"int\": 1}]", ArrayTest.UnionArrayArray.class);
final ArrayTest.UnionArray fixture1 = ArrayTest.UnionArray.create("String in union");
final ArrayTest.UnionArray fixture2 = ArrayTest.UnionArray.create(1);
Assert.assertEquals(result, new ArrayTest.UnionArrayArray(fixture1, fixture2));
Assert.assertSame(result.getClass(), ArrayTest.UnionArrayArray.class);
result = test("[{\"location\": \"Sunnyvale\"}, {\"location\": \"Mountain View\"}]", RecordBarArray.class);
final DataMap dataFixture1 = new DataMap();
final DataMap dataFixture2 = new DataMap();
dataFixture1.put("location", "Sunnyvale");
dataFixture2.put("location", "Mountain View");
Assert.assertEquals(result, new RecordBarArray(new RecordBar(dataFixture1), new RecordBar(dataFixture2)));
Assert.assertSame(result.getClass(), RecordBarArray.class);
}
use of com.linkedin.data.template.LongArray in project rest.li by linkedin.
the class TestComplexArrayResource method testFinder.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testFinder(RootBuilderWrapper<ComplexResourceKey<ComplexArray, ComplexArray>, Greeting> builders) throws RemoteInvocationException {
LongArray singleton = new LongArray(1L);
ComplexArray next = new ComplexArray().setArray(singleton);
ComplexArray array = new ComplexArray().setArray(singleton).setNext(next);
Request<CollectionResponse<Greeting>> request = builders.findBy("Finder").setQueryParam("array", array).build();
getClient().sendRequest(request).getResponse().getEntity();
}
Aggregations