SmartlingResultProcessor { public String processPush(List<SmartlingFile> files, SmartlingOptions options) { return processAction(files, options, "push"); }  String processPush(List<SmartlingFile> files,
                              SmartlingOptions options); String processPushTranslations(List<SmartlingFile> files,
                                          SmartlingOptions options);  }
@Test public void testProcessPush() throws Exception { List<SmartlingFile> files = fileList(5); String requestId = UUID.randomUUID().toString(); SmartlingOptions smartlingOptions = SmartlingOptions.parseList( ImmutableList.of("dry-run=true", "request-id=" + requestId)); processor.processPush(files, smartlingOptions); verify(s3BlobStorage, times(1)).put( nameCaptor.capture(), byteArrayCaptor.capture(), retentionCaptor.capture()); assertThat(nameCaptor.getValue()).contains(requestId); assertThat(nameCaptor.getValue()).contains("_push_"); assertThat(retentionCaptor.getValue()).isEqualTo(Retention.MIN_1_DAY); assertThat(byteArrayCaptor.getValue()).isNotEmpty(); List<SmartlingFile> smartlingFiles = readFilesFromZipBytes(byteArrayCaptor.getValue()); assertThat(smartlingFiles).extracting("fileName", "fileContent") .containsExactlyInAnyOrder( tuple(files.get(0).getFileName(), files.get(0).getFileContent()), tuple(files.get(1).getFileName(), files.get(1).getFileContent()), tuple(files.get(2).getFileName(), files.get(2).getFileContent()), tuple(files.get(3).getFileName(), files.get(3).getFileContent()), tuple(files.get(4).getFileName(), files.get(4).getFileContent())); }
@Test public void testProcessPushThrowsException() { doThrow(new SdkClientException("an exception")).when(s3BlobStorage).put(any(String.class), any(byte[].class), eq(Retention.MIN_1_DAY)); List<SmartlingFile> files = fileList(5); String requestId = UUID.randomUUID().toString(); SmartlingOptions smartlingOptions = SmartlingOptions.parseList( ImmutableList.of("dry-run=true", "request-id=" + requestId)); assertThatThrownBy(() -> processor.processPush(files, smartlingOptions)) .hasMessageContaining("An error ocurred when uploading a push result zip file") .isInstanceOf(RuntimeException.class); }
@Test public void testProcessPushNoBlobStorage() { processor.s3BlobStorage = null; List<SmartlingFile> files = fileList(2); SmartlingOptions smartlingOptions = SmartlingOptions.parseList( ImmutableList.of("dry-run=other", "request-id=test")); processor.processPush(files, smartlingOptions); verifyNoInteractions(s3BlobStorage); }
@Test public void testProcessPushEmptyList() { List<SmartlingFile> files = Collections.emptyList(); SmartlingOptions smartlingOptions = SmartlingOptions.parseList( ImmutableList.of("dry-run=true", "request-id=test")); processor.processPush(files, smartlingOptions); verifyNoInteractions(s3BlobStorage); }
@Test public void testProcessDryRunOff() { List<SmartlingFile> files = fileList(2); SmartlingOptions smartlingOptions = SmartlingOptions.parseList( ImmutableList.of("dry-run=false", "request-id=test")); processor.processPush(files, smartlingOptions); verifyNoInteractions(s3BlobStorage); }