Package org.sonar.api.issue.internal

Examples of org.sonar.api.issue.internal.IssueChangeContext


public class IssueChangeContextTest {
  @Test
  public void test_scan_context() throws Exception {
    Date now = new Date();
    IssueChangeContext context = IssueChangeContext.createScan(now);

    assertThat(context.scan()).isTrue();
    assertThat(context.login()).isNull();
    assertThat(context.date()).isEqualTo(now);
  }
View Full Code Here


  }

  @Test
  public void test_end_user_context() throws Exception {
    Date now = new Date();
    IssueChangeContext context = IssueChangeContext.createUser(now, "emmerik");

    assertThat(context.scan()).isFalse();
    assertThat(context.login()).isEqualTo("emmerik");
    assertThat(context.date()).isEqualTo(now);
  }
View Full Code Here

    Mockito.verify(manager).scheduleForSending(notification);
  }

  @Test
  public void should_send_changes() throws Exception {
    IssueChangeContext context = IssueChangeContext.createScan(new Date());
    DefaultIssue issue = new DefaultIssue()
      .setMessage("the message")
      .setKey("ABCDE")
      .setAssignee("freddy")
      .setFieldChange(context, "resolution", null, "FIXED")
View Full Code Here

    Mockito.verify(manager).scheduleForSending(eq(Arrays.asList(notification)));
  }

  @Test
  public void should_send_changes_with_comment() throws Exception {
    IssueChangeContext context = IssueChangeContext.createScan(new Date());
    DefaultIssue issue = new DefaultIssue()
      .setMessage("the message")
      .setKey("ABCDE")
      .setAssignee("freddy")
      .setComponentKey("struts:Action")
View Full Code Here

    Mockito.verify(manager).scheduleForSending(eq(Arrays.asList(notification)));
  }

  @Test
  public void should_send_changes_with_component_name() throws Exception {
    IssueChangeContext context = IssueChangeContext.createScan(new Date());
    DefaultIssue issue = new DefaultIssue()
      .setMessage("the message")
      .setKey("ABCDE")
      .setAssignee("freddy")
      .setFieldChange(context, "resolution", null, "FIXED")
View Full Code Here

    Mockito.verify(manager).scheduleForSending(eq(Arrays.asList(notification)));
  }

  @Test
  public void should_not_send_changes_if_no_diffs() throws Exception {
    IssueChangeContext context = IssueChangeContext.createScan(new Date());
    DefaultIssue issue = new DefaultIssue()
      .setMessage("the message")
      .setKey("ABCDE")
      .setComponentKey("struts:Action")
      .setProjectKey("struts");
View Full Code Here

    verify(notifications).sendChanges(argThat(matchMapOf(issue, rule)), any(IssueChangeContext.class), any(Component.class), (Component) isNull(), eq((String) null));
  }

  @Test
  public void should_not_send_notification_if_issue_change_on_removed_rule() throws Exception {
    IssueChangeContext changeContext = mock(IssueChangeContext.class);

    when(project.getAnalysisDate()).thenReturn(DateUtils.parseDate("2013-05-18"));
    RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles");
    DefaultIssue issue = new DefaultIssue()
      .setChanged(true)
View Full Code Here

    verify(notifications, never()).sendChanges(argThat(matchMapOf(issue, null)), eq(changeContext), any(Component.class), any(Component.class), eq((String) null));
  }

  @Test
  public void should_not_send_notification_on_any_change() throws Exception {
    IssueChangeContext changeContext = mock(IssueChangeContext.class);

    when(project.getAnalysisDate()).thenReturn(DateUtils.parseDate("2013-05-18"));
    RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles");
    DefaultIssue issue = new DefaultIssue()
      .setChanged(true)
View Full Code Here

      }
      if (!action.supports(issue)) {
        throw new IllegalStateException("A condition is not respected");
      }

      IssueChangeContext changeContext = IssueChangeContext.createUser(new Date(), userSession.login());
      Component project = dbClient.componentDao().getByKey(session, issue.projectKey());
      FunctionContext functionContext = new FunctionContext(issue, updater, changeContext, getProjectSettings(project));
      for (Function function : action.functions()) {
        function.execute(functionContext);
      }
View Full Code Here

    verifyLoggedIn();

    DbSession session = dbClient.openSession(false);
    try {
      DefaultIssue defaultIssue = getByKeyForUpdate(session, issueKey).toDefaultIssue();
      IssueChangeContext context = IssueChangeContext.createUser(new Date(), UserSession.get().login());
      checkTransitionPermission(transitionKey, UserSession.get(), defaultIssue);
      if (workflow.doTransition(defaultIssue, transitionKey, context)) {
        saveIssue(session, defaultIssue, context, null);
      }
      return defaultIssue;
View Full Code Here

TOP

Related Classes of org.sonar.api.issue.internal.IssueChangeContext

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.