@Test public void alertedByRoom() { Individual i = builder.withAge(0).withReactionTime(7).build(); IndividualProperty ip = new IndividualProperty(i); Room room = mockRoom(i, true, 0); RoomCell cell = generateCell(room, i, ip); ReactionRuleCompleteRoom rule = generateReactionRule(); context.checking( new Expectations() { { allowing(es).propertyFor(i); will(returnValue(ip)); } }); rule.execute(cell); assertThat(ip.isAlarmed(), is(true)); }
@Test public void roomNotAlerted() { Individual i = builder.withAge(0).withReactionTime(7).buildAndReset(); IndividualProperty ip = new IndividualProperty(i); Room room = mockRoom(i, false, 0); RoomCell cell = generateCell(room, i, ip); ReactionRuleCompleteRoom rule = generateReactionRule(); context.checking( new Expectations() { { exactly(1).of(es).getTimeStep(); will(returnValue(0)); allowing(es).propertyFor(i); will(returnValue(ip)); } }); rule.execute(cell); assertThat(ip.isAlarmed(), is(false)); }