@Test public void testSizeShouldBeZeroWhenStartIsMoreThanSize() throws Exception { final long size = 100; PartialFetchBodyElement element = new PartialFetchBodyElement(mockBodyElement, 1000, NUMBER_OF_OCTETS); when(mockBodyElement.size()).thenReturn(size); assertThat(element.size()).describedAs("Size is less than number of octets so should be size").isEqualTo(0); }
@Override public long size() throws IOException { final long size = delegate.size(); final long lastOctet = this.numberOfOctets + firstOctet; if (firstOctet > size) { return 0; } else if (size > lastOctet) { return numberOfOctets; } else { return size - firstOctet; } }
PartialFetchBodyElement implements BodyElement { @Override public long size() throws IOException { final long size = delegate.size(); final long lastOctet = this.numberOfOctets + firstOctet; if (firstOctet > size) { return 0; } else if (size > lastOctet) { return numberOfOctets; } else { return size - firstOctet; } } }
PartialFetchBodyElement implements BodyElement { @Override public long size() throws IOException { final long size = delegate.size(); final long lastOctet = this.numberOfOctets + firstOctet; if (firstOctet > size) { return 0; } else if (size > lastOctet) { return numberOfOctets; } else { return size - firstOctet; } } PartialFetchBodyElement(BodyElement delegate, long firstOctet, long numberOfOctets); }
PartialFetchBodyElement implements BodyElement { @Override public long size() throws IOException { final long size = delegate.size(); final long lastOctet = this.numberOfOctets + firstOctet; if (firstOctet > size) { return 0; } else if (size > lastOctet) { return numberOfOctets; } else { return size - firstOctet; } } PartialFetchBodyElement(BodyElement delegate, long firstOctet, long numberOfOctets); @Override String getName(); @Override long size(); @Override InputStream getInputStream(); }
PartialFetchBodyElement implements BodyElement { @Override public long size() throws IOException { final long size = delegate.size(); final long lastOctet = this.numberOfOctets + firstOctet; if (firstOctet > size) { return 0; } else if (size > lastOctet) { return numberOfOctets; } else { return size - firstOctet; } } PartialFetchBodyElement(BodyElement delegate, long firstOctet, long numberOfOctets); @Override String getName(); @Override long size(); @Override InputStream getInputStream();  }