@Test public void create() throws Exception { EcmFile file = new EcmFile(); file.setFileId(103l); EcmFileVersion version = new EcmFileVersion(); version.setId(101l); version.setDurationSeconds(200d); version.setVersionMimeType("video/mp4"); version.setVersionFileNameExtension(".mp4"); version.setFileSizeBytes(1000l); version.setFile(file); Transcribe transcribe = new Transcribe(); transcribe.setId(102l); transcribe.setType(TranscribeType.AUTOMATIC.toString()); transcribe.setRemoteId("remote-id"); transcribe.setMediaEcmFileVersion(version); Map<String, Object> properties = new HashMap<>(); properties.put("aws.bucket", "bucket"); properties.put("aws.region", "region"); properties.put("aws.host", "host"); properties.put("aws.profile", "profile"); when(propertyFileManager.loadMultiple(any(), any())).thenReturn(properties); when(s3Client.doesObjectExist((String) properties.get("aws.bucket"), transcribe.getRemoteId() + transcribe.getMediaEcmFileVersion().getVersionFileNameExtension())).thenReturn(false); when(ecmFileTransaction.downloadFileTransactionAsInputStream(file)).thenReturn(inputStream); when(s3Client.putObject(eq((String) properties.get("aws.bucket")), eq(transcribe.getRemoteId() + transcribe.getMediaEcmFileVersion().getVersionFileNameExtension()), eq(inputStream), any())) .thenReturn(new PutObjectResult()); when(transcribeClient.startTranscriptionJob(any())).thenReturn(new StartTranscriptionJobResult()); awsTranscribeService.create(transcribe); verify(propertyFileManager, times(3)).loadMultiple(any(), any()); verify(s3Client).doesObjectExist((String) properties.get("aws.bucket"), transcribe.getRemoteId() + transcribe.getMediaEcmFileVersion().getVersionFileNameExtension()); verify(ecmFileTransaction).downloadFileTransactionAsInputStream(file); verify(s3Client).putObject(eq((String) properties.get("aws.bucket")), eq(transcribe.getRemoteId() + transcribe.getMediaEcmFileVersion().getVersionFileNameExtension()), eq(inputStream), any()); verify(transcribeClient).startTranscriptionJob(any()); }
@Override @Async public Transcribe create(Transcribe transcribe) throws CreateTranscribeException { AWSTranscribeConfiguration configuration = null; try { configuration = getConfiguration(); } catch (GetConfigurationException e) { getTranscribeEventPublisher().publish(transcribe, TranscribeActionType.PROVIDER_FAILED.toString()); throw new CreateTranscribeException(String.format("Transcribe failed to create on Amazon. REASON=[%s]", e.getMessage()), e); } checkIfMediaExist(transcribe, configuration.getBucket()); uploadMedia(transcribe); startTranscribeJob(transcribe); return transcribe; }
AWSTranscribeService implements TranscribeService, AcmConfigurablePlugin { @Override @Async public Transcribe create(Transcribe transcribe) throws CreateTranscribeException { AWSTranscribeConfiguration configuration = null; try { configuration = getConfiguration(); } catch (GetConfigurationException e) { getTranscribeEventPublisher().publish(transcribe, TranscribeActionType.PROVIDER_FAILED.toString()); throw new CreateTranscribeException(String.format("Transcribe failed to create on Amazon. REASON=[%s]", e.getMessage()), e); } checkIfMediaExist(transcribe, configuration.getBucket()); uploadMedia(transcribe); startTranscribeJob(transcribe); return transcribe; } }
AWSTranscribeService implements TranscribeService, AcmConfigurablePlugin { @Override @Async public Transcribe create(Transcribe transcribe) throws CreateTranscribeException { AWSTranscribeConfiguration configuration = null; try { configuration = getConfiguration(); } catch (GetConfigurationException e) { getTranscribeEventPublisher().publish(transcribe, TranscribeActionType.PROVIDER_FAILED.toString()); throw new CreateTranscribeException(String.format("Transcribe failed to create on Amazon. REASON=[%s]", e.getMessage()), e); } checkIfMediaExist(transcribe, configuration.getBucket()); uploadMedia(transcribe); startTranscribeJob(transcribe); return transcribe; }  }
AWSTranscribeService implements TranscribeService, AcmConfigurablePlugin { @Override @Async public Transcribe create(Transcribe transcribe) throws CreateTranscribeException { AWSTranscribeConfiguration configuration = null; try { configuration = getConfiguration(); } catch (GetConfigurationException e) { getTranscribeEventPublisher().publish(transcribe, TranscribeActionType.PROVIDER_FAILED.toString()); throw new CreateTranscribeException(String.format("Transcribe failed to create on Amazon. REASON=[%s]", e.getMessage()), e); } checkIfMediaExist(transcribe, configuration.getBucket()); uploadMedia(transcribe); startTranscribeJob(transcribe); return transcribe; }  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 @Async public Transcribe create(Transcribe transcribe) throws CreateTranscribeException { AWSTranscribeConfiguration configuration = null; try { configuration = getConfiguration(); } catch (GetConfigurationException e) { getTranscribeEventPublisher().publish(transcribe, TranscribeActionType.PROVIDER_FAILED.toString()); throw new CreateTranscribeException(String.format("Transcribe failed to create on Amazon. REASON=[%s]", e.getMessage()), e); } checkIfMediaExist(transcribe, configuration.getBucket()); uploadMedia(transcribe); startTranscribeJob(transcribe); return transcribe; }  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();  }