예제 #1
0
  private void fireAnalysis(ScopesAgendaFilter scopesAgendaFilter) throws RuntimeException {

    verifier.fireAnalysis(scopesAgendaFilter);

    if (verifier.hasErrors()) {
      StringBuilder message = new StringBuilder("Verifier Errors:\n");
      for (VerifierError verifierError : verifier.getErrors()) {
        message.append("\t");
        message.append(verifierError.getMessage());
        message.append("\n");
      }
      throw new RuntimeException(message.toString());
    }
  }
예제 #2
0
  @Test
  @Ignore("08-APR-2011 temporally ignoring -Rikkola-")
  public void testCauseTrace() throws Exception {

    VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();

    // Check that the builder works.
    assertFalse(vBuilder.hasErrors());
    assertEquals(0, vBuilder.getErrors().size());

    Verifier verifier = vBuilder.newVerifier();

    verifier.addResourcesToVerify(
        new ClassPathResource("Causes.drl", getClass()), ResourceType.DRL);

    assertFalse(verifier.hasErrors());
    assertEquals(0, verifier.getErrors().size());

    boolean works = verifier.fireAnalysis();

    assertTrue(works);

    VerifierReport result = verifier.getResult();
    assertNotNull(result);
    assertEquals(0, result.getBySeverity(Severity.ERROR).size());
    Collection<VerifierMessageBase> warnings = result.getBySeverity(Severity.WARNING);
    Collection<VerifierMessageBase> redundancyWarnings = new ArrayList<VerifierMessageBase>();

    for (VerifierMessageBase verifierMessageBase : warnings) {
      if (verifierMessageBase.getMessageType().equals(MessageType.REDUNDANCY)) {
        redundancyWarnings.add(verifierMessageBase);
      }
    }

    assertEquals(1, redundancyWarnings.size());

    VerifierMessage message = (VerifierMessage) redundancyWarnings.toArray()[0];

    //        System.out.println( message );

    assertEquals(2, message.getImpactedRules().size());

    assertTrue(message.getImpactedRules().values().contains("Your First Rule"));
    assertTrue(message.getImpactedRules().values().contains("Your Second Rule"));

    Cause[] causes = message.getCauses().toArray(new Cause[message.getCauses().size()]);

    assertEquals(1, causes.length);
    causes = causes[0].getCauses().toArray(new Cause[causes[0].getCauses().size()]);

    assertEquals(2, causes.length);

    causes = causes[0].getCauses().toArray(new Cause[causes[0].getCauses().size()]);

    assertEquals(1, causes.length);

    causes = causes[0].getCauses().toArray(new Cause[causes[0].getCauses().size()]);

    assertEquals(1, causes.length);

    causes = causes[0].getCauses().toArray(new Cause[causes[0].getCauses().size()]);

    assertEquals(2, causes.length);

    assertEquals(0, result.getBySeverity(Severity.NOTE).size());
  }