use of com.azure.android.core.serde.jackson.JacksonSerder in project azure-sdk-for-android by Azure.
the class HttpRequestMapperTests method querySubstitution.
@ParameterizedTest
@MethodSource("querySubstitutionSupplier")
public void querySubstitution(Method method, Object[] arguments, String expectedUrl) {
HttpRequestMapper mapper = new HttpRequestMapper("https://raw.host.com", method, new JacksonSerder());
UrlBuilder urlBuilder = UrlBuilder.parse("https://raw.host.com");
mapper.applyQueryMappings(arguments, urlBuilder);
assertEquals(expectedUrl, urlBuilder.toString());
}
use of com.azure.android.core.serde.jackson.JacksonSerder in project azure-sdk-for-android by Azure.
the class HttpRequestMapperTests method noHttpMethodAnnotation.
@Test
public void noHttpMethodAnnotation() throws NoSuchMethodException {
Method noHttpMethodAnnotation = OperationMethods.class.getDeclaredMethod("noMethod");
Exception ex = null;
try {
new HttpRequestMapper("s://raw.host.com", noHttpMethodAnnotation, new JacksonSerder());
} catch (RuntimeException e) {
ex = e;
}
Assertions.assertNotNull(ex);
Assertions.assertTrue(ex.getMessage().contains("Either Get, Put, Head, Delete, Post or Patch " + "annotation must be defined on the method"));
}
use of com.azure.android.core.serde.jackson.JacksonSerder in project azure-sdk-for-android by Azure.
the class HttpRequestMapperTests method formAndBody.
@Test
public void formAndBody() throws NoSuchMethodException {
Class<FormAndBodyMethods> clazz = FormAndBodyMethods.class;
Method formAndBodyMethod = clazz.getDeclaredMethod("formAndBody", String.class, String.class, Callback.class);
RuntimeException ex = null;
try {
new HttpRequestMapper("https://raw.host.com", formAndBodyMethod, new JacksonSerder());
} catch (RuntimeException e) {
ex = e;
}
Assertions.assertNotNull(ex);
Assertions.assertTrue(ex.getMessage().contains("'FormParam' and 'BodyParam' are mutually exclusive, but the method"));
}
use of com.azure.android.core.serde.jackson.JacksonSerder in project azure-sdk-for-android by Azure.
the class HttpRequestMapperTests method schemeSubstitution.
@ParameterizedTest
@MethodSource("schemeSubstitutionSupplier")
public void schemeSubstitution(Method method, String rawHost, Object[] arguments, String expectedUrl) {
HttpRequestMapper mapper = new HttpRequestMapper(rawHost, method, new JacksonSerder());
UrlBuilder urlBuilder = new UrlBuilder();
mapper.applySchemeAndHostMapping(arguments, urlBuilder);
assertEquals(expectedUrl, urlBuilder.toString());
}
use of com.azure.android.core.serde.jackson.JacksonSerder in project azure-sdk-for-android by Azure.
the class HttpResponseMapperTests method base64EncodedContentList.
@Test
public void base64EncodedContentList() throws Throwable {
Class<Base64EncodedContentMethods> clazz = Base64EncodedContentMethods.class;
Method base64UrlListMethod = clazz.getDeclaredMethod("base64UrlList", Callback.class);
HttpResponseMapper mapperBase64List = new HttpResponseMapper(base64UrlListMethod, extractCallbackType(base64UrlListMethod), logger);
JacksonSerder jacksonSerder = new JacksonSerder();
final String value0ToEncode = "hello azure android";
final String value1ToEncode = "hello azure android again";
List<String> base64EncodedBytesList = new ArrayList<>();
base64EncodedBytesList.add(Base64Url.encode(value0ToEncode.getBytes()).toString());
base64EncodedBytesList.add(Base64Url.encode(value1ToEncode.getBytes()).toString());
String wireBase64EncodedList = jacksonSerder.serialize(base64EncodedBytesList, SerdeEncoding.JSON);
MockHttpResponse httpResponseBase64EncodedBytesList = new MockHttpResponse(HttpMethod.GET, "https://raw.host.com", 200, new HttpHeaders(), wireBase64EncodedList.getBytes());
Response<List<byte[]>> restResponseBase64DecodedBytesList = (Response<List<byte[]>>) mapperBase64List.map(httpResponseBase64EncodedBytesList, jacksonSerder);
List<byte[]> decodedBytesList = restResponseBase64DecodedBytesList.getValue();
assertNotNull(decodedBytesList);
assertEquals(2, decodedBytesList.size());
assertArrayEquals(value0ToEncode.getBytes(), decodedBytesList.get(0));
assertArrayEquals(value1ToEncode.getBytes(), decodedBytesList.get(1));
}
Aggregations