use of com.amazonaws.transform.JsonUnmarshallerContext in project aws-sdk-android by aws-amplify.
the class JsonUnmarshallerTest method testSimpleMap.
@Test
public void testSimpleMap() throws Exception {
JsonUnmarshallerContext unmarshallerContext = setupUnmarshaller(SIMPLE_MAP);
MapUnmarshaller<String> unmarshaller = new MapUnmarshaller<String>(SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance());
Map<String, String> map = unmarshaller.unmarshall(unmarshallerContext);
assertTrue(map.size() == 2);
assertEquals("value1", map.get("key1"));
assertEquals("value2", map.get("key2"));
}
use of com.amazonaws.transform.JsonUnmarshallerContext in project aws-sdk-android by aws-amplify.
the class InvalidContactFlowModuleExceptionUnmarshaller method unmarshall.
@Override
public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception {
InvalidContactFlowModuleException e = (InvalidContactFlowModuleException) super.unmarshall(error);
e.setErrorCode("InvalidContactFlowModuleException");
final AwsJsonReader jsonReader = JsonUtils.getJsonReader(new StringReader(error.get("Problems")));
e.setProblems(new ListUnmarshaller<ProblemDetail>(ProblemDetailJsonUnmarshaller.getInstance()).unmarshall(new JsonUnmarshallerContext(jsonReader)));
return e;
}
use of com.amazonaws.transform.JsonUnmarshallerContext in project aws-sdk-android by aws-amplify.
the class InvalidContactFlowExceptionUnmarshaller method unmarshall.
@Override
public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception {
InvalidContactFlowException e = (InvalidContactFlowException) super.unmarshall(error);
e.setErrorCode("InvalidContactFlowException");
final AwsJsonReader jsonReader = JsonUtils.getJsonReader(new StringReader(error.get("problems")));
e.setProblems(new ListUnmarshaller<ProblemDetail>(ProblemDetailJsonUnmarshaller.getInstance()).unmarshall(new JsonUnmarshallerContext(jsonReader)));
return e;
}
use of com.amazonaws.transform.JsonUnmarshallerContext in project aws-sdk-android by aws-amplify.
the class JsonUnmarshallerTest method testMapToList.
@Test
public void testMapToList() throws Exception {
JsonUnmarshallerContext unmarshallerContext = setupUnmarshaller(MAP_TO_LIST);
MapUnmarshaller<List<String>> unmarshaller = new MapUnmarshaller<List<String>>(new ListUnmarshaller<String>(SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance()));
Map<String, List<String>> map = unmarshaller.unmarshall(unmarshallerContext);
assertTrue(map.size() == 2);
assertEquals(Arrays.asList(null, "value1"), map.get("key1"));
assertEquals(Arrays.asList("value2"), map.get("key2"));
}
use of com.amazonaws.transform.JsonUnmarshallerContext in project aws-sdk-android by aws-amplify.
the class InvokeResultJsonUnmarshallerTest method testUnmarshall.
@Test
public void testUnmarshall() throws Exception {
int statusCode = 299;
String error = "error";
String log = "a very long log";
String content = "some content";
HttpResponse response = HttpResponse.builder().statusCode(statusCode).statusCode(statusCode).header("X-Amz-Function-Error", error).header("X-Amz-Log-Result", log).content(new ByteArrayInputStream(content.getBytes(StringUtils.UTF8))).build();
JsonUnmarshallerContext context = new JsonUnmarshallerContext(null, response);
InvokeResultJsonUnmarshaller unmarshaller = InvokeResultJsonUnmarshaller.getInstance();
InvokeResult result = unmarshaller.unmarshall(context);
assertTrue("status code", statusCode == result.getStatusCode());
assertEquals("error", error, result.getFunctionError());
assertEquals("log", log, result.getLogResult());
ByteBuffer payload = result.getPayload();
assertArrayEquals("same payload", content.getBytes(StringUtils.UTF8), payload.array());
}
Aggregations