예제 #1
0
파일: Agency.java 프로젝트: cflewis/argouml
  public static void applyCritics(Object dm, Designer d, Vector
				  critics, long reasonCode) {
    int size = critics.size();
//     if (_hot) System.out.println("----------");
//     if (_hot) System.out.println("HOT: " +
// 				 Long.toBinaryString(reasonCode) +
// 				 " " +  dm);
    for (int i = 0; i < size; i++) {
      Critic c = (Critic) critics.elementAt(i);
      if (c.isActive() && c.matchReason(reasonCode)) {
// 	if (_hot) System.out.println("hot: " +
// 				     Long.toBinaryString(c.getTriggerMask()) +
// 				     " " + c.getClass().getName());
	try {
	  //_numCriticsApplied++;
	  c.critique(dm, d);
	}
	catch (Exception ex) {
	  System.out.println("Exception raised in critique");
	  System.out.println(c.toString());
	  System.out.println(dm.toString());
	  ex.printStackTrace();
	  System.out.println("----------");
	}
      }
    }
  }
예제 #2
0
  /** Test isRelevant method of CurDecisionCM. */
  public void testCurDecisionCM() {

    Critic critic = new Critic();
    CurDecisionCM cm = new CurDecisionCM();

    // CurDecisionCM isRelevant checks to see if the critic has
    // any decisions that have a priority > 0 and less than the
    // priority of the critic.  By default the critic has no
    // decisions so isRelevant should return false.
    assertTrue(
        "CurDecisionCM.isRelevant(Critic, Designer) is incorrect " + "when critic has 0 decisions",
        !cm.isRelevant(critic, Designer.theDesigner()));

    // add a decision but set the critic priority to 0 so isRelevant
    // should still be false
    critic.setPriority(0);
    critic.addSupportedDecision(Decision.UNSPEC);

    // verify isRelevant is still false
    assertTrue(
        "CurDecisionCM.isRelevant(Critic, Designer) is "
            + "incorrect with one decision and critic has priority 0",
        !cm.isRelevant(critic, Designer.theDesigner()));

    // update the priority of the critic to be the same priority as the
    // decision
    critic.setPriority(Decision.UNSPEC.getPriority());

    // isRelevant should now be true
    assertTrue(
        "CurDecisionCM.isRelevant(Critic, Designer) is incorrect with "
            + "one decision and priority has equal priority",
        cm.isRelevant(critic, Designer.theDesigner()));

    critic.setPriority(Decision.UNSPEC.getPriority() + 1);
    // isRelevant should still be true
    assertTrue(
        "CurDecisionCM.isRelevant(Critic, Designer) is incorrect with"
            + " one decision and priority has greater priority",
        cm.isRelevant(critic, Designer.theDesigner()));
  }
예제 #3
0
파일: Agency.java 프로젝트: cflewis/argouml
  //@ should loop over simpler vector of critics, not CompoundCritics
  public void determineActiveCritics(Designer d) {
    //     Enumeration clazzEnum = getCriticRegistry().keys();
    //     while (clazzEnum.hasMoreElements()) {
    //       Class clazz = (Class) (clazzEnum.nextElement());
    Enumeration criticEnum = _critics.elements();
    while (criticEnum.hasMoreElements()) {
      Critic c = (Critic)(criticEnum.nextElement());
      if (_controlMech.isRelevant(c, d)) {
	//System.out.println("Activated: " + c.toString());
	//Dbg.log("debugActivation","Activated: " + c.toString());
	c.beActive();
      }
      else {
	//System.out.println("Deactivated: " + c.toString());
	//Dbg.log("debugActivation","Deactivated: " + c.toString());
	c.beInactive();
      }
	Thread.yield();
    }
    //}
  }
예제 #4
0
  /** Test isRelevant method of NotSnoozedCM. */
  public void testNotSnoozedCM() {

    Critic critic = new Critic();
    NotSnoozedCM cm = new NotSnoozedCM();

    // NotSnoozedCM isRelevant checks if the critic is snoozed
    // snooze the critic to verify isRelevant returns false
    critic.snooze();

    // verify isRelevant returns true
    assertTrue(
        "NotSnoozedCM.isRelevant(Critic, Designer) is incorrect " + "when critic snoozed",
        !cm.isRelevant(critic, Designer.theDesigner()));

    // unsnooze the critic to verify the critic is not relevant
    critic.unsnooze();

    // verify isRelevant is true
    assertTrue(
        "NotSnoozedCM.isRelevant(Critic, Designer) is incorrect " + "when critic not snoozed",
        cm.isRelevant(critic, Designer.theDesigner()));
  }
예제 #5
0
  /** Test isRelevant method of EnabledCM. */
  public void testEnabledCM() {

    Critic critic = new Critic();
    EnabledCM cm = new EnabledCM();

    // EnabledCM isRelevant checks if the critic is enabled
    // initialize this to true to verify isRelevant returns true
    critic.setEnabled(true);

    // verify isRelevant returns true
    assertTrue(
        "EnabledCM.isRelevant(Critic, Designer) is incorrect",
        cm.isRelevant(critic, Designer.theDesigner()));

    // set enabled to false and check the opposite condition
    critic.setEnabled(false);

    // verify isRelevant not is false
    assertTrue(
        "EnabledCM.isRelevant(Critic, Designer) is incorrect",
        !cm.isRelevant(critic, Designer.theDesigner()));
  }