| Summary: | Need to handle the exception when slot value=null | ||
|---|---|---|---|
| Product: | Warehouse Management System | Reporter: | ANIRUDH <pvsatavva2-c> |
| Component: | Testing V1 | Assignee: | ANIRUDH <pvsatavva2-c> |
| Status: | CONFIRMED --- | ||
| Severity: | major | ||
| Priority: | --- | ||
| Version: | Specified | ||
| Hardware: | PC | ||
| OS: | Windows | ||
Steps to produce: 1. Run Main.java 2. When run, the program abruptly stops and throws out the NullPointerException. Actual Results: Exception occurred and program stopped Expected Results: Need to show the exception that occurred //Case when the Arraylist of slots is null @Test public void testOptimize13() { 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 = null; //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("NullPointerException Occured", outContent.toString().trim().substring(outContent.toString().trim().lastIndexOf('\n')+1)); }