MapElementSize width = new MapElementSizePixel(20.0);
MapElementSize height = new MapElementSizePixel(20.0);
MyInternalEffect effect = addBean(new MyInternalEffect());
RectangleElement rectangleElement = new RectangleElement(
new Point(0, 0), Color.BLACK, width, height);
PositionTrigger positionTrigger = new PositionTrigger(
new CircleElement(new Point(25, 25), Color.red, width),
effect.getId(), RectangleElement.class, map.getId());
MapElementFactory.buildMapElement(rectangleElement, map);
MapElementFactory.buildMapElement(positionTrigger, map);
positionTrigger = getBeans(positionTrigger);
assertTrue("trigger should'nt be activated",
!positionTrigger.isActivate());
assertEquals("the effect should have been activated 0", 0,
effect.getActivationCount());
assertEquals("the effect should have been desactivated 0", 0,
effect.getDesactivationCount());
rectangleElement = getBeans(rectangleElement);
rectangleElement.setPosition(new Point(15, 15));
sleep(10);
assertTrue("trigger should be activated", positionTrigger.isActivate());
assertEquals("the effect should have been activated once", 1,
effect.getActivationCount());
assertEquals("the effect should have been desactivated 0", 0,
effect.getDesactivationCount());
rectangleElement.setPosition(new Point(0, 0));
sleep(10);
assertTrue("trigger should'nt be activated",
!positionTrigger.isActivate());
assertEquals("the effect should have been activated once", 1,
effect.getActivationCount());
assertEquals("the effect should have been desactivated once", 1,
effect.getDesactivationCount());
RectangleElement rectangle2 = new RectangleElement(new Point(15, 15),
Color.BLACK, width, height);
MapElementFactory.buildMapElement(rectangle2, map);
getBeans(rectangle2);
sleep(10);