@ -21,24 +21,25 @@ import static org.mockito.Mockito.when;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
class EventServiceTest {
|
||||
|
||||
private EventRepository eventRepository;
|
||||
private EventService eventService;
|
||||
private EventRepository eventRepositoryMock = mock(EventRepository.class);
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
eventService = new EventService(mock(JsonService.class), eventRepositoryMock);
|
||||
eventRepository = mock(EventRepository.class);
|
||||
eventService = new EventService(mock(JsonService.class), eventRepository);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMaxID() {
|
||||
when(eventRepositoryMock.getHighesEvent_ID()).thenReturn(42L);
|
||||
when(eventRepository.getHighesEvent_ID()).thenReturn(42L);
|
||||
|
||||
assertEquals(eventService.getMaxEvent_id(), 42L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkGroupReturnNextValue() {
|
||||
when(eventRepositoryMock.getMaxGroupID()).thenReturn(2L);
|
||||
when(eventRepository.getMaxGroupID()).thenReturn(2L);
|
||||
|
||||
assertEquals(eventService.checkGroup(), 3L);
|
||||
}
|
||||
@ -46,7 +47,7 @@ class EventServiceTest {
|
||||
@Test
|
||||
void checkGroupReturnOneIfDBIsEmpty() {
|
||||
List<EventDTO> eventDTOS = new ArrayList<>();
|
||||
when(eventRepositoryMock.findAll()).thenReturn(eventDTOS);
|
||||
when(eventRepository.findAll()).thenReturn(eventDTOS);
|
||||
|
||||
assertEquals(eventService.checkGroup(), 1);
|
||||
}
|
||||
|
||||
@ -5,12 +5,9 @@ import mops.gruppen2.domain.GroupType;
|
||||
import mops.gruppen2.domain.Visibility;
|
||||
import mops.gruppen2.domain.event.AddUserEvent;
|
||||
import mops.gruppen2.domain.event.CreateGroupEvent;
|
||||
import mops.gruppen2.domain.event.DeleteGroupEvent;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.repository.EventRepository;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -20,23 +17,23 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
class GroupServiceTest {
|
||||
GroupService groupService;
|
||||
EventRepository eventRepository;
|
||||
|
||||
private GroupService groupService;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
groupService = new GroupService(mock(EventService.class), eventRepository);
|
||||
void setUp() {
|
||||
groupService = new GroupService(mock(EventService.class), mock(EventRepository.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void rightClassForSucsessfulGroup() throws Exception {
|
||||
void rightClassForSuccessfulGroup() throws Exception {
|
||||
List<Event> eventList = new ArrayList<>();
|
||||
|
||||
eventList.add(new CreateGroupEvent(1L, "Prof", null, GroupType.LECTURE, Visibility.PRIVATE));
|
||||
|
||||
eventList.add(new AddUserEvent(1L, "Ulli", "Ulli", "Honnis", "FC@B.de"));
|
||||
|
||||
assertThat(groupService.projectEventList(eventList).get(0)).isInstanceOf(Group.class);
|
||||
List<Group> groups = groupService.projectEventList(eventList);
|
||||
|
||||
assertThat(groups.get(0)).isInstanceOf(Group.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user