private void translateText(TranslateClient translateClient, Exchange exchange) throws InvalidPayloadException {
        if (getConfiguration().isPojoRequest()) {
            Object payload = exchange.getIn().getMandatoryBody();
            if (payload instanceof TranslateTextRequest) {
                TranslateTextResponse result;
                try {
                    result = translateClient.translateText((TranslateTextRequest) payload);
                } catch (AwsServiceException ase) {
                    LOG.trace("Translate Text command returned the error code {}", ase.awsErrorDetails().errorCode());
                    throw ase;
                }
                Message message = getMessageForResponse(exchange);
                message.setBody(result.translatedText());
            }
        } else {
            Builder request = TranslateTextRequest.builder();
            if (!getConfiguration().isAutodetectSourceLanguage()) {
                if (ObjectHelper.isEmpty(getConfiguration().getSourceLanguage())
                        && ObjectHelper.isEmpty(getConfiguration().getTargetLanguage())) {
                    String source = exchange.getIn().getHeader(Translate2Constants.SOURCE_LANGUAGE, String.class);
                    String target = exchange.getIn().getHeader(Translate2Constants.TARGET_LANGUAGE, String.class);
                    if (ObjectHelper.isEmpty(source) || ObjectHelper.isEmpty(target)) {
                        throw new IllegalArgumentException(
                                "Source and target language must be specified as headers or endpoint options");
                    }
                    request.sourceLanguageCode(source);
                    request.targetLanguageCode(target);
                } else {
                    request.sourceLanguageCode(getConfiguration().getSourceLanguage());
                    request.targetLanguageCode(getConfiguration().getTargetLanguage());
                }
            } else {
                String source = "auto";
                if (ObjectHelper.isEmpty(getConfiguration().getTargetLanguage())) {
                    String target = exchange.getIn().getHeader(Translate2Constants.TARGET_LANGUAGE, String.class);
                    if (ObjectHelper.isEmpty(source) || ObjectHelper.isEmpty(target)) {
                        throw new IllegalArgumentException(
                                "Target language must be specified when autodetection of source language is enabled");
                    }
                    request.sourceLanguageCode(source);
                    request.targetLanguageCode(target);
                } else {
                    request.sourceLanguageCode(source);
                    request.targetLanguageCode(getConfiguration().getTargetLanguage());
                }
            }
            if (!ObjectHelper.isEmpty(exchange.getIn().getHeader(Translate2Constants.TERMINOLOGY_NAMES, Collection.class))) {
                Collection<String> terminologies
                        = exchange.getIn().getHeader(Translate2Constants.TERMINOLOGY_NAMES, Collection.class);
                request.terminologyNames(terminologies);
            }
            request.text(exchange.getMessage().getBody(String.class));
            TranslateTextResponse result;
            try {
                result = translateClient.translateText(request.build());
            } catch (AwsServiceException ase) {
                LOG.trace("Translate Text command returned the error code {}", ase.awsErrorDetails().errorCode());
                throw ase;
            }
            Message message = getMessageForResponse(exchange);
            message.setBody(result.translatedText());
        }
    }
@Test
    public void translateTextTest() throws Exception {

        mock.expectedMessageCount(1);
        Exchange exchange = template.request("direct:translateText", new Processor() {
            @Override
            public void process(Exchange exchange) {
                exchange.getIn().setHeader(Translate2Constants.SOURCE_LANGUAGE, Translate2LanguageEnum.ITALIAN);
                exchange.getIn().setHeader(Translate2Constants.TARGET_LANGUAGE, Translate2LanguageEnum.ENGLISH);
                exchange.getIn().setBody("ciao");
            }
        });

        MockEndpoint.assertIsSatisfied(context);

        String resultGet = exchange.getIn().getBody(String.class);
        assertEquals("Hello", resultGet);

    }