Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions testing/src/test/java/at/test/drm/RelationServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
import java.util.List;
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;

@ExtendWith(MockitoExtension.class)
public class RelationServiceTest {
Expand All @@ -32,11 +35,15 @@ public class RelationServiceTest {
void createRelation() {
Mockito.when(relationDaoFactory.getDaoFromSourceObjectClass(any(Class.class)))
.thenReturn(personEntityRelationDao);
Mockito.when(personEntityRelationDao.save(any()))
.thenReturn(new PersonEntityRelation());
PersonEntity PersonEntity = new PersonEntity();
PersonEntity.setId(1L);
DogEntity DogEntity = new DogEntity();
DogEntity.setId(1L);
relationService.createRelation(PersonEntity, DogEntity);
RelationLink result = relationService.createRelation(PersonEntity, DogEntity);

assertThat(result).isNotNull();
}

@Test
Expand All @@ -46,6 +53,8 @@ void deleteRelation() {
PersonEntityRelation personEntityRelation = new PersonEntityRelation();
personEntityRelation.setSourceObject(new PersonEntity());
relationService.deleteRelation(personEntityRelation);

verify(personEntityRelationDao, times(1)).delete(personEntityRelation);
}

@Test
Expand All @@ -55,6 +64,8 @@ void findRelationBySourceObject() {
PersonEntity PersonEntity = new PersonEntity();
PersonEntity.setId(1L);
List<RelationLink> relationBySourceObject = relationService.findRelationBySourceObject(PersonEntity);

assertThat(relationBySourceObject).isNotNull();
}

@Test
Expand All @@ -64,6 +75,8 @@ void findRelationByTargetRelationIdentity() {
PersonEntity PersonEntity = new PersonEntity();
PersonEntity.setId(1L);
Set<RelationLink> relationByTargetRelationIdentity = relationService.findRelationByTargetRelationIdentity(PersonEntity);

assertThat(relationByTargetRelationIdentity).isNotNull();
}

}
}
Loading