public void testRemoveNotExists() throws Exception { try { ConstraintSet set = new ConstraintSet(ConstraintOp.OR); set.addConstraint(sc1); set.removeConstraint(sc2); fail("Expected IllegalArgumentExcepion"); } catch (IllegalArgumentException e) { } }
public void testRemoveConstrint() { ConstraintSet set = new ConstraintSet(ConstraintOp.AND); set.addConstraint(sc1); set.addConstraint(sc2); set.removeConstraint(sc1); LinkedHashSet test = new LinkedHashSet(); test.add(sc2); assertEquals(test, set.getConstraints()); }
Frontier prepareMessage(ConstraintSet constraintSet, InGroupablesStack inGroupablesStack) { final Arrow graphic = createArrow(); final double arrowYStartLevel = graphic.getArrowYStartLevel(getStringBounder()); final double arrowYEndLevel = graphic.getArrowYEndLevel(getStringBounder()); for (LifeEvent lifeEvent : getMessage().getLiveEvents()) { beforeMessage(lifeEvent, arrowYStartLevel); } final double length = graphic.getArrowOnlyWidth(getStringBounder()); incFreeY(graphic.getPreferredHeight(getStringBounder())); double marginActivateAndDeactive = 0; if (getMessage().isActivateAndDeactive()) { marginActivateAndDeactive = 30; incFreeY(marginActivateAndDeactive); } getDrawingSet().addEvent(getMessage(), graphic); final LivingParticipantBox livingParticipantBox = getLivingParticipantBox(); if (messageArrow.getType().isRightBorder()) { constraintSet .getConstraint(livingParticipantBox.getParticipantBox(), constraintSet.getLastborder()) .ensureValue(length); } else { constraintSet .getConstraint(constraintSet.getFirstBorder(), livingParticipantBox.getParticipantBox()) .ensureValue(length); } for (LifeEvent lifeEvent : getMessage().getLiveEvents()) { afterMessage(getStringBounder(), lifeEvent, arrowYEndLevel + marginActivateAndDeactive); } assert graphic instanceof InGroupable; if (graphic instanceof InGroupable) { inGroupablesStack.addElement((InGroupable) graphic); inGroupablesStack.addElement(livingParticipantBox); } return getFreeY(); }
public void testEqual() throws Exception { ConstraintSet cs1 = new ConstraintSet(ConstraintOp.AND); ConstraintSet cs2 = new ConstraintSet(ConstraintOp.AND); ConstraintSet cs3 = new ConstraintSet(ConstraintOp.AND); ConstraintSet cs4 = new ConstraintSet(ConstraintOp.AND); ConstraintSet cs5 = new ConstraintSet(ConstraintOp.OR); ConstraintSet cs6 = new ConstraintSet(ConstraintOp.NAND); cs1.addConstraint(sc1).addConstraint(sc2); cs2.addConstraint(sc1).addConstraint(sc2); assertEquals(cs1, cs1); assertEquals(cs1, cs2); // cs3 has same two constraints but in different oreder, should still be equal cs3.addConstraint(sc2).addConstraint(sc1); assertEquals(cs1, cs3); cs4.addConstraint(sc1); assertEquals(cs4, cs4); assertTrue("Expected cs1 and cs4 to not be equal", !cs1.equals(cs4)); // cs5 is AND, cs4 is OR cs5.addConstraint(sc1); assertTrue("Expected cs4 and cs5 to not be equal", !cs4.equals(cs5)); // cs6 is negated, cs4 is not cs6.addConstraint(sc1); assertTrue("Expected cs4 and cs6 to not be equal", !cs4.equals(cs6)); }
public void testHashCode() throws Exception { ConstraintSet cs1 = new ConstraintSet(ConstraintOp.AND); ConstraintSet cs2 = new ConstraintSet(ConstraintOp.AND); ConstraintSet cs3 = new ConstraintSet(ConstraintOp.AND); ConstraintSet cs4 = new ConstraintSet(ConstraintOp.AND); ConstraintSet cs5 = new ConstraintSet(ConstraintOp.OR); ConstraintSet cs6 = new ConstraintSet(ConstraintOp.NAND); cs1.addConstraint(sc1).addConstraint(sc2); cs2.addConstraint(sc1).addConstraint(sc2); assertEquals(cs1.hashCode(), cs1.hashCode()); assertEquals(cs1.hashCode(), cs2.hashCode()); // cs3 has same two constraints but in different oreder, should still be equal cs3.addConstraint(sc2).addConstraint(sc1); assertEquals(cs1.hashCode(), cs3.hashCode()); cs4.addConstraint(sc1); assertEquals(cs4.hashCode(), cs4.hashCode()); assertTrue( "Expected cs1.hashCode() and cs4.hashCode() to not be equal", cs1.hashCode() != cs4.hashCode()); // cs5 is AND, cs4 is OR cs5.addConstraint(sc1); assertTrue( "Expected cs4.hashCode() and cs5.hashCode() to not be equal", cs4.hashCode() != cs5.hashCode()); // cs6 is negated, cs4 is not cs6.addConstraint(sc1); assertTrue( "Expected cs4.hashCode() and cs6.hashCode() to not be equal", cs4.hashCode() != cs6.hashCode()); }