Packager { public List<Container> packList(List<BoxItem> boxes, int limit, long deadline) { return packList(boxes, limit, BooleanSupplierBuilder.builder().withDeadline(deadline, checkpointsPerDeadlineCheck).build()); } Packager(List<Container> containers);  Packager(List<Container> containers, boolean rotate3D, boolean binarySearch, int checkpointsPerDeadlineCheck); Container pack(List<BoxItem> boxes); Container pack(List<BoxItem> boxes, long deadline); Container pack(List<BoxItem> boxes, BooleanSupplier interrupt); Container pack(List<BoxItem> boxes, long deadline, BooleanSupplier interrupt); Container pack(List<BoxItem> boxes, List<Container> containers, long deadline); Container pack(List<BoxItem> boxes, List<Container> containers, long deadline, BooleanSupplier interrupt); Container pack(List<BoxItem> boxes, List<Container> containers, BooleanSupplier interrupt); List<Container> packList(List<BoxItem> boxes, int limit, long deadline); List<Container> packList(List<BoxItem> boxes, int limit, long deadline, BooleanSupplier interrupt); List<Container> packList(List<BoxItem> boxes, int limit, BooleanSupplier interrupt);  }
@Test void testLimitIsRespected() { long deadline = System.currentTimeMillis() + 100000; List<Container> containers = new ArrayList<>(); containers.add(new ValidatingContainer("0", 5, 5, 1, 0)); List<BoxItem> products = new ArrayList<>(); products.add(new BoxItem(new Box("1", 5, 5, 1, 0), 1)); products.add(new BoxItem(new Box("2", 5, 5, 1, 0), 1)); products.add(new BoxItem(new Box("3", 5, 5, 1, 0), 1)); Adapter mock = mock(Adapter.class); when(mock.attempt(eq(0))).thenReturn(completeResult); when(mock.hasMore(any(PackResult.class))).thenReturn(true, true, false); MyPackager myPackager = new MyPackager(containers, mock); List<Container> pack = myPackager.packList(products, 2, deadline); assertNull(pack); }