@Test public void shouldRefuseDeleteCommands() { S3ObjectSummary mockS3ObjectSummary = mock(S3ObjectSummary.class); when(mockUploadConfiguration.getBucketName()).thenReturn("bucket"); when(mockS3Scanner.listObjects("bucket")).thenReturn(asList(mockS3ObjectSummary)); when(mockUploadConfiguration.isClearBucketBeforeUpload()).thenReturn(false); s3Processor.clearBucket(mockUploadConfiguration); verifyNoMoreInteractions(mockQueue); }
@Test public void shouldAcceptDeleteCommands() { UploadConfiguration mockUploadConfiguration = mock(UploadConfiguration.class); S3ObjectSummary mockS3ObjectSummary = mock(S3ObjectSummary.class); when(mockUploadConfiguration.getBucketName()).thenReturn("bucket"); when(mockS3Scanner.listObjects("bucket")).thenReturn(asList(mockS3ObjectSummary)); when(mockUploadConfiguration.isClearBucketBeforeUpload()).thenReturn(true); s3Processor.clearBucket(mockUploadConfiguration); verify(mockQueue).add(new DeleteUnit(mockS3ObjectSummary)); }
@Test public void shouldAcceptUploadCommands() { Date mockDate = mock(Date.class); UploadUnit mockUploadUnit = mock(UploadUnit.class); File mockFile = mock(File.class); File mockDirectory = mock(File.class); when(mockDirectoryScanner.scanRegularFiles(mockDirectory)).thenReturn(asList(mockFile)); when(mockUploadConfiguration.getBaseDirectory()).thenReturn(mockDirectory); when(mockUploadConfiguration.uploadUnitFor(mockFile, mockDate)).thenReturn(mockUploadUnit); s3Processor.uploadBucket(mockUploadConfiguration, mockDate); verify(mockQueue).add(mockUploadUnit); }