Java Code Examples for com.fasterxml.jackson.databind.type.SimpleType#constructUnsafe()

The following examples show how to use com.fasterxml.jackson.databind.type.SimpleType#constructUnsafe() . 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: AuthenticationExtensionsAuthenticatorOutputsEnvelopeDeserializer.java    From webauthn4j with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AuthenticationExtensionsAuthenticatorOutputsEnvelope<? extends ExtensionAuthenticatorOutput<?>> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    JavaType javaType = SimpleType.constructUnsafe(AuthenticationExtensionsAuthenticatorOutputs.class);
    AuthenticationExtensionsAuthenticatorOutputs<? extends ExtensionAuthenticatorOutput<?>> authenticationExtensionsAuthenticatorOutputs = ctxt.readValue(p, javaType);
    int length = (int) p.getCurrentLocation().getByteOffset();
    return new AuthenticationExtensionsAuthenticatorOutputsEnvelope<>(authenticationExtensionsAuthenticatorOutputs, length);
}
 
Example 2
Source File: TestDefaultHttpClientFilter.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void testAfterReceiveResponseNullProduceProcessor(@Mocked Invocation invocation,
    @Mocked HttpServletResponseEx responseEx,
    @Mocked OperationMeta operationMeta,
    @Mocked RestOperationMeta swaggerRestOperation) throws Exception {
  CommonExceptionData data = new CommonExceptionData("abcd");
  new Expectations() {
    {
      invocation.getOperationMeta();
      result = operationMeta;
      operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION);
      result = swaggerRestOperation;
      invocation.findResponseType(403);
      result = SimpleType.constructUnsafe(CommonExceptionData.class);
      responseEx.getStatus();
      result = 403;
      responseEx.getStatusType();
      result = Status.FORBIDDEN;
      responseEx.getBodyBuffer();
      result = Buffer.buffer(JsonUtils.writeValueAsString(data).getBytes());
    }
  };

  Response response = filter.afterReceiveResponse(invocation, responseEx);
  Assert.assertEquals(403, response.getStatusCode());
  Assert.assertEquals("Forbidden", response.getReasonPhrase());
  Assert.assertEquals(InvocationException.class, response.<InvocationException>getResult().getClass());
  InvocationException invocationException = response.getResult();
  Assert.assertEquals(
      403,
      invocationException.getStatusCode());
  Assert.assertEquals(
      "CommonExceptionData [message=abcd]",
      invocationException.getErrorData().toString());
}
 
Example 3
Source File: NodeTypeResolver.java    From depgraph-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public JavaType typeFromId(DatabindContext context, String id) {
  try {
    return SimpleType.constructUnsafe(Class.forName(getClass().getPackage().getName() + "." + id.substring(0, 1).toUpperCase() + id.substring(1)));
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
}
 
Example 4
Source File: RestOperationsFactoryTest.java    From bowman with Apache License 2.0 4 votes vote down vote up
protected DummyTypeIdResolver() {
	super(SimpleType.constructUnsafe(Object.class), TypeFactory.defaultInstance(), BasicPolymorphicTypeValidator
		.builder().build());
}