Search in sources :

Example 1 with GetRequestBuilder

use of com.linkedin.restli.client.GetRequestBuilder in project rest.li by linkedin.

the class TestTyperefCustomDoubleAssociationKeyResource method testGet.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
public void testGet(RestliRequestOptions requestOptions) throws RemoteInvocationException {
    HashMap<String, CompoundKey.TypeInfo> keyParts = new HashMap<String, CompoundKey.TypeInfo>();
    keyParts.put("src", new CompoundKey.TypeInfo(Double.class, Double.class));
    keyParts.put("dest", new CompoundKey.TypeInfo(Double.class, Double.class));
    GetRequestBuilder<CompoundKey, Message> getBuilder = new GetRequestBuilder<CompoundKey, Message>("typerefCustomDoubleAssociationKeyResource", Message.class, new ResourceSpecImpl(EnumSet.of(ResourceMethod.GET), new HashMap<String, DynamicRecordMetadata>(), new HashMap<String, DynamicRecordMetadata>(), CompoundKey.class, null, null, Message.class, keyParts), requestOptions);
    final String[] stringArray = { "foo" };
    GetRequest<Message> req = getBuilder.id(new CompoundKey().append("src", 100.0).append("dest", 200.0)).setReqParam("array", stringArray).build();
    Response<Message> resp = REST_CLIENT.sendRequest(req).getResponse();
    Message result = resp.getEntity();
    Assert.assertEquals(result.getId(), "100.0->200.0");
    Assert.assertEquals(result.getMessage(), String.format("I need some $20. Array contents %s.", Arrays.asList(stringArray)));
}
Also used : Message(com.linkedin.restli.examples.greetings.api.Message) HashMap(java.util.HashMap) CompoundKey(com.linkedin.restli.common.CompoundKey) ResourceSpecImpl(com.linkedin.restli.common.ResourceSpecImpl) GetRequestBuilder(com.linkedin.restli.client.GetRequestBuilder) Test(org.testng.annotations.Test)

Aggregations

GetRequestBuilder (com.linkedin.restli.client.GetRequestBuilder)1 CompoundKey (com.linkedin.restli.common.CompoundKey)1 ResourceSpecImpl (com.linkedin.restli.common.ResourceSpecImpl)1 Message (com.linkedin.restli.examples.greetings.api.Message)1 HashMap (java.util.HashMap)1 Test (org.testng.annotations.Test)1