This commit is contained in:
2026-05-17 19:23:06 +02:00
commit 75a3390ef4
36 changed files with 2035 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
package integration;
import model.Amount;
import model.TaskDTO;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class RepairTaskCatalogTest {
private RepairTaskCatalog catalog;
@BeforeEach
void setUp() {
catalog = new RepairTaskCatalog();
}
@Test
void findTaskWithExistingNameReturnsTaskDTO() throws TaskNotFoundException {
TaskDTO task = catalog.findTask("Brake Pad Replacement");
assertNotNull(task);
}
@Test
void findTaskWithExistingNameReturnsCorrectCost() throws TaskNotFoundException {
TaskDTO task = catalog.findTask("Battery Check");
assertEquals(200.0, task.getCost().getValue(), 0.001);
}
@Test
void findTaskWithAllFourSampleTasksReturnsNonNull() throws TaskNotFoundException {
assertNotNull(catalog.findTask("Brake Pad Replacement"));
assertNotNull(catalog.findTask("Tire Replacement"));
assertNotNull(catalog.findTask("Battery Check"));
assertNotNull(catalog.findTask("Chain Lubrication"));
}
@Test
void findTaskWithUnknownNameThrowsTaskNotFoundException() {
assertThrows(TaskNotFoundException.class,
() -> catalog.findTask("Rocket Booster Installation"));
}
@Test
void thrownTaskNotFoundExceptionContainsCorrectTaskName() {
TaskNotFoundException ex = assertThrows(TaskNotFoundException.class,
() -> catalog.findTask("Unknown Task"));
assertEquals("Unknown Task", ex.getTaskName());
}
@Test
void thrownTaskNotFoundExceptionMessageMentionsTaskName() {
TaskNotFoundException ex = assertThrows(TaskNotFoundException.class,
() -> catalog.findTask("Unknown Task"));
assertTrue(ex.getMessage().contains("Unknown Task"));
}
}