Skip to content

Commit

Permalink
[Fix #65] Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kostobog committed Mar 12, 2024
1 parent 3c4087e commit 3798901
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3798901

Please sign in to comment.