Search in sources :

Example 1 with CustomTypesRequestBuilders

use of com.linkedin.restli.examples.greetings.client.CustomTypesRequestBuilders in project rest.li by linkedin.

the class TestCustomTypesClient method testCalendarRefActionParam.

@Test
public void testCalendarRefActionParam() throws RemoteInvocationException {
    ActionRequest<Integer> actionRequest = new CustomTypesRequestBuilders().actionCalendarAction().calendarParam(new GregorianCalendar()).build();
    Response<Integer> response = getClient().sendRequest(actionRequest).getResponse();
    Assert.assertEquals(response.getEntity().intValue(), Calendar.getInstance().get(Calendar.YEAR));
}
Also used : CustomTypesRequestBuilders(com.linkedin.restli.examples.greetings.client.CustomTypesRequestBuilders) GregorianCalendar(java.util.GregorianCalendar) Test(org.testng.annotations.Test)

Example 2 with CustomTypesRequestBuilders

use of com.linkedin.restli.examples.greetings.client.CustomTypesRequestBuilders in project rest.li by linkedin.

the class TestCustomTypesClient method testCalendarRefQueryParam.

@Test
public void testCalendarRefQueryParam() throws RemoteInvocationException {
    FindRequest<Greeting> findRequest = new CustomTypesRequestBuilders().findByCalendar().calendarParam(new GregorianCalendar()).build();
    Response<CollectionResponse<Greeting>> response = getClient().sendRequest(findRequest).getResponse();
    Assert.assertEquals(response.getEntity().getElements().size(), 0);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CustomTypesRequestBuilders(com.linkedin.restli.examples.greetings.client.CustomTypesRequestBuilders) CollectionResponse(com.linkedin.restli.common.CollectionResponse) GregorianCalendar(java.util.GregorianCalendar) Test(org.testng.annotations.Test)

Example 3 with CustomTypesRequestBuilders

use of com.linkedin.restli.examples.greetings.client.CustomTypesRequestBuilders in project rest.li by linkedin.

the class TestCustomTypesClient method testIPAddressQueryParam.

// This tests that a typeref that refers to bytes with a custom coercer is serialized correctly when used as a query parameter.
// (See IPAddressSimple.pdsc)
@Test
public void testIPAddressQueryParam() throws RemoteInvocationException, UnknownHostException {
    FindRequest<Greeting> findRequest = new CustomTypesRequestBuilders().findByIp().ipParam(Inet4Address.getByName("linkedin.com")).build();
    Response<CollectionResponse<Greeting>> response = getClient().sendRequest(findRequest).getResponse();
    Assert.assertEquals(response.getEntity().getElements().size(), 0);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CustomTypesRequestBuilders(com.linkedin.restli.examples.greetings.client.CustomTypesRequestBuilders) CollectionResponse(com.linkedin.restli.common.CollectionResponse) Test(org.testng.annotations.Test)

Example 4 with CustomTypesRequestBuilders

use of com.linkedin.restli.examples.greetings.client.CustomTypesRequestBuilders in project rest.li by linkedin.

the class TestCustomTypesClient method testCalendarRefArrayQueryParam.

@Test
public void testCalendarRefArrayQueryParam() throws RemoteInvocationException {
    FindRequest<Greeting> findRequest = new CustomTypesRequestBuilders().findByCalendars().addCalendarsParam(new GregorianCalendar()).build();
    Response<CollectionResponse<Greeting>> response = getClient().sendRequest(findRequest).getResponse();
    Assert.assertEquals(response.getEntity().getElements().size(), 0);
    CalendarRefArray calendarRefArray = new CalendarRefArray();
    calendarRefArray.add(new GregorianCalendar());
    findRequest = new CustomTypesRequestBuilders().findByCalendars().calendarsParam(calendarRefArray).build();
    response = getClient().sendRequest(findRequest).getResponse();
    Assert.assertEquals(response.getEntity().getElements().size(), 0);
    List<Calendar> calendars = new ArrayList<Calendar>();
    calendars.add(new GregorianCalendar());
    findRequest = new CustomTypesRequestBuilders().findByCalendars().calendarsParam(calendars).build();
    response = getClient().sendRequest(findRequest).getResponse();
    Assert.assertEquals(response.getEntity().getElements().size(), 0);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CustomTypesRequestBuilders(com.linkedin.restli.examples.greetings.client.CustomTypesRequestBuilders) CollectionResponse(com.linkedin.restli.common.CollectionResponse) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ArrayList(java.util.ArrayList) CalendarRefArray(com.linkedin.restli.examples.typeref.api.CalendarRefArray) Test(org.testng.annotations.Test)

Aggregations

CustomTypesRequestBuilders (com.linkedin.restli.examples.greetings.client.CustomTypesRequestBuilders)4 Test (org.testng.annotations.Test)4 CollectionResponse (com.linkedin.restli.common.CollectionResponse)3 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)3 GregorianCalendar (java.util.GregorianCalendar)3 CalendarRefArray (com.linkedin.restli.examples.typeref.api.CalendarRefArray)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1