Search in sources :

Example 6 with DateTimeRfc1123

use of com.azure.android.core.util.DateTimeRfc1123 in project azure-sdk-for-android by Azure.

the class HttpResponseMapperTests method dateTimeRfc1123EncodedContentList.

@Test
public void dateTimeRfc1123EncodedContentList() throws Throwable {
    Class<DateTimeRfc1123EncodedContentMethods> clazz = DateTimeRfc1123EncodedContentMethods.class;
    Method dateTimeRfc1123ListMethod = clazz.getDeclaredMethod("dateTimeRfc1123List", Callback.class);
    HttpResponseMapper mapperDateTimeRfc1123 = new HttpResponseMapper(dateTimeRfc1123ListMethod, extractCallbackType(dateTimeRfc1123ListMethod), logger);
    JacksonSerder jacksonSerder = new JacksonSerder();
    OffsetDateTime offsetDateTime0 = OffsetDateTime.parse("1980-01-01T10:00:00Z");
    OffsetDateTime offsetDateTime1 = OffsetDateTime.parse("1981-01-01T10:00:00Z");
    List<String> wireDateTimeRfc1123List = new ArrayList<>();
    wireDateTimeRfc1123List.add(new DateTimeRfc1123(offsetDateTime0).toString());
    wireDateTimeRfc1123List.add(new DateTimeRfc1123(offsetDateTime1).toString());
    String wireDateTimeRfc1123JsonList = jacksonSerder.serialize(wireDateTimeRfc1123List, SerdeEncoding.JSON);
    MockHttpResponse httpResponseDateTimeRfc1123 = new MockHttpResponse(HttpMethod.GET, "https://raw.host.com", 200, new HttpHeaders(), wireDateTimeRfc1123JsonList.getBytes());
    Response<List<OffsetDateTime>> httpResponseOffsetDateTimeList = (Response<List<OffsetDateTime>>) mapperDateTimeRfc1123.map(httpResponseDateTimeRfc1123, jacksonSerder);
    List<OffsetDateTime> dateTimeListReceived = httpResponseOffsetDateTimeList.getValue();
    assertNotNull(dateTimeListReceived);
    assertEquals(2, dateTimeListReceived.size());
    assertEquals(0, dateTimeListReceived.get(0).compareTo(offsetDateTime0));
    assertEquals(0, dateTimeListReceived.get(1).compareTo(offsetDateTime1));
}
Also used : HttpHeaders(com.azure.android.core.http.HttpHeaders) JacksonSerder(com.azure.android.core.serde.jackson.JacksonSerder) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) HttpMethod(com.azure.android.core.http.HttpMethod) HttpResponse(com.azure.android.core.http.HttpResponse) PagedResponse(com.azure.android.core.rest.util.paging.PagedResponse) OffsetDateTime(org.threeten.bp.OffsetDateTime) DateTimeRfc1123(com.azure.android.core.util.DateTimeRfc1123) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DateTimeRfc1123 (com.azure.android.core.util.DateTimeRfc1123)6 OffsetDateTime (org.threeten.bp.OffsetDateTime)5 HttpHeaders (com.azure.android.core.http.HttpHeaders)4 HttpResponse (com.azure.android.core.http.HttpResponse)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 HttpMethod (com.azure.android.core.http.HttpMethod)3 PagedResponse (com.azure.android.core.rest.util.paging.PagedResponse)3 JacksonSerder (com.azure.android.core.serde.jackson.JacksonSerder)3 Base64Url (com.azure.android.core.util.Base64Url)3 Method (java.lang.reflect.Method)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 ReturnValueWireType (com.azure.android.core.rest.annotation.ReturnValueWireType)2 UnexpectedResponseExceptionType (com.azure.android.core.rest.annotation.UnexpectedResponseExceptionType)2 UnixTime (com.azure.android.core.util.UnixTime)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2