@Test void testBinarySearchChecksBoxesBelowPositiveBetterMatch() { List<Container> containers = new ArrayList<>(); containers.add(new ValidatingContainer("0", 5, 5, 1, 0)); containers.add(new ValidatingContainer("1", 5, 5, 1, 0)); containers.add(new ValidatingContainer("2", 5, 5, 1, 0)); containers.add(new ValidatingContainer("3", 5, 5, 1, 0)); containers.add(new ValidatingContainer("4", 5, 5, 1, 0)); containers.add(new ValidatingContainer("5", 5, 5, 1, 0)); containers.add(new ValidatingContainer("6", 5, 5, 1, 0)); long deadline = System.currentTimeMillis() + 100000; List<BoxItem> products = new ArrayList<>(); products.add(new BoxItem(new Box("1", 5, 5, 1, 0), 1)); Adapter mock = mock(Adapter.class); when(mock.accepted(completeResult)) .thenReturn(new ValidatingContainer("final", 5, 5, 1, 0)); when(mock.attempt(eq(3))).thenReturn(completeResult); when(mock.attempt(eq(1))).thenReturn(incompleteResult); when(mock.attempt(eq(2))).thenReturn(incompleteResult); when(mock.attempt(eq(0))).thenReturn(completeResult); when(mock.hasMore(any(PackResult.class))).thenReturn(false, true, true, false); MyPackager myPackager = new MyPackager(containers, mock); Container pack = myPackager.pack(products, deadline); assertNotNull(pack); assertEquals("final", pack.getName()); verify(mock, times(1)).attempt(eq(3)); verify(mock, times(1)).attempt(eq(2)); verify(mock, times(1)).attempt(eq(1)); verify(mock, times(1)).attempt(eq(0)); }
public Container pack(List<BoxItem> boxes) { return pack(boxes, Long.MAX_VALUE); }
Packager { public Container pack(List<BoxItem> boxes) { return pack(boxes, Long.MAX_VALUE); } }
Packager { public Container pack(List<BoxItem> boxes) { return pack(boxes, Long.MAX_VALUE); } Packager(List<Container> containers);  Packager(List<Container> containers, boolean rotate3D, boolean binarySearch, int checkpointsPerDeadlineCheck); }
Packager { public Container pack(List<BoxItem> boxes) { return pack(boxes, Long.MAX_VALUE); } 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); }
Packager { public Container pack(List<BoxItem> boxes) { return pack(boxes, Long.MAX_VALUE); } 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);  }