@Test public void get() throws Exception { String remoteId = "transcribe-remote-id"; String jsonString = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("aws/output/asrOutput.json")); TranscribeConfiguration configuration = new TranscribeConfiguration(); configuration.setWordCountPerItem(20); configuration.setSilentBetweenWords(new BigDecimal("2")); Transcript transcript = new Transcript(); transcript.setTranscriptFileUri("https: TranscriptionJob transcriptionJob = new TranscriptionJob(); transcriptionJob.setTranscriptionJobStatus(TranscriptionJobStatus.COMPLETED.toString()); transcriptionJob.setTranscript(transcript); GetTranscriptionJobResult getTranscriptionJobResult = new GetTranscriptionJobResult(); getTranscriptionJobResult.setTranscriptionJob(transcriptionJob); when(transcribeClient.getTranscriptionJob(any())).thenReturn(getTranscriptionJobResult); when(muleContextManager.send("vm: when(muleMessage.getInboundProperty("getProviderTranscribeException")).thenReturn(null); when(muleMessage.getPayloadAsString()).thenReturn(jsonString); when(transcribeConfigurationPropertiesService.get()).thenReturn(configuration); Transcribe transcribe = awsTranscribeService.get(remoteId); verify(transcribeClient).getTranscriptionJob(any()); verify(muleContextManager).send("vm: verify(muleMessage).getInboundProperty("getProviderTranscribeException"); verify(muleMessage).getPayloadAsString(); verify(transcribeConfigurationPropertiesService, times(346)).get(); assertNotNull(transcribe); assertNotNull(transcribe.getTranscribeItems()); assertEquals(22, transcribe.getTranscribeItems().size()); assertEquals(new BigDecimal("1.390"), transcribe.getTranscribeItems().get(0).getStartTime()); assertEquals(new BigDecimal("7.720"), transcribe.getTranscribeItems().get(0).getEndTime()); assertEquals(98, transcribe.getTranscribeItems().get(0).getConfidence()); assertEquals("I've often said that i wish people could realize all their dreams and wealth fame and so that they could", transcribe.getTranscribeItems().get(0).getText()); assertEquals(new BigDecimal("169.120"), transcribe.getTranscribeItems().get(21).getStartTime()); assertEquals(new BigDecimal("177.730"), transcribe.getTranscribeItems().get(21).getEndTime()); assertEquals(61, transcribe.getTranscribeItems().get(21).getConfidence()); assertEquals("Wait", transcribe.getTranscribeItems().get(21).getText()); assertEquals(configuration.getWordCountPerItem(), transcribe.getTranscribeItems().get(0).getText().split(" ").length); assertEquals(13, transcribe.getTranscribeItems().get(1).getText().split(" ").length); assertEquals(1, transcribe.getTranscribeItems().get(21).getText().split(" ").length); }
@Override public Transcribe get(String remoteId) throws GetTranscribeException { if (StringUtils.isNotEmpty(remoteId)) { try { GetTranscriptionJobRequest request = new GetTranscriptionJobRequest(); request.setTranscriptionJobName(remoteId); GetTranscriptionJobResult result = getTranscribeClient().getTranscriptionJob(request); String resultStatus = result.getTranscriptionJob().getTranscriptionJobStatus(); Transcribe transcribe = new Transcribe(); if (TranscriptionJobStatus.COMPLETED.toString().equals(resultStatus)) { transcribe.setTranscribeItems(generateTranscribeItems(result)); transcribe.setStatus(TranscribeStatusType.COMPLETED.toString()); transcribe.setRemoteId(remoteId); } else { String status = TranscribeStatusType.PROCESSING.toString(); switch (TranscriptionJobStatus.fromValue(resultStatus)) { case IN_PROGRESS: status = TranscribeStatusType.PROCESSING.toString(); break; case FAILED: status = TranscribeStatusType.FAILED.toString(); break; } transcribe.setStatus(status); transcribe.setRemoteId(remoteId); } return transcribe; } catch (MuleException | AmazonServiceException e) { throw new GetTranscribeException(String.format("Unable to get transcribe job on Amazon. REASON=[%s].", e.getMessage()), e); } } throw new GetTranscribeException("Unable to get transcribe job on Amazon. Remote ID not provided."); }
AWSTranscribeService implements TranscribeService, AcmConfigurablePlugin { @Override public Transcribe get(String remoteId) throws GetTranscribeException { if (StringUtils.isNotEmpty(remoteId)) { try { GetTranscriptionJobRequest request = new GetTranscriptionJobRequest(); request.setTranscriptionJobName(remoteId); GetTranscriptionJobResult result = getTranscribeClient().getTranscriptionJob(request); String resultStatus = result.getTranscriptionJob().getTranscriptionJobStatus(); Transcribe transcribe = new Transcribe(); if (TranscriptionJobStatus.COMPLETED.toString().equals(resultStatus)) { transcribe.setTranscribeItems(generateTranscribeItems(result)); transcribe.setStatus(TranscribeStatusType.COMPLETED.toString()); transcribe.setRemoteId(remoteId); } else { String status = TranscribeStatusType.PROCESSING.toString(); switch (TranscriptionJobStatus.fromValue(resultStatus)) { case IN_PROGRESS: status = TranscribeStatusType.PROCESSING.toString(); break; case FAILED: status = TranscribeStatusType.FAILED.toString(); break; } transcribe.setStatus(status); transcribe.setRemoteId(remoteId); } return transcribe; } catch (MuleException | AmazonServiceException e) { throw new GetTranscribeException(String.format("Unable to get transcribe job on Amazon. REASON=[%s].", e.getMessage()), e); } } throw new GetTranscribeException("Unable to get transcribe job on Amazon. Remote ID not provided."); } }
AWSTranscribeService implements TranscribeService, AcmConfigurablePlugin { @Override public Transcribe get(String remoteId) throws GetTranscribeException { if (StringUtils.isNotEmpty(remoteId)) { try { GetTranscriptionJobRequest request = new GetTranscriptionJobRequest(); request.setTranscriptionJobName(remoteId); GetTranscriptionJobResult result = getTranscribeClient().getTranscriptionJob(request); String resultStatus = result.getTranscriptionJob().getTranscriptionJobStatus(); Transcribe transcribe = new Transcribe(); if (TranscriptionJobStatus.COMPLETED.toString().equals(resultStatus)) { transcribe.setTranscribeItems(generateTranscribeItems(result)); transcribe.setStatus(TranscribeStatusType.COMPLETED.toString()); transcribe.setRemoteId(remoteId); } else { String status = TranscribeStatusType.PROCESSING.toString(); switch (TranscriptionJobStatus.fromValue(resultStatus)) { case IN_PROGRESS: status = TranscribeStatusType.PROCESSING.toString(); break; case FAILED: status = TranscribeStatusType.FAILED.toString(); break; } transcribe.setStatus(status); transcribe.setRemoteId(remoteId); } return transcribe; } catch (MuleException | AmazonServiceException e) { throw new GetTranscribeException(String.format("Unable to get transcribe job on Amazon. REASON=[%s].", e.getMessage()), e); } } throw new GetTranscribeException("Unable to get transcribe job on Amazon. Remote ID not provided."); }  }
AWSTranscribeService implements TranscribeService, AcmConfigurablePlugin { @Override public Transcribe get(String remoteId) throws GetTranscribeException { if (StringUtils.isNotEmpty(remoteId)) { try { GetTranscriptionJobRequest request = new GetTranscriptionJobRequest(); request.setTranscriptionJobName(remoteId); GetTranscriptionJobResult result = getTranscribeClient().getTranscriptionJob(request); String resultStatus = result.getTranscriptionJob().getTranscriptionJobStatus(); Transcribe transcribe = new Transcribe(); if (TranscriptionJobStatus.COMPLETED.toString().equals(resultStatus)) { transcribe.setTranscribeItems(generateTranscribeItems(result)); transcribe.setStatus(TranscribeStatusType.COMPLETED.toString()); transcribe.setRemoteId(remoteId); } else { String status = TranscribeStatusType.PROCESSING.toString(); switch (TranscriptionJobStatus.fromValue(resultStatus)) { case IN_PROGRESS: status = TranscribeStatusType.PROCESSING.toString(); break; case FAILED: status = TranscribeStatusType.FAILED.toString(); break; } transcribe.setStatus(status); transcribe.setRemoteId(remoteId); } return transcribe; } catch (MuleException | AmazonServiceException e) { throw new GetTranscribeException(String.format("Unable to get transcribe job on Amazon. REASON=[%s].", e.getMessage()), e); } } throw new GetTranscribeException("Unable to get transcribe job on Amazon. Remote ID not provided."); }  void init(); @Override @Async Transcribe create(Transcribe transcribe); @Override Transcribe get(String remoteId); @Override List<Transcribe> getAll(); @Override List<Transcribe> getAllByStatus(String status); @Override List<Transcribe> getPage(int start, int n); @Override List<Transcribe> getPageByStatus(int start, int n, String status); @Override boolean purge(Transcribe transcribe); AWSTranscribeConfiguration getConfiguration(); AWSTranscribeConfiguration saveConfiguration(AWSTranscribeConfiguration configuration); AmazonS3 getS3Client(); void setS3Client(AmazonS3 s3Client); AmazonTranscribe getTranscribeClient(); void setTranscribeClient(AmazonTranscribe transcribeClient); EcmFileTransaction getEcmFileTransaction(); void setEcmFileTransaction(EcmFileTransaction ecmFileTransaction); AWSTranscribeConfigurationPropertiesService getAwsTranscribeConfigurationPropertiesService(); void setAwsTranscribeConfigurationPropertiesService(
            AWSTranscribeConfigurationPropertiesService awsTranscribeConfigurationPropertiesService); MuleContextManager getMuleContextManager(); void setMuleContextManager(MuleContextManager muleContextManager); TranscribeConfigurationPropertiesService getTranscribeConfigurationPropertiesService(); void setTranscribeConfigurationPropertiesService(
            TranscribeConfigurationPropertiesService transcribeConfigurationPropertiesService); String getCredentialConfigurationFileLocation(); void setCredentialConfigurationFileLocation(String credentialConfigurationFileLocation); TranscribeEventPublisher getTranscribeEventPublisher(); void setTranscribeEventPublisher(TranscribeEventPublisher transcribeEventPublisher); @Override boolean isEnabled(); @Override String getName(); }
AWSTranscribeService implements TranscribeService, AcmConfigurablePlugin { @Override public Transcribe get(String remoteId) throws GetTranscribeException { if (StringUtils.isNotEmpty(remoteId)) { try { GetTranscriptionJobRequest request = new GetTranscriptionJobRequest(); request.setTranscriptionJobName(remoteId); GetTranscriptionJobResult result = getTranscribeClient().getTranscriptionJob(request); String resultStatus = result.getTranscriptionJob().getTranscriptionJobStatus(); Transcribe transcribe = new Transcribe(); if (TranscriptionJobStatus.COMPLETED.toString().equals(resultStatus)) { transcribe.setTranscribeItems(generateTranscribeItems(result)); transcribe.setStatus(TranscribeStatusType.COMPLETED.toString()); transcribe.setRemoteId(remoteId); } else { String status = TranscribeStatusType.PROCESSING.toString(); switch (TranscriptionJobStatus.fromValue(resultStatus)) { case IN_PROGRESS: status = TranscribeStatusType.PROCESSING.toString(); break; case FAILED: status = TranscribeStatusType.FAILED.toString(); break; } transcribe.setStatus(status); transcribe.setRemoteId(remoteId); } return transcribe; } catch (MuleException | AmazonServiceException e) { throw new GetTranscribeException(String.format("Unable to get transcribe job on Amazon. REASON=[%s].", e.getMessage()), e); } } throw new GetTranscribeException("Unable to get transcribe job on Amazon. Remote ID not provided."); }  void init(); @Override @Async Transcribe create(Transcribe transcribe); @Override Transcribe get(String remoteId); @Override List<Transcribe> getAll(); @Override List<Transcribe> getAllByStatus(String status); @Override List<Transcribe> getPage(int start, int n); @Override List<Transcribe> getPageByStatus(int start, int n, String status); @Override boolean purge(Transcribe transcribe); AWSTranscribeConfiguration getConfiguration(); AWSTranscribeConfiguration saveConfiguration(AWSTranscribeConfiguration configuration); AmazonS3 getS3Client(); void setS3Client(AmazonS3 s3Client); AmazonTranscribe getTranscribeClient(); void setTranscribeClient(AmazonTranscribe transcribeClient); EcmFileTransaction getEcmFileTransaction(); void setEcmFileTransaction(EcmFileTransaction ecmFileTransaction); AWSTranscribeConfigurationPropertiesService getAwsTranscribeConfigurationPropertiesService(); void setAwsTranscribeConfigurationPropertiesService(
            AWSTranscribeConfigurationPropertiesService awsTranscribeConfigurationPropertiesService); MuleContextManager getMuleContextManager(); void setMuleContextManager(MuleContextManager muleContextManager); TranscribeConfigurationPropertiesService getTranscribeConfigurationPropertiesService(); void setTranscribeConfigurationPropertiesService(
            TranscribeConfigurationPropertiesService transcribeConfigurationPropertiesService); String getCredentialConfigurationFileLocation(); void setCredentialConfigurationFileLocation(String credentialConfigurationFileLocation); TranscribeEventPublisher getTranscribeEventPublisher(); void setTranscribeEventPublisher(TranscribeEventPublisher transcribeEventPublisher); @Override boolean isEnabled(); @Override String getName();  }