S3BinaryStore extends AbstractBinaryStore { @Override public void markAsUsed(Iterable<BinaryKey> keys) throws BinaryStoreException { for (BinaryKey key : keys) { setS3ObjectTag(key.toString(), UNUSED_TAG_KEY, String.valueOf(false)); } } S3BinaryStore(String accessKey, String secretKey, String bucketName);  S3BinaryStore(String accessKey, String secretKey, String bucketName, String endPoint);  S3BinaryStore( String accessKey,
                          String secretKey,
                          String bucketName,
                          String endPoint,
                          Boolean deleteUnusedNatively ); protected  S3BinaryStore(String bucketName, AmazonS3 s3Client, boolean deleteUnusedNatively); @Override void storeExtractedText(BinaryValue binaryValue, String extractedText); @Override String getExtractedText(BinaryValue binaryValue); @Override BinaryValue storeValue(InputStream stream, boolean markAsUnused); @Override InputStream getInputStream(BinaryKey key); @Override void markAsUsed(Iterable<BinaryKey> keys); @Override void markAsUnused(Iterable<BinaryKey> keys); @Override void removeValuesUnusedLongerThan(long minimumAge, TimeUnit timeUnit); @Override Iterable<BinaryKey> getAllBinaryKeys(); void migrateUnusedMetadataToTags();  }
@Test public void testMarkAsUsed() throws BinaryStoreException { Capture<GetObjectTaggingRequest> getTaggingRequestCapture = Capture.newInstance(); GetObjectTaggingResult getTaggingResult = new GetObjectTaggingResult(new ArrayList<>()); getTaggingResult.getTagSet().add(new Tag(S3BinaryStore.UNUSED_TAG_KEY, String.valueOf(true))); expect(s3Client.getObjectTagging(capture(getTaggingRequestCapture))) .andReturn(getTaggingResult); Capture<SetObjectTaggingRequest> setTaggingRequestCapture = Capture.newInstance(); expect(s3Client.setObjectTagging(capture(setTaggingRequestCapture))) .andReturn(new SetObjectTaggingResult()); replayAll(); s3BinaryStore.markAsUsed(Collections.singleton(new BinaryKey(TEST_KEY))); SetObjectTaggingRequest setTaggingRequest = setTaggingRequestCapture.getValue(); assertUnusedTagInSetTaggingRequest(setTaggingRequest, String.valueOf(false)); }
@Test public void testMarkAsUsedNoChangeNeeded() throws BinaryStoreException { Capture<GetObjectTaggingRequest> getTaggingRequestCapture = Capture.newInstance(); GetObjectTaggingResult getTaggingResult = new GetObjectTaggingResult(new ArrayList<>()); getTaggingResult.getTagSet().add(new Tag(S3BinaryStore.UNUSED_TAG_KEY, String.valueOf(false))); expect(s3Client.getObjectTagging(capture(getTaggingRequestCapture))) .andReturn(getTaggingResult); replayAll(); s3BinaryStore.markAsUsed(Collections.singleton(new BinaryKey(TEST_KEY))); }