Simulator/test/model/environment/objects/physicalObject/ChairTest.java
/**
	 * Tests the chair occupation after the agent is destroyed.
	 */
Tests the chair occupation after the agent is destroyed.
Tests the chair occupation after the agent is destroyed .
@Test
	public void testOccupationAfterDestroy() {
		Chair c = new Chair(new Position(10, 10), new Position(9.75, 9.75), 0.5);
		HumanAgent a = new HumanAgent(new Position(9.75, 9.75), 0.2, 80, Color.RED) {
			@Override
			public void communicate(CommunicationType type, Object communication) {
			}
			@Override
			public <T> Collection<T> getObservation(Class<T> type) {
				return null;
			}
			@Override
			public boolean wantsToBeDestoryed() {
				if (map.getTime() > 5)
					return true;
				return false;
			}
			@Override
			public void update(int timeStep) {
			}
		};
		Simulator s = new Simulator.Builder<>().setEndingConditions(new BaseEndingConditions(10)).setGui(false).build();
		s.add(c);
		s.add(a);
		Assert.assertFalse(c.isOccupied());
		c.setOccupied(a);
		Assert.assertTrue(c.isOccupied());
		Thread t = new Thread(s);
		t.start();
		try {
			t.join();
		} catch (Exception e) {
			e.printStackTrace();
		}
		Assert.assertFalse(c.isOccupied());
	}
@ Test public void testOccupationAfterDestroy ( ) { Chair c = new Chair ( new Position ( 10 , 10 ) , new Position ( 9.75 , 9.75 ) , 0.5 ) ; HumanAgent a = new HumanAgent ( new Position ( 9.75 , 9.75 ) , 0.2 , 80 , Color . RED ) { @ Override public void communicate ( CommunicationType type , Object communication ) { } @ Override public < T > Collection < T > getObservation ( Class < T > type ) { return null ; } @ Override public boolean wantsToBeDestoryed ( ) { if ( map . getTime ( ) > 5 ) return true ; return false ; } @ Override public void update ( int timeStep ) { } } ; Simulator s = new Simulator . Builder < > ( ) . setEndingConditions ( new BaseEndingConditions ( 10 ) ) . setGui ( false ) . build ( ) ; s . add ( c ) ; s . add ( a ) ; Assert . assertFalse ( c . isOccupied ( ) ) ; c . setOccupied ( a ) ; Assert . assertTrue ( c . isOccupied ( ) ) ; Thread t = new Thread ( s ) ; t . start ( ) ; try { t . join ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } Assert . assertFalse ( c . isOccupied ( ) ) ; }
Tests the chair occupation after the agent is destroyed.
Tests the chair occupation after the agent is destroyed .