### Question:
FilesystemBinaryStorageSvcImpl extends BaseBinaryStorageSvcImpl { @Override public StoredDetails storeBlob(IIdType theResourceId, String theBlobIdOrNull, String theContentType, InputStream theInputStream) throws IOException { String id = super.provideIdForNewBlob(theBlobIdOrNull); File storagePath = getStoragePath(id, true); File storageFilename = getStorageFilename(storagePath, theResourceId, id); ourLog.info("Writing to file: {}", storageFilename.getAbsolutePath()); CountingInputStream countingInputStream = createCountingInputStream(theInputStream); HashingInputStream hashingInputStream = createHashingInputStream(countingInputStream); try (FileOutputStream outputStream = new FileOutputStream(storageFilename)) { IOUtils.copy(hashingInputStream, outputStream); } long count = countingInputStream.getCount(); StoredDetails details = new StoredDetails(id, count, theContentType, hashingInputStream, new Date()); File descriptorFilename = getDescriptorFilename(storagePath, theResourceId, id); ourLog.info("Writing to file: {}", descriptorFilename.getAbsolutePath()); try (FileWriter writer = new FileWriter(descriptorFilename)) { myJsonSerializer.writeValue(writer, details); } ourLog.info("Stored binary blob with {} bytes and ContentType {} for resource {}", count, theContentType, theResourceId); return details; } FilesystemBinaryStorageSvcImpl(String theBasePath); @PostConstruct void start(); @Override StoredDetails storeBlob(IIdType theResourceId, String theBlobIdOrNull, String theContentType, InputStream theInputStream); @Override StoredDetails fetchBlobDetails(IIdType theResourceId, String theBlobId); @Override boolean writeBlob(IIdType theResourceId, String theBlobId, OutputStream theOutputStream); @Override void expungeBlob(IIdType theResourceId, String theBlobId); @Override byte[] fetchBlob(IIdType theResourceId, String theBlobId);  }### Answer:
@Test public void testRejectOversized() throws IOException { mySvc.setMinimumBinarySize(0); mySvc.setMaximumBinarySize(5); IIdType id = new IdType("Patient/123"); String contentType = "image/png"; try { mySvc.storeBlob(id, null, contentType, new ByteArrayInputStream(SOME_BYTES)); fail(); } catch (PayloadTooLargeException e) { assertEquals("Binary size exceeds maximum: 5", e.getMessage()); } }