Steps to reproduce: 1. Initialize the warehouse 2. Add slots to the instance 3. Fill all slots of the warehouse to make it full 4. Add extra items to the queue with the same date as items in step 3 5. Set a new date so that all items in the warehouse and a queue should exit In the current test case: there is an item in the warehouse with size 3 and delivery date 26-Oct-2020 as well as an item with the same size and delivery date in the queue. When I set a date to 27-Oct-2020, the warehouse should be empty, so that I can add a new slot with size 3. However, this item is added to the queue, because the previous item in the queue was added to the warehouse but it should be delivered due to its delivery date. @Test void testCmdAddItemFromQueue_03() { ByteArrayOutputStream outContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); String cmdLine = "startNewDate|27-Oct-2020"; String [] cmdParts = cmdLine.split("\\|"); (new CmdSetDate()).execute(cmdParts); (new CmdDeliverExpiredItem()).execute(cmdParts); (new CmdAddItemFromQueue()).execute(cmdParts); String cmdLine3 = "addItem|3|2-Nov-2020"; String [] cmdParts3 = cmdLine3.split("\\|"); (new CmdAddItem()).execute(cmdParts3); String msg = "Checking when there is no slot in the warehouse yet"; assertEquals("Item #9 with size(3) is added in Slot ID #3 ; Delivery Date: 2-Nov-2020", outContent.toString().trim().substring(outContent.toString().trim().lastIndexOf('\n')+1), msg); }