コード例 #1
0
  public void on(@Observes ExecutionDecisionEvent event, JiraGovernorClient jiraGovernorClient) {
    ExecutionDecision executionDecision = this.executionDecision.get();

    if (executionDecision == null || executionDecision.getDecision() == Decision.DONT_EXECUTE) {
      return;
    }

    if (event.getAnnotation().annotationType() == provides()) {
      Jira jiraIssue = (Jira) event.getAnnotation();

      this.executionDecision.set(jiraGovernorClient.resolve(jiraIssue));
    }
  }
コード例 #2
0
  public void on(
      @Observes AfterTestLifecycleEvent event,
      TestResult testResult,
      GovernorRegistry governorRegistry,
      JiraGovernorConfiguration jiraGovernorConfiguration,
      JiraGovernorClient jiraGovernorClient) {
    int count = 0;
    try {
      Integer c = lifecycleCountRegister.get(event.getTestMethod());
      count = (c != null ? c.intValue() : 0);
      if (count
          == 0) { // skip first event - see
                  // https://github.com/arquillian/arquillian-governor/pull/16#issuecomment-166590210
        return;
      }
      final ExecutionDecision decision =
          TestMethodExecutionRegister.resolve(event.getTestMethod(), provides());

      // if we passed some test method annotated with Jira, we may eventually close it

      if (jiraGovernorConfiguration.getClosePassed()) {
        // we decided we run this test method even it has annotation on it
        if (testResult.getStatus() == Status.PASSED
            && decision.getDecision() == Decision.EXECUTE
            && (JiraGovernorStrategy.FORCING_EXECUTION_REASON_STRING)
                .equals(decision.getReason())) {

          for (Map.Entry<Method, List<Annotation>> entry : governorRegistry.get().entrySet()) {
            if (entry.getKey().toString().equals(event.getTestMethod().toString())) {
              for (Annotation annotation : entry.getValue()) {
                if (annotation.annotationType() == provides()) {
                  String id = ((Jira) annotation).value();
                  jiraGovernorClient.close(id);
                  return;
                }
              }
            }
          }
        }
      }
    } finally {
      lifecycleCountRegister.put(event.getTestMethod(), ++count);
    }
  }