Search in sources :

Example 1 with SprintDTO

use of com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO in project mirrorgate-jira-stories-collector by BBVA.

the class SprintParserTests method itShouldNotResturnSprintWhenDoesntMatch.

@Test
public void itShouldNotResturnSprintWhenDoesntMatch() {
    String in = "someother.class@20d5ab81[id=1003]";
    SprintDTO out = issueUtils.parseSprint(in);
    assertEquals(out, null);
}
Also used : SprintDTO(com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 2 with SprintDTO

use of com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO in project mirrorgate-jira-stories-collector by BBVA.

the class Main method run.

@Scheduled(cron = "${scheduler.cron}")
public void run() {
    LOGGER.info("Starting");
    iterateAndSave(service.getRecentIssues(), true);
    for (SprintDTO s : getSprintsThatNeedUpdating()) {
        SprintDTO sprint = sprintApi.getSprint(s.getId());
        if (sprint != null && sprint.getIssues() != null) {
            List<Long> ids = sprint.getIssues().stream().map(IssueDTO::getId).collect(Collectors.toList());
            iterateAndSave(getIssuesByIdAndDeleteNotPresent(ids), false);
        } else {
            LOGGER.warn("-> Could not update the sprint " + s.getName());
        }
    }
    LOGGER.info("Ending");
}
Also used : SprintDTO(com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 3 with SprintDTO

use of com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO in project mirrorgate-jira-stories-collector by BBVA.

the class Main method getSprintsThatNeedUpdating.

private List<SprintDTO> getSprintsThatNeedUpdating() {
    final List<SprintDTO> sprints = sprintApi.getSprintSamples();
    final List<Long> ids = new ArrayList<>();
    final Map<Long, SprintDTO> idToSprint = new HashMap<>(ids.size() * 2);
    sprints.forEach((s) -> {
        for (IssueDTO issue : s.getIssues()) {
            idToSprint.put(issue.getId(), s);
            ids.add(issue.getId());
        }
    });
    Pageable<IssueDTO> samples = getIssuesByIdAndDeleteNotPresent(ids);
    List<SprintDTO> toUpdate = new ArrayList<>();
    List<IssueDTO> issues;
    while ((issues = samples.nextPage()).size() > 0) {
        LOGGER.info("-> Checking " + issues.get(0));
        issues.forEach((i) -> {
            SprintDTO current = i.getSprint();
            if (current == null) {
                toUpdate.add(idToSprint.get(i.getId()));
            } else if (!current.equals(idToSprint.get(i.getId()))) {
                toUpdate.add(i.getSprint());
            }
        });
    }
    LOGGER.info("-> Needs updating: " + toUpdate);
    return toUpdate;
}
Also used : IssueDTO(com.bbva.arq.devops.ae.mirrorgate.core.dto.IssueDTO) SprintDTO(com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO)

Example 4 with SprintDTO

use of com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO in project mirrorgate-jira-stories-collector by BBVA.

the class JiraIssueUtils method parseSprint.

public SprintDTO parseSprint(String data) {
    if (data == null || !data.startsWith("com.atlassian.greenhopper.service.sprint.Sprint")) {
        return null;
    }
    Matcher match = Pattern.compile("([^=\\[,]*)=([^,\\]]*)").matcher(data);
    Map<String, String> fieldsAndValue = new HashMap<>();
    while (match.find()) {
        fieldsAndValue.put(match.group(1), match.group(2));
    }
    return new SprintDTO().setId(fieldsAndValue.get("id")).setStatus(parse(fieldsAndValue.get("state"), SprintStatus.class)).setName(fieldsAndValue.get("name")).setStartDate(parse(fieldsAndValue.get("startDate"), Date.class)).setEndDate(parse(fieldsAndValue.get("endDate"), Date.class)).setCompleteDate(parse(fieldsAndValue.get("completeDate"), Date.class));
}
Also used : Matcher(java.util.regex.Matcher) SprintDTO(com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO) SprintStatus(com.bbva.arq.devops.ae.mirrorgate.core.utils.SprintStatus)

Example 5 with SprintDTO

use of com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO in project mirrorgate-jira-stories-collector by BBVA.

the class SprintParserTests method itShouldParseSprintsCorrectly.

@Test
public void itShouldParseSprintsCorrectly() {
    String in = "com.atlassian.greenhopper.service.sprint.Sprint@20d5ab81[id=1003,rapidViewId=879,state=CLOSED,name=SOME_SPRINT,startDate=2017-02-22T07:00:27.314+01:00,endDate=2017-03-07T19:00:00.000+01:00,completeDate=2017-03-08T10:29:26.122+01:00,sequence=1003]";
    SprintDTO out = issueUtils.parseSprint(in);
    assertEquals(out.getId(), "1003");
    assertEquals(out.getStatus(), SprintStatus.CLOSED);
    assertEquals(out.getName(), "SOME_SPRINT");
    assertEquals(out.getStartDate(), DateTime.parse("2017-02-22T07:00:27.314+01:00").toDate());
    assertEquals(out.getEndDate(), DateTime.parse("2017-03-07T19:00:00.000+01:00").toDate());
    assertEquals(out.getCompleteDate(), DateTime.parse("2017-03-08T10:29:26.122+01:00").toDate());
}
Also used : SprintDTO(com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

SprintDTO (com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO)6 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 IssueDTO (com.bbva.arq.devops.ae.mirrorgate.core.dto.IssueDTO)1 SprintStatus (com.bbva.arq.devops.ae.mirrorgate.core.utils.SprintStatus)1 Matcher (java.util.regex.Matcher)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1