Bug 421 - Need to handle the negative slot values
Summary: Need to handle the negative slot values
Status: CONFIRMED
Alias: None
Product: Warehouse Management System
Classification: Unclassified
Component: Testing V1 (show other bugs)
Version: Specified
Hardware: PC Windows
: --- major
Assignee: ANIRUDH
URL:
Depends on:
Blocks:
 
Reported: 2020-11-19 02:49 HKT by ANIRUDH
Modified: 2020-11-19 02: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 02:49:24 HKT
Steps to produce: 
1. Run Main.java
2. When run, the program abruptly stops and throws out the IndexOutOfBoundsException.

Actual Results: Exception occurred and program stopped
Expected Results: Need to show the exception that occured

@Test
public void testOptimize9() {
	
	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(9,new Day("13-Oct-2020"),new Day("20-Nov-2020"), 2);
	Item item3 = new Item(2,new Day("13-Oct-2020"),new Day("25-Oct-2020"), 3);
	
	ArrayList<Slot> slots = new ArrayList<>();
	slots.add(new Slot(1));
	slots.add(new Slot(10));
	slots.add(new Slot(-1));
	
	
	slots.get(0).addItem(item1);
	slots.get(1).addItem(item2);
	slots.get(2).addItem(item3);
	
	
	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 not done.", outContent.toString().trim().substring(outContent.toString().trim().lastIndexOf('\n')+1));
	
}