### Question:
FileSystemRepository implements ContentRepository { @Override public long size(final ContentClaim claim) throws IOException { if (claim == null) { return 0L; } if (claim.getLength() < 0) { return Files.size(getPath(claim, true)) - claim.getOffset(); } return claim.getLength(); } FileSystemRepository();  FileSystemRepository(final NiFiProperties nifiProperties); @Override void initialize(final ResourceClaimManager claimManager); @Override void shutdown(); @Override Set<String> getContainerNames(); @Override long getContainerCapacity(final String containerName); @Override long getContainerUsableSpace(String containerName); @Override void cleanup(); @Override ContentClaim create(final boolean lossTolerant); @Override int incrementClaimaintCount(final ContentClaim claim); @Override int getClaimantCount(final ContentClaim claim); @Override int decrementClaimantCount(final ContentClaim claim); @Override boolean remove(final ContentClaim claim); @Override ContentClaim clone(final ContentClaim original, final boolean lossTolerant); @Override long merge(final Collection<ContentClaim> claims, final ContentClaim destination, final byte[] header, final byte[] footer, final byte[] demarcator); @Override long importFrom(final Path content, final ContentClaim claim); @Override long importFrom(final InputStream content, final ContentClaim claim); @Override long exportTo(final ContentClaim claim, final Path destination, final boolean append); @Override long exportTo(final ContentClaim claim, final Path destination, final boolean append, final long offset, final long length); @Override long exportTo(final ContentClaim claim, final OutputStream destination); @Override long exportTo(final ContentClaim claim, final OutputStream destination, final long offset, final long length); @Override long size(final ContentClaim claim); @Override InputStream read(final ContentClaim claim); @Override OutputStream write(final ContentClaim claim); @Override void purge(); static Path getArchivePath(final Path contentClaimPath); @Override boolean isAccessible(final ContentClaim contentClaim); static final int SECTIONS_PER_CONTAINER; static final long MIN_CLEANUP_INTERVAL_MILLIS; static final String ARCHIVE_DIR_NAME; static final Pattern MAX_ARCHIVE_SIZE_PATTERN; }### Answer:
@Test public void testSize() throws IOException { final ContentClaim claim = repository.create(true); final Path path = getPath(claim); Files.createDirectories(path.getParent()); final byte[] data = "The quick brown fox jumps over the lazy dog".getBytes(); try (final OutputStream out = Files.newOutputStream(path, StandardOpenOption.WRITE, StandardOpenOption.CREATE)) { out.write(data); } assertEquals(data.length, repository.size(claim)); }
@Test(expected = ContentNotFoundException.class) public void testSizeWithNoContent() throws IOException { final ContentClaim claim = new StandardContentClaim(new StandardResourceClaim(claimManager, "container1", "section 1", "1", false), 0L); assertEquals(0L, repository.size(claim)); }