Search in sources :

Example 61 with PathSpec

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");
}
Also used : PathSpec(com.linkedin.data.schema.PathSpec) Test(org.testng.annotations.Test)

Example 62 with PathSpec

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");
}
Also used : PathSpec(com.linkedin.data.schema.PathSpec) Test(org.testng.annotations.Test)

Example 63 with PathSpec

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");
}
Also used : PathSpec(com.linkedin.data.schema.PathSpec) Test(org.testng.annotations.Test)

Example 64 with PathSpec

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");
}
Also used : PathSpec(com.linkedin.data.schema.PathSpec) Test(org.testng.annotations.Test)

Example 65 with PathSpec

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&param1=value1&param2=value2";
    String expectedProtocol2Uri = "/?fields=id,message&ids=List(1,2,3)&param1=value1&param2=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)));
}
Also used : PathSpec(com.linkedin.data.schema.PathSpec) DynamicRecordMetadata(com.linkedin.data.template.DynamicRecordMetadata) ResourceSpecImpl(com.linkedin.restli.common.ResourceSpecImpl) TestRecord(com.linkedin.restli.client.test.TestRecord) ResourceMethod(com.linkedin.restli.common.ResourceMethod) Test(org.testng.annotations.Test)

Aggregations

PathSpec (com.linkedin.data.schema.PathSpec)79 Test (org.testng.annotations.Test)63 MaskTree (com.linkedin.data.transform.filter.request.MaskTree)31 DataMap (com.linkedin.data.DataMap)21 HashSet (java.util.HashSet)11 PatchTree (com.linkedin.data.transform.patch.request.PatchTree)9 DataList (com.linkedin.data.DataList)8 RecordTemplate (com.linkedin.data.template.RecordTemplate)7 ResourceMethodDescriptor (com.linkedin.restli.internal.server.model.ResourceMethodDescriptor)7 ByteString (com.linkedin.data.ByteString)6 ArrayList (java.util.ArrayList)6 Foo (com.linkedin.pegasus.generator.examples.Foo)5 RoutingResult (com.linkedin.restli.internal.server.RoutingResult)5 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)5 RestLiResponseData (com.linkedin.restli.server.RestLiResponseData)5 RestLiTestHelper.buildResourceModel (com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel)5 AfterTest (org.testng.annotations.AfterTest)5 BeforeTest (org.testng.annotations.BeforeTest)5 TestRecord (com.linkedin.restli.client.test.TestRecord)4 List (java.util.List)4