Steps to produce:
1. Run Main.java
2. When run, the program abruptly stops and throws out the AssertionFailedError.
Actual Results: Exception occurred and program stopped
Expected Results: Need to show a message stating that no slots are found, etc.
Need to handle this error!
//Case when there are no slots in the ArrayList
@Test
public void testOptimize14() {
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
Item item1 = new Item(1,new Day("13-Oct-2020"),new Day("20-Oct-2020"), 1);
Item item2 = new Item(5,new Day("13-Oct-2020"),new Day("20-Nov-2020"), 2);
Item item3 = new Item(4,new Day("13-Oct-2020"),new Day("25-Oct-2020"), 3);
Item item4 = new Item(1,new Day("13-Oct-2020"),new Day("25-Oct-2020"), 4);
ArrayList<Slot> slots = new ArrayList<>();
Warehouse.createInstance(slots);
Warehouse.getInstance().printItemsInSlots();
//denny addition
ArrayList<Item> items = new ArrayList<>();
items.add(item1);
items.add(item2);
items.add(item3);
//denny addition
Warehouse.getInstance().optimize(items);
assertEquals("Optimizing was done.", outContent.toString().trim().substring(outContent.toString().trim().lastIndexOf('\n')+1));
}
Steps to produce: 1. Run Main.java 2. When run, the program abruptly stops and throws out the AssertionFailedError. Actual Results: Exception occurred and program stopped Expected Results: Need to show a message stating that no slots are found, etc. Need to handle this error! //Case when there are no slots in the ArrayList @Test public void testOptimize14() { ByteArrayOutputStream outContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); Item item1 = new Item(1,new Day("13-Oct-2020"),new Day("20-Oct-2020"), 1); Item item2 = new Item(5,new Day("13-Oct-2020"),new Day("20-Nov-2020"), 2); Item item3 = new Item(4,new Day("13-Oct-2020"),new Day("25-Oct-2020"), 3); Item item4 = new Item(1,new Day("13-Oct-2020"),new Day("25-Oct-2020"), 4); ArrayList<Slot> slots = new ArrayList<>(); Warehouse.createInstance(slots); Warehouse.getInstance().printItemsInSlots(); //denny addition ArrayList<Item> items = new ArrayList<>(); items.add(item1); items.add(item2); items.add(item3); //denny addition Warehouse.getInstance().optimize(items); assertEquals("Optimizing was done.", outContent.toString().trim().substring(outContent.toString().trim().lastIndexOf('\n')+1)); }