/**
   * RUL 004
   *
   * <p>Class: CreationEvaluationRule Unit: processRuleOnNode(Declaration beingScored,
   * ArrayList<Declaration> allDecls)
   *
   * <p>This test creates instance of class declarations and interface declarations. It adds new
   * object references to two of the class declarations.
   */
  @Test
  public void creationOne() {
    ArrayList<Declaration> allDecls = new ArrayList<Declaration>();

    ClassDeclaration a = new ClassDeclaration("Class A", false);
    ClassDeclaration b = new ClassDeclaration("Class B", false);
    ClassDeclaration c = new ClassDeclaration("Class C", false);
    ClassDeclaration d = new ClassDeclaration("Class D", false);

    Declaration e = new InterfaceDeclaration("Interface E");
    Declaration f = new InterfaceDeclaration("Interface F");

    // Add all to list
    allDecls.add(f);
    allDecls.add(e);
    allDecls.add(d);
    allDecls.add(c);
    allDecls.add(b);
    allDecls.add(a);

    // Add four new objects to A
    a.addReferenceToNewObject("Interface E");
    a.addReferenceToNewObject("Interface F");
    a.addReferenceToNewObject("Class B");
    a.addReferenceToNewObject("Class D");

    // Add two new objects to C
    c.addReferenceToNewObject("Class A");
    c.addReferenceToNewObject("Interface B"); // Shouldn't happen but can handle.

    CreationEvaluationRule rule = new CreationEvaluationRule();

    rule.processRuleOnNode(a, allDecls);
    // A has four new references but is reference new once by C
    assertEquals(3, rule.getScore());

    rule.processRuleOnNode(d, allDecls);
    // D is created by A but does not create any itself
    assertEquals(-1, rule.getScore());

    // Should be one as interfaces cannot be 'created' a concrete implementation relies behind it.
    rule.processRuleOnNode(c, allDecls);
    assertEquals(1, rule.getScore());
  }
  /**
   * RUL 005
   *
   * <p>Class: CreationEvaluationRule Unit: processRuleOnNode(Declaration beingScored,
   * ArrayList<Declaration> allDecls)
   *
   * <p>Tests that all interfaces give a score of 0.
   */
  @Test
  public void creationTwo() {
    ArrayList<Declaration> allDecls = new ArrayList<Declaration>();

    ClassDeclaration a = new ClassDeclaration("Class A", false);
    ClassDeclaration b = new ClassDeclaration("Class B", false);
    ClassDeclaration c = new ClassDeclaration("Class C", false);
    ClassDeclaration d = new ClassDeclaration("Class D", false);

    Declaration e = new InterfaceDeclaration("Interface E");
    Declaration f = new InterfaceDeclaration("Interface F");

    // Add all to list
    allDecls.add(f);
    allDecls.add(e);
    allDecls.add(d);
    allDecls.add(c);
    allDecls.add(b);
    allDecls.add(a);

    // Add four new objects to A
    a.addReferenceToNewObject("Class B");
    a.addReferenceToNewObject("Class D");

    // Add two new objects to C
    c.addReferenceToNewObject("Class A");

    CreationEvaluationRule rule = new CreationEvaluationRule();

    // Score the interfaces to ensure 0.
    rule.processRuleOnNode(e, allDecls);
    assertEquals(0, rule.getScore());

    rule.processRuleOnNode(f, allDecls);
    assertEquals(0, rule.getScore());
  }