### Question:
S3FileList { public List<String> getFiles(AmazonS3 s3Client) throws AdapterException { final List<S3ObjectSummary> objectSummaries = reportFilesInBillingBucket(s3Client); return awsJobEnabled ? lastFilesPerBillingPeriod(objectSummaries) : objectSummaries.stream().map(S3ObjectSummary::getKey).sorted().collect(toList()); } S3FileList(boolean awsJobEnabled, String bucket, ModuleData moduleData); List<String> getFiles(AmazonS3 s3Client);  }### Answer:
@Test public void sort() throws AdapterException { final AmazonS3Client s3Client = mock(AmazonS3Client.class); final ListObjectsV2Result result = mock(ListObjectsV2Result.class); final ModuleData moduleData = mock(ModuleData.class); final String[] array = { "report-prefix/report/20160101-20160131/123456789/report-1.csv", "report-prefix/report/20160101-20160131/123456789/report-2.csv", "report-prefix/report/20160101-20160131/123456789/report-3.csv", "report-prefix/report/20160202-20160231/123456789/report.csv", "report-prefix/report/20160202-20160301/123456789/report.csv", "report-prefix/report/20160303-20160301/123456789/report-1.csv", "report-prefix/report/20160303-20160301/123456789/report-2.csv", "report-prefix/report/20160303-20160302/123456789/report-1.csv", "report-prefix/report/20160303-20160302/123456789/report-2.csv" }; final List<S3ObjectSummary> objectSummaries = Arrays.asList( getObjectSummary(array[0], LocalDate.of(2018, 4, 4)), getObjectSummary(array[4], LocalDate.of(2018, 4, 4)), getObjectSummary(array[1], LocalDate.of(2018, 4, 4)), getObjectSummary(array[2], LocalDate.of(2018, 4, 4)), getObjectSummary(array[3], LocalDate.of(2018, 4, 4)), getObjectSummary(array[5], LocalDate.of(2018, 4, 4)), getObjectSummary(array[6], LocalDate.of(2018, 4, 4)), getObjectSummary(array[7], LocalDate.of(2018, 4, 4)), getObjectSummary(array[8], LocalDate.of(2018, 4, 4)) ); when(s3Client.listObjectsV2(any(ListObjectsV2Request.class))).thenReturn(result); when(result.getObjectSummaries()).thenReturn(objectSummaries); when(moduleData.wasProcessed(any(),any(), anyString())).thenReturn(false); S3FileList s3list = new S3FileList(false, "test", moduleData); final List<String> list = s3list.getFiles(s3Client); assertEquals(array.length, list.size()); for (int i = 0; i < array.length; i++) { assertEquals(array[i], list.get(i)); } }