Bug 419 (Handled) - Exception Not Handled(IndexOutOfBoundsException) WMS V1
Summary: Exception Not Handled(IndexOutOfBoundsException) WMS V1
Status: CONFIRMED
Alias: Handled
Product: Warehouse Management System
Classification: Unclassified
Component: Testing (show other bugs)
Version: Specified
Hardware: PC Windows
: High major
Assignee: ANIRUDH
URL:
Depends on:
Blocks:
 
Reported: 2020-11-19 01:38 HKT by ANIRUDH
Modified: 2020-11-19 01:49 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ANIRUDH 2020-11-19 01:38:37 HKT
Note: Input given in the test case function in Version 1 of the system

Steps to reproduce:
Give the input for the list of items:
Item 1: 1
Item 2: 2
Item 3: 3

Added a couple of slots with the sizes of 5 and 1 respectively.

Below is the test case which threw error:

@Test
public void testOptimize5() {
	
	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(2,new Day("13-Oct-2020"),new Day("20-Nov-2020"), 2);
	Item item3 = new Item(3,new Day("13-Oct-2020"),new Day("25-Oct-2020"), 3);
	
	ArrayList<Slot> slots = new ArrayList<>();
	slots.add(new Slot(5));
	slots.add(new Slot(1));
	
	slots.get(0).addItem(item1);
	slots.get(1).addItem(item2);
	slots.get(2).addItem(item3); //Threw an exception at this line
	
	
	Warehouse.createInstance(slots);
	Warehouse.getInstance().printItemsInSlots();
	
	//addition
	ArrayList<Item> items = new ArrayList<>();
	items.add(item1);
	items.add(item2);
	items.add(item3);
	
	//addition
	Warehouse.getInstance().optimize(items);
    
	assertEquals("Optimizing was done.", outContent.toString().trim().substring(outContent.toString().trim().lastIndexOf('\n')+1));
	
}

When items are added to the slots for checking whether the system can optimize or not, an exception was thrown.

Actual Output: IndexOutOfBoundsException
Expected Output: Optimizing was done
Comment 1 ANIRUDH 2020-11-19 01:49:32 HKT
When an item was added to an extra slot which is not created/present, exception was thrown.