59 lines
1.8 KiB
Java
59 lines
1.8 KiB
Java
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"));
|
|
}
|
|
}
|