Esempio n. 1
0
  /**
   * RUL 012
   *
   * <p>Class: SuperTypeRule Unit: processRuleOnNode(Declaration d, ArrayList<Declaration>
   * allDecls);
   *
   * <p>Tests that the unit scores correctly for this class by evaluating three different instances.
   */
  @Test
  public void superTwo() {
    ArrayList<Declaration> allDecls = new ArrayList<Declaration>();

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

    allDecls.add(a);
    allDecls.add(b);
    allDecls.add(c);
    allDecls.add(d);

    // B and D used as super types here.
    c.addSuperClass(b.getName());
    a.addSuperClass(d.getName());

    SuperTypeRule rule = new SuperTypeRule();

    rule.processRuleOnNode(b, allDecls);
    assertEquals(1, rule.getScore());

    rule.processRuleOnNode(d, allDecls);
    assertEquals(1, rule.getScore());
  }
Esempio n. 2
0
  /**
   * RUL 011
   *
   * <p>Class: SuperTypeRule Unit: processRuleOnNode(Declaration d, ArrayList<Declaration>
   * allDecls);
   *
   * <p>Tests that the unit scores correctly for this class by evaluating three different instances.
   */
  @Test
  public void superOne() {
    ArrayList<Declaration> allDecls = new ArrayList<Declaration>();

    Declaration a = new InterfaceDeclaration("Interface A");
    Declaration b = new InterfaceDeclaration("Interface B");
    Declaration c = new InterfaceDeclaration("Interface C");
    Declaration d = new InterfaceDeclaration("Interface D");

    allDecls.add(a);
    allDecls.add(b);
    allDecls.add(c);
    allDecls.add(d);

    // C and A used as super types here.
    d.addSuperClass(c.getName());
    c.addSuperClass(a.getName());

    // A used as super type here.
    b.addSuperClass(a.getName());

    SuperTypeRule rule = new SuperTypeRule();

    rule.processRuleOnNode(a, allDecls);
    assertEquals(2, rule.getScore());

    rule.processRuleOnNode(b, allDecls);
    assertEquals(0, rule.getScore());

    rule.processRuleOnNode(c, allDecls);
    assertEquals(1, rule.getScore());
  }