#104 setUp fields

This commit is contained in:
Nightblade73 2019-05-14 16:20:19 +04:00
parent 9da5fd8a7a
commit 3a9fde3404

View File

@ -1,5 +1,6 @@
package conference.module_test;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@ -8,10 +9,17 @@ 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.model.ConferenceDto;
import ru.ulstu.conference.repository.ConferenceRepository;
import ru.ulstu.conference.service.ConferenceService;
import ru.ulstu.conference.service.ConferenceUserService;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.deadline.service.DeadlineService;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.paper.service.PaperService;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static org.junit.Assert.assertEquals;
@ -22,16 +30,60 @@ public class ConferenceServiceTest {
@Mock
ConferenceRepository conferenceRepository;
@Mock
DeadlineService deadlineService;
@Mock
ConferenceUserService conferenceUserService;
@Mock
PaperService paperService;
@InjectMocks
ConferenceService conferenceService;
private List<Conference> conferences;
private List<Deadline> deadlines;
private Conference conference;
private Paper paperWithId;
private Paper paperWithoutId;
private Deadline deadline;
private ConferenceDto conferenceDto;
@Before
public void setUp() throws Exception {
conferences = new ArrayList<>();
conference = new Conference();
conference.setId(1);
conference.setTitle("Название");
conference.setDescription("Описание");
conferences.add(conference);
conferenceDto = new ConferenceDto(conference);
paperWithId = new Paper();
paperWithId.setId(1);
paperWithId.setTitle("paperTitle");
paperWithoutId = new Paper();
paperWithoutId.setTitle("paperTitleNoId");
deadlines = new ArrayList<>();
deadline = new Deadline(new Date(),"desc");
deadline.setId(1);
deadlines.add(deadline);
}
@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());
}
@Test
public void testCopyFromDto() {
}
}