use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestPathSpec method testSelfReferencePathSpec.
@Test
public void testSelfReferencePathSpec() {
PathSpec p = AliasTest.fields().a1().a1().a1().a1();
Assert.assertEquals(p.toString(), "/a1/a1/a1/a1");
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestPathSpec method testTyperefPathSpec.
@Test
public void testTyperefPathSpec() {
PathSpec p = TyperefTest.fields().bar1().location();
Assert.assertEquals(p.toString(), "/bar1/location");
p = TyperefTest.fields().barRefMap().values().location();
Assert.assertEquals(p.toString(), "/barRefMap/*/location");
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestPathSpec method testUnionPathSpec.
@Test
public void testUnionPathSpec() {
PathSpec p = UnionTest.fields().unionWithInline().RecordInUnion().a();
Assert.assertEquals(p.toString(), "/unionWithInline/com.linkedin.pegasus.generator.testpackage.RecordInUnion/a");
p = UnionTest.fields().unionWithoutNull().RecordBar().location();
Assert.assertEquals(p.toString(), "/unionWithoutNull/com.linkedin.pegasus.generator.testpackage.RecordBar/location");
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestPathSpec method testArrayWildcardPathSpec.
@Test
public void testArrayWildcardPathSpec() {
PathSpec p = ArrayTest.fields().recordInlineArray().items().f();
Assert.assertEquals(p.toString(), "/recordInlineArray/*/f");
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class BatchGetRequestBuilderTest method testSimpleBatching.
@Test
public void testSimpleBatching() throws URISyntaxException {
String expectedProtocol1Uri = "/?fields=id,message&ids=1&ids=2&ids=3¶m1=value1¶m2=value2";
String expectedProtocol2Uri = "/?fields=id,message&ids=List(1,2,3)¶m1=value1¶m2=value2";
BatchGetRequestBuilder<Integer, TestRecord> batchRequestBuilder1 = new BatchGetRequestBuilder<Integer, TestRecord>("/", TestRecord.class, new ResourceSpecImpl(Collections.<ResourceMethod>emptySet(), Collections.<String, DynamicRecordMetadata>emptyMap(), Collections.<String, DynamicRecordMetadata>emptyMap(), Integer.class, null, null, null, Collections.<String, Object>emptyMap()), RestliRequestOptions.DEFAULT_OPTIONS);
batchRequestBuilder1.ids(1, 2).fields(FIELDS.id()).setParam("param2", "value2").setParam("param1", "value1");
BatchGetRequestBuilder<Integer, TestRecord> batchRequestBuilder2 = new BatchGetRequestBuilder<Integer, TestRecord>("/", TestRecord.class, new ResourceSpecImpl(Collections.<ResourceMethod>emptySet(), Collections.<String, DynamicRecordMetadata>emptyMap(), Collections.<String, DynamicRecordMetadata>emptyMap(), Integer.class, null, null, null, Collections.<String, Object>emptyMap()), RestliRequestOptions.DEFAULT_OPTIONS);
batchRequestBuilder2.ids(2, 3).fields(FIELDS.id(), FIELDS.message()).setParam("param1", "value1").setParam("param2", "value2");
BatchGetRequest<TestRecord> batchRequest1 = batchRequestBuilder1.build();
BatchGetRequest<TestRecord> batchRequest2 = batchRequestBuilder2.build();
@SuppressWarnings("unchecked") BatchGetRequest<TestRecord> batchingRequest = BatchGetRequestBuilder.batch(Arrays.asList(batchRequest1, batchRequest2));
testUriGeneration(batchingRequest, expectedProtocol1Uri, expectedProtocol2Uri);
Assert.assertEquals(batchingRequest.getBaseUriTemplate(), batchRequest1.getBaseUriTemplate());
Assert.assertEquals(batchingRequest.getPathKeys(), batchRequest1.getPathKeys());
Assert.assertEquals(batchingRequest.getFields(), new HashSet<PathSpec>(Arrays.asList(FIELDS.id(), FIELDS.message())));
Assert.assertEquals(batchingRequest.getObjectIds(), new HashSet<Integer>(Arrays.asList(1, 2, 3)));
}
Aggregations