类com.fasterxml.jackson.databind.exc.InvalidTypeIdException源码实例Demo

下面列出了怎么用com.fasterxml.jackson.databind.exc.InvalidTypeIdException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: SerializerProvider.java
@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);
}
 
源代码2 项目: lams   文件: DeserializationContext.java
@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);
}
 
源代码3 项目: lams   文件: DeserializationContext.java
/**
 * @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);
}
 
源代码4 项目: credhub   文件: BaseCredentialSetRequestTest.java
@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);
}
 
源代码5 项目: credhub   文件: BaseCredentialSetRequestTest.java
@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);
}
 
源代码6 项目: jackson-modules-base   文件: ProblemHandlerTest.java
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());
    }
}
 
@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()));
}
 
 同包方法