Search in sources :

Example 1 with Status

use of com.atlassian.jira.rest.client.api.domain.Status in project staf by simpleworks-gmbh.

the class DebugTestFLOClientMojo method dumpIssue.

public void dumpIssue() {
    final Issue issue = client.getIssue(testPlanId).claim();
    DebugTestFLOClientMojo.logger.debug(String.format("key: '%s', issue: id: %d.", issue.getKey(), issue.getId()));
    final IssueType type = issue.getIssueType();
    DebugTestFLOClientMojo.logger.debug(String.format("issue type: id: %d, name: '%s'.", type.getId(), type.getName()));
    final Status status = issue.getStatus();
    DebugTestFLOClientMojo.logger.debug(String.format("status: id: %d, name: '%s'.", status.getId(), status.getName()));
    DebugTestFLOClientMojo.dumpFields("fields for issue.", issue.getFields());
    DebugTestFLOClientMojo.logger.debug("attachments:");
    for (final Attachment attachment : issue.getAttachments()) {
        DebugTestFLOClientMojo.logger.debug(String.format("attachment: '%s'.", attachment));
    }
    final IssueField field = issue.getField("Test Plan Iteration");
    Assert.assertNotNull("field \"Test Plan Iteration\" can't be null.", field);
    final Object obj = field.getValue();
    DebugTestFLOClientMojo.logger.debug(String.format("class for field: \"Iteration\" is: '%s'.", obj.getClass().getName()));
    {
        DebugTestFLOClientMojo.logger.debug("transition:");
        final Iterable<Transition> transitions = client.getTransitions(issue).claim();
        for (final Transition transition : transitions) {
            DebugTestFLOClientMojo.logger.debug(String.format("transition: name: '%s', id: %d.", transition.getName(), Integer.valueOf(transition.getId())));
        }
    }
    for (final Subtask subtask : issue.getSubtasks()) {
        final Issue i = client.getIssue(subtask.getIssueKey()).claim();
        final IssueField steps = i.getFieldByName("Steps");
        DebugTestFLOClientMojo.logger.debug(String.format("steps: '%s'.", steps.getValue()));
        final IssueField template = i.getFieldByName("TC Template");
        DebugTestFLOClientMojo.logger.debug(String.format("template: '%s'.", template.getValue()));
        final Iterable<Transition> transitions = client.getTransitions(i).claim();
        for (final Transition transition : transitions) {
            DebugTestFLOClientMojo.logger.debug(String.format("subtask: '%s', transition: name: '%s', id: %d.", subtask.getIssueKey(), transition.getName(), Integer.valueOf(transition.getId())));
        }
    }
}
Also used : Status(com.atlassian.jira.rest.client.api.domain.Status) Subtask(com.atlassian.jira.rest.client.api.domain.Subtask) Issue(com.atlassian.jira.rest.client.api.domain.Issue) IssueField(com.atlassian.jira.rest.client.api.domain.IssueField) IssueType(com.atlassian.jira.rest.client.api.domain.IssueType) Transition(com.atlassian.jira.rest.client.api.domain.Transition) Attachment(com.atlassian.jira.rest.client.api.domain.Attachment)

Example 2 with Status

use of com.atlassian.jira.rest.client.api.domain.Status in project jira-plugin by jenkinsci.

the class JiraCreateIssueNotifierTest method performFailureSuccessIssueClosedWithComponents.

@Test
@WithoutJenkins
public void performFailureSuccessIssueClosedWithComponents() throws Exception {
    JiraCreateIssueNotifier notifier = spy(new JiraCreateIssueNotifier(JIRA_PROJECT, "", "", "", 1L, 1L, 1));
    doReturn(site).when(notifier).getSiteForProject(Mockito.any());
    Issue issue = mock(Issue.class);
    Status status = new Status(null, null, JiraCreateIssueNotifier.finishedStatuses.Closed.toString(), null, null, null);
    when(session.createIssue(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyIterable(), Mockito.anyString(), Mockito.anyLong(), Mockito.anyLong())).thenReturn(issue);
    when(issue.getStatus()).thenReturn(status);
    when(session.getIssueByKey(Mockito.anyString())).thenReturn(issue);
    assertEquals(0, temporaryDirectory.list().length);
    when(previousBuild.getResult()).thenReturn(Result.SUCCESS);
    when(currentBuild.getResult()).thenReturn(Result.FAILURE);
    assertTrue(notifier.perform(currentBuild, launcher, buildListener));
    assertEquals(1, temporaryDirectory.list().length);
    when(previousBuild.getResult()).thenReturn(Result.FAILURE);
    when(currentBuild.getResult()).thenReturn(Result.SUCCESS);
    assertTrue(notifier.perform(currentBuild, launcher, buildListener));
    // file should be deleted
    assertEquals(0, temporaryDirectory.list().length);
}
Also used : Status(com.atlassian.jira.rest.client.api.domain.Status) Issue(com.atlassian.jira.rest.client.api.domain.Issue) Test(org.junit.Test) WithoutJenkins(org.jvnet.hudson.test.WithoutJenkins)

Example 3 with Status

use of com.atlassian.jira.rest.client.api.domain.Status in project jira-plugin by jenkinsci.

the class JiraCreateIssueNotifierTest method performFailureSuccessIssueOpen.

@Test
@WithoutJenkins
public void performFailureSuccessIssueOpen() throws Exception {
    Long typeId = 1L;
    Long priorityId = 0L;
    Integer actionIdOnSuccess = 5;
    JiraCreateIssueNotifier notifier = spy(new JiraCreateIssueNotifier(JIRA_PROJECT, "", "", "", typeId, priorityId, actionIdOnSuccess));
    assertEquals(typeId, notifier.getTypeId());
    assertEquals(priorityId, notifier.getPriorityId());
    assertEquals(actionIdOnSuccess, notifier.getActionIdOnSuccess());
    doReturn(site).when(notifier).getSiteForProject(Mockito.any());
    Issue issue = mock(Issue.class);
    Status status = new Status(null, null, "1", "Open", null, null);
    when(session.createIssue(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyIterable(), Mockito.anyString(), Mockito.eq(typeId), Mockito.isNull())).thenReturn(issue);
    when(issue.getStatus()).thenReturn(status);
    when(session.getIssueByKey(Mockito.anyString())).thenReturn(issue);
    assertEquals(0, temporaryDirectory.list().length);
    when(previousBuild.getResult()).thenReturn(Result.SUCCESS);
    when(currentBuild.getResult()).thenReturn(Result.FAILURE);
    assertTrue(notifier.perform(currentBuild, launcher, buildListener));
    assertEquals(1, temporaryDirectory.list().length);
    when(previousBuild.getResult()).thenReturn(Result.FAILURE);
    when(currentBuild.getResult()).thenReturn(Result.SUCCESS);
    assertTrue(notifier.perform(currentBuild, launcher, buildListener));
    verify(session).progressWorkflowAction("null", actionIdOnSuccess);
    assertEquals(1, temporaryDirectory.list().length);
}
Also used : Status(com.atlassian.jira.rest.client.api.domain.Status) Issue(com.atlassian.jira.rest.client.api.domain.Issue) Test(org.junit.Test) WithoutJenkins(org.jvnet.hudson.test.WithoutJenkins)

Example 4 with Status

use of com.atlassian.jira.rest.client.api.domain.Status in project jira-plugin by jenkinsci.

the class JiraCreateIssueNotifierTest method performFailureFailure.

@Test
@WithoutJenkins
public void performFailureFailure() throws Exception {
    JiraCreateIssueNotifier notifier = spy(new JiraCreateIssueNotifier(JIRA_PROJECT, DESCRIPTION, ASSIGNEE, COMPONENT, 1L, 1L, 1));
    doReturn(site).when(notifier).getSiteForProject(Mockito.any());
    Issue issue = mock(Issue.class);
    Status status = new Status(null, null, "1", "Open", null, null);
    when(session.createIssue(Mockito.anyString(), contains(DESCRIPTION), Mockito.anyString(), Mockito.anyIterable(), Mockito.anyString(), Mockito.anyLong(), Mockito.anyLong())).thenReturn(issue);
    when(session.getIssueByKey(Mockito.anyString())).thenReturn(issue);
    when(issue.getStatus()).thenReturn(status);
    assertEquals(0, temporaryDirectory.list().length);
    when(previousBuild.getResult()).thenReturn(Result.SUCCESS);
    when(currentBuild.getResult()).thenReturn(Result.FAILURE);
    assertTrue(notifier.perform(currentBuild, launcher, buildListener));
    assertEquals(1, temporaryDirectory.list().length);
    when(previousBuild.getResult()).thenReturn(Result.FAILURE);
    when(currentBuild.getResult()).thenReturn(Result.FAILURE);
    assertTrue(notifier.perform(currentBuild, launcher, buildListener));
    assertEquals(1, temporaryDirectory.list().length);
    when(issue.getStatus()).thenReturn(new Status(null, null, "6", JiraCreateIssueNotifier.finishedStatuses.Closed.toString(), null, null));
    assertTrue(notifier.perform(currentBuild, launcher, buildListener));
    assertEquals(1, temporaryDirectory.list().length);
}
Also used : Status(com.atlassian.jira.rest.client.api.domain.Status) Issue(com.atlassian.jira.rest.client.api.domain.Issue) Test(org.junit.Test) WithoutJenkins(org.jvnet.hudson.test.WithoutJenkins)

Example 5 with Status

use of com.atlassian.jira.rest.client.api.domain.Status in project jira-plugin by jenkinsci.

the class JiraCreateReleaseNotesTest method releaseNotesContent.

@Test
public void releaseNotesContent() throws InterruptedException, Exception {
    JiraCreateReleaseNotes jcrn = spy(new JiraCreateReleaseNotes(JIRA_PRJ, JIRA_RELEASE, JIRA_VARIABLE));
    doReturn(site).when(jcrn).getSiteForProject(Mockito.any());
    when(site.getReleaseNotesForFixVersion(JIRA_PRJ, JIRA_RELEASE, JiraCreateReleaseNotes.DEFAULT_FILTER)).thenCallRealMethod();
    Issue issue1 = Mockito.mock(Issue.class);
    IssueType issueType1 = Mockito.mock(IssueType.class);
    Status issueStatus = Mockito.mock(Status.class);
    when(issue1.getIssueType()).thenReturn(issueType1);
    when(issue1.getStatus()).thenReturn(issueStatus);
    when(issueType1.getName()).thenReturn("Bug");
    Issue issue2 = Mockito.mock(Issue.class);
    IssueType issueType2 = Mockito.mock(IssueType.class);
    when(issue2.getIssueType()).thenReturn(issueType2);
    when(issue2.getStatus()).thenReturn(issueStatus);
    when(issueType2.getName()).thenReturn("Feature");
    when(session.getIssuesWithFixVersion(JIRA_PRJ, JIRA_RELEASE, JiraCreateReleaseNotes.DEFAULT_FILTER)).thenReturn(Arrays.asList(issue1, issue2));
    BuildWrapper.Environment environment = jcrn.setUp(build, launcher, buildListener);
    Map<String, String> envVars = new HashMap<>();
    environment.buildEnvVars(envVars);
    String releaseNotes = envVars.get(jcrn.getJiraEnvironmentVariable());
    assertNotNull(releaseNotes);
    assertThat(releaseNotes, Matchers.containsString(issueType1.getName()));
    assertThat(releaseNotes, Matchers.containsString(issueType2.getName()));
    assertThat(releaseNotes, Matchers.not(Matchers.containsString("UNKNOWN")));
}
Also used : Status(com.atlassian.jira.rest.client.api.domain.Status) Issue(com.atlassian.jira.rest.client.api.domain.Issue) HashMap(java.util.HashMap) IssueType(com.atlassian.jira.rest.client.api.domain.IssueType) BuildWrapper(hudson.tasks.BuildWrapper) Test(org.junit.Test)

Aggregations

Status (com.atlassian.jira.rest.client.api.domain.Status)12 Issue (com.atlassian.jira.rest.client.api.domain.Issue)8 Test (org.junit.Test)5 WithoutJenkins (org.jvnet.hudson.test.WithoutJenkins)4 IssueType (com.atlassian.jira.rest.client.api.domain.IssueType)3 URI (java.net.URI)3 StatusCategory (com.atlassian.jira.rest.client.api.StatusCategory)2 Resolution (com.atlassian.jira.rest.client.api.domain.Resolution)2 Transition (com.atlassian.jira.rest.client.api.domain.Transition)2 IOException (java.io.IOException)2 IssueRestClient (com.atlassian.jira.rest.client.api.IssueRestClient)1 JiraRestClient (com.atlassian.jira.rest.client.api.JiraRestClient)1 JiraRestClientFactory (com.atlassian.jira.rest.client.api.JiraRestClientFactory)1 Attachment (com.atlassian.jira.rest.client.api.domain.Attachment)1 Component (com.atlassian.jira.rest.client.api.domain.Component)1 IssueField (com.atlassian.jira.rest.client.api.domain.IssueField)1 Subtask (com.atlassian.jira.rest.client.api.domain.Subtask)1 User (com.atlassian.jira.rest.client.api.domain.User)1 TransitionInput (com.atlassian.jira.rest.client.api.domain.input.TransitionInput)1 Config (com.bbva.arq.devops.ae.mirrorgate.collectors.jira.config.Config)1