@Test public void formatErrorResponseShouldWork() { String expectedMethodCallId = "#1"; ObjectNode parameters = new ObjectNode(new JsonNodeFactory(false)); parameters.put("id", "myId"); JsonNode[] nodes = new JsonNode[]{new ObjectNode(new JsonNodeFactory(false)).textNode("unknwonMethod"), parameters, new ObjectNode(new JsonNodeFactory(false)).textNode(expectedMethodCallId)}; List<InvocationResponse> response = testee.formatMethodResponse( Flux.just(JmapResponse .builder() .methodCallId(InvocationRequest.deserialize(nodes).getMethodCallId()) .error() .build())) .collectList() .block(); assertThat(response).hasSize(1) .extracting(InvocationResponse::getResponseName, x -> x.getResults().get("type").asText(), InvocationResponse::getMethodCallId) .containsExactly(tuple(ErrorResponse.ERROR_METHOD, ErrorResponse.DEFAULT_ERROR_MESSAGE, MethodCallId.of(expectedMethodCallId))); }
@Override public Flux<InvocationResponse> formatMethodResponse(Flux<JmapResponse> jmapResponses) { return jmapResponses.map(jmapResponse -> { ObjectMapper objectMapper = newConfiguredObjectMapper(jmapResponse); return new InvocationResponse( jmapResponse.getResponseName(), objectMapper.valueToTree(jmapResponse.getResponse()), jmapResponse.getMethodCallId()); }); }
JmapResponseWriterImpl implements JmapResponseWriter { @Override public Flux<InvocationResponse> formatMethodResponse(Flux<JmapResponse> jmapResponses) { return jmapResponses.map(jmapResponse -> { ObjectMapper objectMapper = newConfiguredObjectMapper(jmapResponse); return new InvocationResponse( jmapResponse.getResponseName(), objectMapper.valueToTree(jmapResponse.getResponse()), jmapResponse.getMethodCallId()); }); } }
JmapResponseWriterImpl implements JmapResponseWriter { @Override public Flux<InvocationResponse> formatMethodResponse(Flux<JmapResponse> jmapResponses) { return jmapResponses.map(jmapResponse -> { ObjectMapper objectMapper = newConfiguredObjectMapper(jmapResponse); return new InvocationResponse( jmapResponse.getResponseName(), objectMapper.valueToTree(jmapResponse.getResponse()), jmapResponse.getMethodCallId()); }); } @Inject  JmapResponseWriterImpl(ObjectMapperFactory objectMapperFactory); }
JmapResponseWriterImpl implements JmapResponseWriter { @Override public Flux<InvocationResponse> formatMethodResponse(Flux<JmapResponse> jmapResponses) { return jmapResponses.map(jmapResponse -> { ObjectMapper objectMapper = newConfiguredObjectMapper(jmapResponse); return new InvocationResponse( jmapResponse.getResponseName(), objectMapper.valueToTree(jmapResponse.getResponse()), jmapResponse.getMethodCallId()); }); } @Inject  JmapResponseWriterImpl(ObjectMapperFactory objectMapperFactory); @Override Flux<InvocationResponse> formatMethodResponse(Flux<JmapResponse> jmapResponses); }
JmapResponseWriterImpl implements JmapResponseWriter { @Override public Flux<InvocationResponse> formatMethodResponse(Flux<JmapResponse> jmapResponses) { return jmapResponses.map(jmapResponse -> { ObjectMapper objectMapper = newConfiguredObjectMapper(jmapResponse); return new InvocationResponse( jmapResponse.getResponseName(), objectMapper.valueToTree(jmapResponse.getResponse()), jmapResponse.getMethodCallId()); }); } @Inject  JmapResponseWriterImpl(ObjectMapperFactory objectMapperFactory); @Override Flux<InvocationResponse> formatMethodResponse(Flux<JmapResponse> jmapResponses); static final String PROPERTIES_FILTER; }