Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
43 changes: 43 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: PR Check

on:
pull_request:
branches: [ "**" ]

jobs:
spotless:
name: Code Style Spotless Check
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
cache: maven

- name: Run spotless plugin check
run: ./mvnw --no-transfer-progress spotless:check

verify:
name: Maven Build & Test
needs: spotless
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
cache: maven

- name: Run mvn verify
run: ./mvnw --no-transfer-progress verify
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.sivalabs.ft.features.api.controllers;

import com.sivalabs.ft.features.api.models.PagedResult;
import com.sivalabs.ft.features.domain.FeatureService;
import com.sivalabs.ft.features.domain.PlanningHistoryService;
import com.sivalabs.ft.features.domain.ReleaseService;
import com.sivalabs.ft.features.domain.dtos.PlanningHistoryDto;
import com.sivalabs.ft.features.domain.exceptions.ResourceNotFoundException;
import com.sivalabs.ft.features.domain.models.ChangeType;
import com.sivalabs.ft.features.domain.models.EntityType;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -17,9 +20,16 @@
@Tag(name = "Planning History API")
class PlanningHistoryController {
private final PlanningHistoryService planningHistoryService;
private final FeatureService featureService;
private final ReleaseService releaseService;

PlanningHistoryController(PlanningHistoryService planningHistoryService) {
PlanningHistoryController(
PlanningHistoryService planningHistoryService,
FeatureService featureService,
ReleaseService releaseService) {
this.planningHistoryService = planningHistoryService;
this.featureService = featureService;
this.releaseService = releaseService;
}

@GetMapping("/api/planning-history")
Expand All @@ -45,6 +55,9 @@ PagedResult<PlanningHistoryDto> getReleaseHistory(
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "20") int size,
@RequestParam(required = false) String sort) {
if (!releaseService.isReleaseExists(code)) {
throw new ResourceNotFoundException("Release with code " + code + " not found");
}
return PagedResult.from(
planningHistoryService.findHistory(EntityType.RELEASE, code, null, null, null, null, page, size, sort));
}
Expand All @@ -56,6 +69,9 @@ PagedResult<PlanningHistoryDto> getFeatureHistory(
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "20") int size,
@RequestParam(required = false) String sort) {
if (!featureService.isFeatureExists(code)) {
throw new ResourceNotFoundException("Feature with code " + code + " not found");
}
return PagedResult.from(
planningHistoryService.findHistory(EntityType.FEATURE, code, null, null, null, null, page, size, sort));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,17 @@ void shouldGetReleaseHistory() {
}

@Test
void shouldReturnEmptyHistoryForUnknownCode() {
void shouldReturn404ForUnknownFeatureCode() {
var result =
mvc.get().uri("/api/features/{code}/history", "UNKNOWN-999").exchange();
assertThat(result).hasStatusOk();
assertThat(result)
.bodyJson()
.extractingPath("$.totalElements")
.asNumber()
.extracting(Number::intValue)
.satisfies(n -> assertThat(n).isEqualTo(0));
assertThat(result).hasStatus(HttpStatus.NOT_FOUND);
}

@Test
void shouldReturn404ForUnknownReleaseCode() {
var result =
mvc.get().uri("/api/releases/{code}/history", "UNKNOWN-666").exchange();
assertThat(result).hasStatus(HttpStatus.NOT_FOUND);
}

@Test
Expand Down
Loading