#104 shock, the first unit test works
This commit is contained in:
parent
ff7f535980
commit
9da5fd8a7a
@ -1,6 +1,7 @@
|
|||||||
package ru.ulstu.conference.service;
|
package ru.ulstu.conference.service;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -43,6 +44,7 @@ public class ConferenceService {
|
|||||||
private final ConferenceNotificationService conferenceNotificationService;
|
private final ConferenceNotificationService conferenceNotificationService;
|
||||||
private final EventService eventService;
|
private final EventService eventService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
public ConferenceService(ConferenceRepository conferenceRepository,
|
public ConferenceService(ConferenceRepository conferenceRepository,
|
||||||
ConferenceUserService conferenceUserService,
|
ConferenceUserService conferenceUserService,
|
||||||
DeadlineService deadlineService,
|
DeadlineService deadlineService,
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package conference.module_test;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import ru.ulstu.conference.model.Conference;
|
||||||
|
import ru.ulstu.conference.repository.ConferenceRepository;
|
||||||
|
import ru.ulstu.conference.service.ConferenceService;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
|
public class ConferenceServiceTest {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
ConferenceRepository conferenceRepository;
|
||||||
|
|
||||||
|
@InjectMocks
|
||||||
|
ConferenceService conferenceService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFindAllConferences() {
|
||||||
|
List<Conference> conferences = new ArrayList<>();
|
||||||
|
Conference conference = new Conference();
|
||||||
|
conference.setId(1);
|
||||||
|
conferences.add(conference);
|
||||||
|
Mockito.when(conferenceRepository.findAll(new Sort(Sort.Direction.DESC, "beginDate"))).thenReturn(conferences);
|
||||||
|
assertEquals(conferences, conferenceService.findAll());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user