Package com.google.test.metric

Examples of com.google.test.metric.CostModel


  protected void setUp() throws Exception {
    super.setUp();
    ClassRepository repo = new JavaClassRepository();
    MetricComputer toDecorate = new MetricComputerBuilder().withClassRepository(repo).build();
    decoratedComputer = new MetricComputerJavaDecorator(toDecorate, repo);
    HypotheticalCostModel hypotheticalCostModel = new HypotheticalCostModel(new CostModel());
    issuesReporter = new IssuesReporter(new LinkedList<ClassIssues>(), hypotheticalCostModel);
  }
View Full Code Here


    methodWithIndirectCosts = new MethodCost("Foo", "hasIndirect()", 2, false, false, false);
    methodWithIndirectCosts.addCostSource(new CyclomaticCost(new SourceLocation(null, 4), Cost.cyclomatic(50)));
    methodWithIndirectCosts.addCostSource(new MethodInvocationCost(new SourceLocation(null, 1),
        doThingMethod, NON_OVERRIDABLE_METHOD_CALL, Cost.cyclomatic(33)));
    costModel = new CostModel();
  }
View Full Code Here

  protected void setUp() throws Exception {
    super.setUp();
    ClassRepository repo = new JavaClassRepository();
    MetricComputer toDecorate = new MetricComputerBuilder().withClassRepository(repo).build();
    decoratedComputer = new MetricComputerJavaDecorator(toDecorate, repo);
    costModel = new HypotheticalCostModel(new CostModel());
    issuesReporter = new IssuesReporter(new LinkedList<ClassIssues>(), this.costModel);
  }
View Full Code Here

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    out = new ByteArrayOutputStream();
    CostModel costModel = new CostModel();
    SourceLocation location = new SourceLocation("com/google/FooClass.java", 1);
    final Issue issue =
        new Issue(location, "void doThing()", 0.5f, IssueType.CONSTRUCTION, IssueSubType.SETTER);
    final MethodCost methodCost = new MethodCost("", "void setUp()", 1, false, false, false);
    methodCost.addCostSource(new MethodInvocationCost(location, methodCost,
View Full Code Here

  protected void setUp() throws Exception {
    super.setUp();
    ClassPath classPath =
        new ClassPathFactory().createFromPaths("src/test/java", "core/src/test/java");
    SourceLoader loader = new SourceLoader(classPath);
    report = new SourceReportGenerator(new GradeCategories(0, 0), loader, null, new CostModel(),
            new Date(), 10, new Configuration());
    computer = new MetricComputer(new JavaClassRepository(), null,
            new RegExpWhiteList(), 1);
  }
View Full Code Here

      RegExpWhiteList whitelist = new RegExpWhiteList("java.");
      for (String packageName : whitelistPackages) {
        whitelist.addPackage(packageName);
      }
     
      CostModel costModel = new CostModel(cyclomaticCost, globalCost, constructorMultiplier);
      JavaClassRepository classRepository = new JavaClassRepository(classPath);
      MetricComputer computer = new MetricComputer(classRepository, errorStream, whitelist, printDepth);
      HypotheticalCostModel hypotheticalCostModel = new HypotheticalCostModel(costModel);
      IssuesReporter issuesReporter = new IssuesReporter(
          new TriageIssuesQueue<ClassIssues>(maxAcceptableCost,
View Full Code Here

    cost3.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));
    cost3.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));
    cost3.addCostSource(new CyclomaticCost(new SourceLocation(null, 0), Cost.cyclomatic(1)));
    cost.addCostSource(new MethodInvocationCost(new SourceLocation(null, 0), cost3,
        IMPLICIT_STATIC_INIT, Cost.cyclomatic(3)));
    CostModel costModel = new CostModel(2, 10, 1);
    cost.link();

    assertEquals((long) 2 * (3 + 1) + 10 * 1, costModel.computeOverall(cost.getTotalCost()));
    assertEquals(2, cost.getExplicitViolationCosts().size());
    assertEquals(1, cost.getImplicitViolationCosts().size());
  }
View Full Code Here

  private MetricComputer computer;

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    computer = new MetricComputer(repo, null, new RegExpWhiteList(), new CostModel());
  }
View Full Code Here

  private ClassCost classCost(String name, int cost) {
    List<MethodCost> methods = new ArrayList<MethodCost>();
    methods.add(new MethodCost("method_" + cost, 1, cost));
    ClassCost classCost = new ClassCost(name, methods);
    classCost.link(new CostModel(1, 1));
    return classCost;
  }
View Full Code Here

  public void testComputeOverallCost() throws Exception {
    MethodCost cost = new MethodCost("a", 0, 1);
    cost.addGlobalCost(0, null);
    cost.addMethodCost(0, new MethodCost("b", 0, 3));
    CostModel context = new CostModel(2, 10);
    cost.link(context);

    assertEquals((long) 2 * (3 + 1) + 10 * 1, cost.getOverallCost());
  }
View Full Code Here

TOP

Related Classes of com.google.test.metric.CostModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.