Skip to content

Commit

Permalink
use v2 for quarter url and update tests accoridingly
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Oct 21, 2024
1 parent 7633a86 commit bf8dade
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.List;

@RestController
@RequestMapping("api/v1/quarters")
@RequestMapping("api/v2/quarters")
public class QuarterController {

private final QuarterBusinessService quarterBusinessService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class QuarterControllerIT {
void shouldGetAllQuarters() throws Exception {
BDDMockito.given(quarterBusinessService.getQuarters()).willReturn(quaterList);

mvc.perform(get("/api/v1/quarters").contentType(MediaType.APPLICATION_JSON))
mvc.perform(get("/api/v2/quarters").contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$", Matchers.hasSize(3)))
.andExpect(jsonPath("$[0].id", Is.is(1))).andExpect(jsonPath("$[0].label", Is.is("GJ 22/23-Q2")))
.andExpect(jsonPath("$[0].startDate", Is.is(LocalDate.of(2022, 9, 1).toString())))
Expand All @@ -65,13 +65,13 @@ void shouldGetAllQuarters() throws Exception {
void shouldGetAllTeamsIfNoTeamsExists() throws Exception {
BDDMockito.given(quarterBusinessService.getQuarters()).willReturn(Collections.emptyList());

mvc.perform(get("/api/v1/quarters").contentType(MediaType.APPLICATION_JSON))
mvc.perform(get("/api/v2/quarters").contentType(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk()).andExpect(jsonPath("$", Matchers.hasSize(0)));
}

@Test
void shouldCallCurrentQuarterAfterRequest() throws Exception {
mvc.perform(get("/api/v1/quarters/current").contentType(MediaType.APPLICATION_JSON));
mvc.perform(get("/api/v2/quarters/current").contentType(MediaType.APPLICATION_JSON));

BDDMockito.verify(quarterBusinessService, Mockito.times(1)).getCurrentQuarter();
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/services/quarter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class QuarterService {

getAllQuarters(): Observable<Quarter[]> {
return this.http
.get<Quarter[]>('/api/v1/quarters')
.get<Quarter[]>('/api/v2/quarters')
.pipe(
map((quarters) =>
quarters.map((quarter) => new Quarter(quarter.id, quarter.label, quarter.startDate, quarter.endDate)),
Expand All @@ -20,6 +20,6 @@ export class QuarterService {
}

getCurrentQuarter(): Observable<Quarter> {
return this.http.get<Quarter>('/api/v1/quarters/current');
return this.http.get<Quarter>('/api/v2/quarters/current');
}
}

0 comments on commit bf8dade

Please sign in to comment.