com.fasterxml.jackson.databind.exc.InvalidTypeIdException Java Examples

The following examples show how to use com.fasterxml.jackson.databind.exc.InvalidTypeIdException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SerializerProvider.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public JsonMappingException invalidTypeIdException(JavaType baseType, String typeId,
        String extraDesc) {
    String msg = String.format("Could not resolve type id '%s' as a subtype of %s",
            typeId, baseType);
    return InvalidTypeIdException.from(null, _colonConcat(msg, extraDesc), baseType, typeId);
}
 
Example #2
Source File: DeserializationContext.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @since 2.9
 */
public JsonMappingException missingTypeIdException(JavaType baseType,
        String extraDesc) {
    String msg = String.format("Missing type id when trying to resolve subtype of %s",
            baseType);
    return InvalidTypeIdException.from(_parser, _colonConcat(msg, extraDesc), baseType, null);
}
 
Example #3
Source File: BaseCredentialSetRequestTest.java    From credhub with Apache License 2.0 5 votes vote down vote up
@Test(expected = InvalidTypeIdException.class)
public void whenTypeIsEmptyString_throwsException() throws IOException {
  final String json = "{" +
                      "\"name\":\"some-name\"," +
                      "\"type\":\"\"," +
                      "\"value\":\"some-value\"," +
                      "\"overwrite\":true" +
                      "}";

  JsonTestHelper.deserializeChecked(json, BaseCredentialSetRequest.class);
}
 
Example #4
Source File: BaseCredentialSetRequestTest.java    From credhub with Apache License 2.0 5 votes vote down vote up
@Test(expected = InvalidTypeIdException.class)
public void whenTypeIsUnknown_throwsException() throws IOException {
  final String json = "{" +
                      "\"name\":\"some-name\"," +
                      "\"type\":\"moose\"," +
                      "\"value\":\"some-value\"," +
                      "\"overwrite\":true" +
                      "}";

  JsonTestHelper.deserializeChecked(json, BaseCredentialSetRequest.class);
}
 
Example #5
Source File: ProblemHandlerTest.java    From jackson-modules-base with Apache License 2.0 5 votes vote down vote up
public void testInvalidTypeIdFail() throws Exception
{
    try {
        MAPPER.readValue("{\"value\":{\"type\":\"foo\",\"a\":4}}",
            BaseWrapper.class);
        fail("Should not pass");
    } catch (InvalidTypeIdException e) {
        verifyException(e, "Could not resolve type id 'foo'");
        assertEquals(Base.class, e.getBaseType().getRawClass());
        assertEquals("foo", e.getTypeId());
    }
}
 
Example #6
Source File: GeneralExceptionMapperTest.java    From ambari-logsearch with Apache License 2.0 4 votes vote down vote up
@Test
public void testToResponseSetsPredefinedStatusWhenExceptionIsDerivedFromExpectedException() {
  InvalidTypeIdException derivedFromJsonMappingException = new InvalidTypeIdException(null, "Invalid type", null, "any type id");
  Response response = new GeneralExceptionMapper().toResponse(derivedFromJsonMappingException);
  assertThat(response.getStatus(), is(BAD_REQUEST.getStatusCode()));
}
 
Example #7
Source File: DeserializationContext.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public JsonMappingException invalidTypeIdException(JavaType baseType, String typeId,
        String extraDesc) {
    String msg = String.format("Could not resolve type id '%s' as a subtype of %s",
            typeId, baseType);
    return InvalidTypeIdException.from(_parser, _colonConcat(msg, extraDesc), baseType, typeId);
}