@Test public void test_that_a_signalfx_signal_flow_response_can_be_parsed() throws Exception { InputStream response = getClass().getClassLoader().getResourceAsStream("signalfx-signalflow-response.text"); SignalFxConverter converter = new SignalFxConverter(); TypedInput typedInput = new TypedByteArray("text/plain", ByteStreams.toByteArray(response)); SignalFlowExecutionResult signalFlowExecutionResult = (SignalFlowExecutionResult) converter.fromBody(typedInput, SignalFlowExecutionResult.class); assertNotNull(signalFlowExecutionResult); assertThat("The signalFlowExecutionResult contains the channel messages", signalFlowExecutionResult.getChannelMessages().size(), greaterThan(1)); } }
@Override public Object fromBody(TypedInput body, Type type) throws ConversionException { if (!CONVERTIBLE_TYPES.contains(type)) { throw new ConversionException( String.format("The SignalFxConverter Retrofit converter can only handle Types: [ %s ], received: %s", CONVERTIBLE_TYPES.stream().map(Type::getTypeName).collect(Collectors.joining(", ")), type.getTypeName())); } if (type.getTypeName().equals(SignalFlowExecutionResult.class.getTypeName())) { return getSignalFlowExecutionResultFromBody(body); } else { return getErrorResponseFromBody(body); } }
accountCredentialsBuilder.signalFlowService(retrofitClientFactory.createClient( SignalFxSignalFlowRemoteService.class, new SignalFxConverter(), signalFxSignalFlowEndpoint, okHttpClient
accountCredentialsBuilder.signalFlowService(retrofitClientFactory.createClient( SignalFxSignalFlowRemoteService.class, new SignalFxConverter(), signalFxSignalFlowEndpoint, okHttpClient
@Override public Object fromBody(TypedInput body, Type type) throws ConversionException { if (!CONVERTIBLE_TYPES.contains(type)) { throw new ConversionException( String.format("The SignalFxConverter Retrofit converter can only handle Types: [ %s ], received: %s", CONVERTIBLE_TYPES.stream().map(Type::getTypeName).collect(Collectors.joining(", ")), type.getTypeName())); } if (type.getTypeName().equals(SignalFlowExecutionResult.class.getTypeName())) { return getSignalFlowExecutionResultFromBody(body); } else { return getErrorResponseFromBody(body); } }