Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adm 574 #636

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions backend/src/main/java/heartbeat/service/board/jira/JiraService.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package heartbeat.service.board.jira;

import heartbeat.exception.BaseException;
import heartbeat.exception.InternalServerErrorException;

import static java.lang.Long.parseLong;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
Expand All @@ -21,9 +14,9 @@
import heartbeat.client.dto.board.jira.HistoryDetail;
import heartbeat.client.dto.board.jira.IssueField;
import heartbeat.client.dto.board.jira.Issuetype;
import heartbeat.client.dto.board.jira.JiraCardWithFields;
import heartbeat.client.dto.board.jira.JiraBoardConfigDTO;
import heartbeat.client.dto.board.jira.JiraCard;
import heartbeat.client.dto.board.jira.JiraCardWithFields;
import heartbeat.client.dto.board.jira.JiraColumn;
import heartbeat.client.dto.board.jira.Sprint;
import heartbeat.client.dto.board.jira.StatusSelfDTO;
Expand All @@ -45,9 +38,15 @@
import heartbeat.controller.board.dto.response.StepsDay;
import heartbeat.controller.board.dto.response.TargetField;
import heartbeat.exception.BadRequestException;
import heartbeat.exception.BaseException;
import heartbeat.exception.InternalServerErrorException;
import heartbeat.exception.NoContentException;
import heartbeat.util.BoardUtil;
import jakarta.annotation.PreDestroy;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

import java.net.URI;
import java.util.ArrayList;
Expand All @@ -65,10 +64,9 @@
import java.util.stream.IntStream;
import java.util.stream.Stream;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import static java.lang.Long.parseLong;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -274,7 +272,8 @@ private JiraCardWithFields getAllDoneCards(BoardType boardType, URI baseUrl, Lis
private JiraCardWithFields getAllCards(BoardType boardType, URI baseUrl, BoardRequestParam boardRequestParam) {
String jql;
if (BoardType.JIRA.equals(boardType) || BoardType.CLASSIC_JIRA.equals(boardType)) {
jql = "sprint in openSprints()";
jql = String.format("status changed during (%s, %s)", boardRequestParam.getStartTime(),
boardRequestParam.getEndTime());
}
else {
throw new BadRequestException("boardType param is not correct");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class JiraServiceTest {

private final BoardType boardTypeClassicJira = BoardType.fromValue("classic-jira");

private static final String ALL_CARDS_JQL = "status changed during (%s, %s)";

@Mock
JiraFeignClient jiraFeignClient;

Expand Down Expand Up @@ -126,7 +128,7 @@ void shouldCallJiraFeignClientAndReturnBoardConfigResponseWhenGetJiraBoardConfig
URI baseUrl = URI.create(SITE_ATLASSIAN_NET);
String token = "token";
BoardRequestParam boardRequestParam = BOARD_REQUEST_BUILDER().build();
String jql = "sprint in openSprints()";
String jql = String.format(ALL_CARDS_JQL, boardRequestParam.getStartTime(), boardRequestParam.getEndTime());
List<TargetField> expectTargetField = List.of(
new TargetField("customfield_10016", "Story point estimate", false),
new TargetField("customfield_10020", "Sprint", false),
Expand Down Expand Up @@ -167,7 +169,7 @@ void shouldCallJiraFeignClientAndReturnBoardConfigResponseWhenGetJiraBoardConfig
URI baseUrl = URI.create(SITE_ATLASSIAN_NET);
String token = "token";
BoardRequestParam boardRequestParam = BOARD_REQUEST_BUILDER().build();
String jql = "sprint in openSprints()";
String jql = String.format(ALL_CARDS_JQL, boardRequestParam.getStartTime(), boardRequestParam.getEndTime());
List<TargetField> expectTargetField = List.of(
new TargetField("customfield_10016", "Story point estimate", false),
new TargetField("customfield_10020", "Sprint", false),
Expand Down Expand Up @@ -208,7 +210,7 @@ void shouldCallJiraFeignClientAndReturnBoardConfigResponseWhenGetClassicJiraBoar
URI baseUrl = URI.create(SITE_ATLASSIAN_NET);
String token = "token";
BoardRequestParam boardRequestParam = BOARD_REQUEST_BUILDER().build();
String jql = "sprint in openSprints()";
String jql = String.format(ALL_CARDS_JQL, boardRequestParam.getStartTime(), boardRequestParam.getEndTime());
List<TargetField> expectTargetField = List.of(
new TargetField("customfield_10016", "Story point estimate", false),
new TargetField("customfield_10020", "Sprint", false),
Expand Down Expand Up @@ -267,7 +269,7 @@ void shouldCallJiraFeignClientAndThrowNonContentCodeWhenGetJiraBoardConfig() thr
URI baseUrl = URI.create(SITE_ATLASSIAN_NET);
String token = "token";
BoardRequestParam boardRequestParam = BOARD_REQUEST_BUILDER().build();
String jql = "sprint in openSprints()";
String jql = String.format(ALL_CARDS_JQL, boardRequestParam.getStartTime(), boardRequestParam.getEndTime());

when(urlGenerator.getUri(any())).thenReturn(URI.create(SITE_ATLASSIAN_NET));
doReturn(jiraBoardConfigDTO).when(jiraFeignClient).getJiraBoardConfiguration(baseUrl, BOARD_ID, token);
Expand Down Expand Up @@ -325,7 +327,7 @@ void shouldReturnAssigneeNameFromDoneCardWhenGetAssigneeSet() throws JsonProcess
URI baseUrl = URI.create(SITE_ATLASSIAN_NET);
String token = "token";
BoardRequestParam boardRequestParam = BOARD_REQUEST_BUILDER().build();
String jql = "sprint in openSprints()";
String jql = String.format(ALL_CARDS_JQL, boardRequestParam.getStartTime(), boardRequestParam.getEndTime());
String allDoneCards = objectMapper.writeValueAsString(ALL_DONE_CARDS_RESPONSE_FOR_STORY_POINT_BUILDER().build())
.replaceAll("storyPoints", "customfield_10016");

Expand Down
Loading