mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 15:29:34 +01:00
fix(production): Review-Findings aus US-P17 beheben
RescheduleNotAllowed Error-Typ statt InvalidStatusTransition(status, status), Null-Guard für newDate, Controller-Parameter als Enum statt String (verhindert 500 bei ungültigem Status), partielle Datumsangaben als 400 ablehnen, ORDER BY in findAll() konsistent mit gefilterten Queries.
This commit is contained in:
parent
ad33eed2f4
commit
19f1cf16a1
8 changed files with 46 additions and 23 deletions
|
|
@ -109,7 +109,7 @@ class RescheduleProductionOrderTest {
|
|||
var result = rescheduleProductionOrder.execute(validCommand(), performedBy);
|
||||
|
||||
assertThat(result.isFailure()).isTrue();
|
||||
assertThat(result.unsafeGetError()).isInstanceOf(ProductionOrderError.InvalidStatusTransition.class);
|
||||
assertThat(result.unsafeGetError()).isInstanceOf(ProductionOrderError.RescheduleNotAllowed.class);
|
||||
verify(productionOrderRepository, never()).save(any());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -778,7 +778,7 @@ class ProductionOrderTest {
|
|||
var result = order.reschedule(LocalDate.now().plusDays(14));
|
||||
|
||||
assertThat(result.isFailure()).isTrue();
|
||||
var err = (ProductionOrderError.InvalidStatusTransition) result.unsafeGetError();
|
||||
var err = (ProductionOrderError.RescheduleNotAllowed) result.unsafeGetError();
|
||||
assertThat(err.current()).isEqualTo(ProductionOrderStatus.IN_PROGRESS);
|
||||
}
|
||||
|
||||
|
|
@ -790,7 +790,7 @@ class ProductionOrderTest {
|
|||
var result = order.reschedule(LocalDate.now().plusDays(14));
|
||||
|
||||
assertThat(result.isFailure()).isTrue();
|
||||
var err = (ProductionOrderError.InvalidStatusTransition) result.unsafeGetError();
|
||||
var err = (ProductionOrderError.RescheduleNotAllowed) result.unsafeGetError();
|
||||
assertThat(err.current()).isEqualTo(ProductionOrderStatus.COMPLETED);
|
||||
}
|
||||
|
||||
|
|
@ -802,10 +802,21 @@ class ProductionOrderTest {
|
|||
var result = order.reschedule(LocalDate.now().plusDays(14));
|
||||
|
||||
assertThat(result.isFailure()).isTrue();
|
||||
var err = (ProductionOrderError.InvalidStatusTransition) result.unsafeGetError();
|
||||
var err = (ProductionOrderError.RescheduleNotAllowed) result.unsafeGetError();
|
||||
assertThat(err.current()).isEqualTo(ProductionOrderStatus.CANCELLED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("should fail when newDate is null")
|
||||
void should_Fail_When_NewDateNull() {
|
||||
var order = orderWithStatus(ProductionOrderStatus.PLANNED);
|
||||
|
||||
var result = order.reschedule(null);
|
||||
|
||||
assertThat(result.isFailure()).isTrue();
|
||||
assertThat(result.unsafeGetError()).isInstanceOf(ProductionOrderError.ValidationFailure.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("should fail when new date is in the past")
|
||||
void should_Fail_When_DateInPast() {
|
||||
|
|
|
|||
|
|
@ -887,7 +887,7 @@ class ProductionOrderControllerIntegrationTest extends AbstractIntegrationTest {
|
|||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(json))
|
||||
.andExpect(status().isConflict())
|
||||
.andExpect(jsonPath("$.code").value("PRODUCTION_ORDER_INVALID_STATUS_TRANSITION"));
|
||||
.andExpect(jsonPath("$.code").value("PRODUCTION_ORDER_RESCHEDULE_NOT_ALLOWED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -928,7 +928,7 @@ class ProductionOrderControllerIntegrationTest extends AbstractIntegrationTest {
|
|||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(json))
|
||||
.andExpect(status().isConflict())
|
||||
.andExpect(jsonPath("$.code").value("PRODUCTION_ORDER_INVALID_STATUS_TRANSITION"));
|
||||
.andExpect(jsonPath("$.code").value("PRODUCTION_ORDER_RESCHEDULE_NOT_ALLOWED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -955,7 +955,7 @@ class ProductionOrderControllerIntegrationTest extends AbstractIntegrationTest {
|
|||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(json))
|
||||
.andExpect(status().isConflict())
|
||||
.andExpect(jsonPath("$.code").value("PRODUCTION_ORDER_INVALID_STATUS_TRANSITION"));
|
||||
.andExpect(jsonPath("$.code").value("PRODUCTION_ORDER_RESCHEDULE_NOT_ALLOWED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1078,15 +1078,12 @@ class ProductionOrderControllerIntegrationTest extends AbstractIntegrationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Nur dateFrom ohne dateTo → alle auflisten (kein Range-Filter)")
|
||||
void listWithOnlyDateFrom_returnsAll() throws Exception {
|
||||
createPlannedOrder();
|
||||
|
||||
@DisplayName("Nur dateFrom ohne dateTo → 400 Bad Request")
|
||||
void listWithOnlyDateFrom_returns400() throws Exception {
|
||||
mockMvc.perform(get("/api/production/production-orders")
|
||||
.param("dateFrom", LocalDate.now().toString())
|
||||
.header("Authorization", "Bearer " + adminToken))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.length()").value(org.hamcrest.Matchers.greaterThanOrEqualTo(1)));
|
||||
.andExpect(status().isBadRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue