public void testNestPartsMissing() { NestAgent nest = new NestAgent("NEST AGENT"); Part p = new Part(1); List<Part> nestParts = new ArrayList<Part>(); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); parts = new MockParts("MOCK PARTS"); lane0 = new MockLane("MOCK LANE 0"); camera = new MockCamera("MOCK CAMERA"); nest.getNest(0).setLane(lane0); nest.setCamera(camera); nest.setPartsAgent(parts); assertTrue("Purge parts should be empty", nest.purgeNests.isEmpty()); nest.msgNestInspected(nest.myNests.get(0), new Result(Result.Is.badParts)); assertTrue("Purge parts should be size 1", nest.purgeNests.size() == 1); nest.pickAndExecuteAnAction(); assertTrue("Purge parts should be empty", nest.purgeNests.isEmpty()); assertTrue( "Nest status is need part signifying a purge happened", nest.myNests.get(0).status == Nest.Status.needPart); nest.msgNestInspected(nest.myNests.get(0), new Result(Result.Is.piledParts)); assertTrue("Purge parts should be size 1", nest.purgeNests.size() == 1); nest.pickAndExecuteAnAction(); assertTrue("Purge parts should be empty", nest.purgeNests.isEmpty()); assertTrue( "Nest status is need part signifying a purge happened", nest.myNests.get(0).status == Nest.Status.needPart); }
public void testNestEarlyInspection() { NestAgent nest = new NestAgent("NEST AGENT"); Part p = new Part(1); List<Part> nestParts = new ArrayList<Part>(); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); parts = new MockParts("MOCK PARTS"); lane0 = new MockLane("MOCK LANE 0"); camera = new MockCamera("MOCK CAMERA"); nest.getNest(0).setLane(lane0); nest.setCamera(camera); nest.setPartsAgent(parts); assertTrue( "request early inspection value should be false", nest.requestEarlyInspection == false); nest.msgRequestEarlyInspection(); assertTrue( "request early inspection value should be false", nest.requestEarlyInspection == true); nest.myNests.get(0).status = Nest.Status.gettingPart; nest.pickAndExecuteAnAction(); assertTrue( "request early inspection value should be false", nest.requestEarlyInspection == false); assertTrue( "Nest status is getting part", nest.myNests.get(0).status == Nest.Status.gettingInspected); nest.msgNestInspected(nest.myNests.get(0), new Result(Result.Is.partsMissing)); assertTrue( "Nest status is getting part", nest.myNests.get(0).status == Nest.Status.gettingPart); }
// @Test public void testFirstNest() { NestAgent nest = new NestAgent("NEST AGENT"); Part p = new Part(1); List<Part> nestParts = new ArrayList<Part>(); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); parts = new MockParts("MOCK PARTS"); lane0 = new MockLane("MOCK LANE 0"); camera = new MockCamera("MOCK CAMERA"); nest.getNest(0).setLane(lane0); nest.setCamera(camera); nest.setPartsAgent(parts); assertTrue("Nest 0 status should be empty", nest.myNests.get(0).status == Nest.Status.empty); nest.msgNeedPart(p); // tests msgNeedPart below assertTrue( "Requests size and NeedParts size should be 1", nest.requests.size() == 1 && nest.needParts.size() == 1); nest.pickAndExecuteAnAction(); assertTrue( "Nest 0 status should be needPart", nest.myNests.get(0).status == Nest.Status.needPart); nest.pickAndExecuteAnAction(); assertTrue( "Lane should have gotten msgNeedPart" + getLogs(), lane0.log.containsString("msgNeedPart")); assertTrue( "nest 0 status should be gettingPart", nest.myNests.get(0).status == Nest.Status.gettingPart); nest.msgHereAreParts(nestParts, 0); assertTrue("Nest parts array should contain 8 p1 parts", nest.myNests.get(0).parts.size() == 8); assertTrue("Nest 0 status should be full", nest.myNests.get(0).status == Nest.Status.full); assertTrue( "Parts in nest should have set its nestNum to 0", nest.myNests.get(0).parts.get(0).getNestNum() == 0); assertTrue("The part type of nest 0 should be 1", nest.myNests.get(0).parts.get(0).type == 1); assertTrue( "Requests size should be 1 and NeedParts size should be 0", nest.requests.size() == 1 && nest.needParts.isEmpty()); nest.pickAndExecuteAnAction(); assertTrue( "Camera should have gotten msgRequestInspection from nest" + getLogs(), camera.log.containsString("msgNestIsFull")); assertTrue( "Nest 0 status should be full", nest.myNests.get(0).status == Nest.Status.gettingInspected); nest.msgNestInspected( nest.myNests.get(0), new Result(Result.Is.verified)); // camera verifies the nest assertTrue( "Nest 0 status should be readyForKit", nest.myNests.get(0).status == Nest.Status.readyForKit); nest.pickAndExecuteAnAction(); assertTrue("msgHereIsPart" + getLogs(), parts.log.containsString("msgHereIsPart")); assertTrue( "Requests size and NeedParts size should be 0", nest.requests.isEmpty() && nest.needParts.isEmpty()); assertTrue("Nest parts array should contain 7 p1 parts", nest.myNests.get(0).parts.size() == 7); assertTrue( "Nest 0 status still should be readyForKit", nest.myNests.get(0).status == Nest.Status.readyForKit); }
public void testNestPurge() { // when nest doesn't have a part the kit needs and has to get new parts NestAgent nest = new NestAgent("NEST AGENT"); Part p = new Part(1); Part purgePart = new Part(2); List<Part> nestParts = new ArrayList<Part>(); List<Part> nestPartsPurge = new ArrayList<Part>(); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestParts.add(p); nestPartsPurge.add(purgePart); nestPartsPurge.add(purgePart); nestPartsPurge.add(purgePart); nestPartsPurge.add(purgePart); nestPartsPurge.add(purgePart); nestPartsPurge.add(purgePart); nestPartsPurge.add(purgePart); nestPartsPurge.add(purgePart); parts = new MockParts("MOCK PARTS"); lane0 = new MockLane("MOCK LANE 0"); camera = new MockCamera("MOCK CAMERA"); nest.getNest(0).setLane(lane0); nest.getNest(1).status = Nest.Status.none; // set all other nests to none so scheduler only acts on nest0 nest.getNest(2).status = Nest.Status.none; nest.getNest(3).status = Nest.Status.none; nest.getNest(4).status = Nest.Status.none; nest.getNest(5).status = Nest.Status.none; nest.getNest(6).status = Nest.Status.none; nest.getNest(7).status = Nest.Status.none; nest.setCamera(camera); nest.setPartsAgent(parts); nest.msgHereAreParts(nestParts, 0); nest.myNests.get(0).status = Nest.Status.readyForKit; nest.myNests.get(0).setPart(p); assertTrue("Nest parts array should contain 8 p1 parts", nest.myNests.get(0).parts.size() == 8); assertTrue( "Parts in nest should have set its nestNum to 0", nest.myNests.get(0).parts.get(0).getNestNum() == 0); assertTrue("The part type of nest 0 should be 1", nest.myNests.get(0).parts.get(0).type == 1); nest.msgNeedPart(p); assertTrue( "Nest 0 status should be readyForKit", nest.myNests.get(0).status == Nest.Status.readyForKit); nest.pickAndExecuteAnAction(); assertTrue("msgHereIsPart" + getLogs(), parts.log.containsString("msgHereIsPart")); assertTrue( "Requests size and NeedParts size should be 1", nest.requests.isEmpty() && nest.needParts.size() == 1); assertTrue("Nest parts array should contain 7 p1 parts", nest.myNests.get(0).parts.size() == 7); assertTrue( "Nest 0 status still should be readyForKit", nest.myNests.get(0).status == Nest.Status.readyForKit); nest.needParts.clear(); nest.msgNeedPart(purgePart); assertTrue( "Requests size should be 1 still and NeedParts size should be 2", nest.requests.size() == 1 && nest.needParts.size() == 1); nest.pickAndExecuteAnAction(); assertTrue( "Requests size should be 1 and NeedParts size should be 1", nest.requests.size() == 1 && nest.needParts.size() == 0); assertTrue( "The part type of nest 0 should be 2 [changed after purge]", nest.myNests.get(0).part.type == 2); // after purge nest part is 2 now assertTrue( "Nest status should be needPart", nest.myNests.get(0).status == Nest.Status.needPart); assertTrue( "Nest parts array should contain no parts after purge", nest.myNests.get(0).parts.size() == 0); nest.msgHereAreParts(nestPartsPurge, 0); }