@Test
public void testGetValueAsInstance() throws IOException {

	// With object mapper
	MultipartBody multipartBody = MultipartBody.of(
		Collections.emptyMap(), __ -> _objectMapper,
		Collections.singletonMap(
			"key",
			JSONUtil.put(
				"list", Arrays.asList(1, 2, 3)
			).put(
				"number", 42
			).put(
				"string", "Hello"
			).toString()));
	TestClass testClass = multipartBody.getValueAsInstance(
		"key", TestClass.class);
	assertThat(testClass.list, contains(1, 2, 3));
	assertThat(testClass.number, is(42L));
	assertThat(testClass.string, is("Hello"));
	assertThat(testClass.testClass, is(nullValue()));
	try {
		multipartBody.getValueAsInstance("null", TestClass.class);
		throw new AssertionError("Should thrown exception");
	}
	catch (Exception exception) {
		assertThat(exception, is(instanceOf(BadRequestException.class)));
		assertThat(
			exception.getMessage(),
			is("Missing JSON property with the key: null"));
	}
	// Without object mapper
	multipartBody = MultipartBody.of(
		Collections.emptyMap(), __ -> null,
		Collections.singletonMap("key", "value"));
	try {
		multipartBody.getValueAsInstance("key", TestClass.class);
		throw new AssertionError();
	}
	catch (Exception exception) {
		assertThat(
			exception, is(instanceOf(InternalServerErrorException.class)));
		String expectedMessage =
			"Unable to get object mapper for class " +
				TestClass.class.getName();
		assertThat(exception.getMessage(), is(expectedMessage));
	}
}