### Question:
B2PartSizes implements B2FilePolicy { List<B2PartSpec> pickParts(long contentLength) { B2Preconditions.checkArgument(couldBeLargeFile(contentLength), "contentLength=" + contentLength + " is too small to make at least two parts. minimumPartSize=" + minimumPartSize); final int partCount; final long partSize; final long lastPartSize; if (contentLength < 2 * minimumPartSize) { partCount = 2; partSize = minimumPartSize; lastPartSize = contentLength - minimumPartSize; } else if (contentLength < 2 * recommendedPartSize) { partCount = 2; partSize = (contentLength+1) / partCount; lastPartSize = contentLength - partSize; } else { partCount = Math.min(B2StorageLimits.MAX_PARTS_PER_LARGE_FILE, (int) (contentLength / recommendedPartSize)); partSize = contentLength / partCount; lastPartSize = contentLength - ((partCount-1) * partSize); B2Preconditions.checkState(lastPartSize >= partSize); } B2Preconditions.checkState(partCount >= 2); B2Preconditions.checkState(partSize >= minimumPartSize); B2Preconditions.checkState(lastPartSize >= 1); final List<B2PartSpec> parts = new ArrayList<>(); for (int i=0; i < (partCount-1); i++) { parts.add(new B2PartSpec(i+1, i*partSize, partSize)); } parts.add(new B2PartSpec(partCount, contentLength-lastPartSize, lastPartSize)); return parts; } private  B2PartSizes(long minimumPartSize,
                long recommendedPartSize); @Override boolean mustBeLargeFile(long contentLength); @Override boolean couldBeLargeFile(long contentLength); @Override boolean shouldBeLargeFile(long contentLength);  }### Answer:
@Test public void testPickParts_tooSmall() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("contentLength=100 is too small to make at least two parts. minimumPartSize=100"); partSizes.pickParts(minSize); }
@Test public void testPickParts_barelyBigEnough() { final List<B2PartSpec> specs = partSizes.pickParts(minSize + 1); checkSpecs(specs, new B2PartSpec(1, 0, minSize), new B2PartSpec(2, minSize, 1) ); }
@Test public void testPickParts_notBigEnoughToUseRecommendedSize() { final List<B2PartSpec> specs = partSizes.pickParts((2 * recSize) - 1); checkSpecs(specs, new B2PartSpec(1, 0, recSize), new B2PartSpec(2, recSize, recSize-1) ); }
@Test public void testPickParts_barelyBigEnoughToUseRecommendedSize() { final List<B2PartSpec> specs = partSizes.pickParts(2 * recSize); checkSpecs(specs, new B2PartSpec(1, 0, recSize), new B2PartSpec(2, recSize, recSize) ); }
@Test public void testPickParts_bigEnoughToUseRecommendedSize() { final List<B2PartSpec> specs = partSizes.pickParts(3 * recSize + (recSize-2)); checkSpecs(specs, new B2PartSpec(1, 0, 1332), new B2PartSpec(2, 1332, 1332), new B2PartSpec(3, 2664, 1334) ); }