From 3798901afc8dacc13c15105400a2c806879544be Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Tue, 12 Mar 2024 09:04:17 +0100 Subject: [PATCH] [Fix #65] Refactor tests --- .../analysis/service/ComponentRepositoryServiceTest.java | 4 +++- .../analysis/service/FaultEventRepositoryServiceTest.java | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/java/cz/cvut/kbss/analysis/service/ComponentRepositoryServiceTest.java b/src/test/java/cz/cvut/kbss/analysis/service/ComponentRepositoryServiceTest.java index 8a0b5468..5fe1154c 100755 --- a/src/test/java/cz/cvut/kbss/analysis/service/ComponentRepositoryServiceTest.java +++ b/src/test/java/cz/cvut/kbss/analysis/service/ComponentRepositoryServiceTest.java @@ -134,7 +134,9 @@ void linkComponents_shouldFindComponents_shouldSetParentComponent_shouldCallUpda void linkComponents_shouldFindComponent_shouldSetParentNull_shouldCallUpdate() { Component component = new Component(); component.setUri(Generator.generateUri()); - component.setParentComponent(Generator.generateUri()); + Component parent = new Component(); + parent.setUri(Generator.generateUri()); + component.setParentComponent(parent); Mockito.when(componentDao.find(eq(component.getUri()))).thenReturn(Optional.of(component)); Mockito.when(componentDao.exists(eq(component.getUri()))).thenReturn(true); diff --git a/src/test/java/cz/cvut/kbss/analysis/service/FaultEventRepositoryServiceTest.java b/src/test/java/cz/cvut/kbss/analysis/service/FaultEventRepositoryServiceTest.java index 552d5992..4267acc2 100755 --- a/src/test/java/cz/cvut/kbss/analysis/service/FaultEventRepositoryServiceTest.java +++ b/src/test/java/cz/cvut/kbss/analysis/service/FaultEventRepositoryServiceTest.java @@ -16,7 +16,6 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import java.net.URI; import java.util.Optional; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -131,10 +130,10 @@ void addFailureMode_shouldSetData_shouldUpdateEvent() { failureMode.setUri(Generator.generateUri()); Component component = new Component(); component.setUri(Generator.generateUri()); - failureMode.setComponent(component); + failureMode.setItem(component); Mockito.when(faultEventDao.find(eq(event.getUri()))).thenReturn(Optional.of(event)); - Mockito.when(componentRepositoryService.findRequired(eq(failureMode.getComponent().getUri()))).thenReturn(component); + Mockito.when(componentRepositoryService.findRequired(eq(failureMode.getItem().getUri()))).thenReturn(component); Mockito.when(faultEventDao.exists(event.getUri())).thenReturn(true); Mockito.when(faultEventValidator.supports(any())).thenReturn(true); Mockito.when(faultEventDao.update(eq(event))).thenReturn(event);