From 3a9fde3404bd3422dabde9a2a5459508bd043765 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Tue, 14 May 2019 16:20:19 +0400 Subject: [PATCH] #104 setUp fields --- .../module_test/ConferenceServiceTest.java | 60 +++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/src/test/java/conference/module_test/ConferenceServiceTest.java b/src/test/java/conference/module_test/ConferenceServiceTest.java index 44c92ea..de83ae7 100644 --- a/src/test/java/conference/module_test/ConferenceServiceTest.java +++ b/src/test/java/conference/module_test/ConferenceServiceTest.java @@ -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 conferences; + private List 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 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() { + + + } }