|
|
@ -11,12 +11,14 @@ import ru.ulstu.conference.model.Conference;
|
|
|
|
import ru.ulstu.conference.model.ConferenceDto;
|
|
|
|
import ru.ulstu.conference.model.ConferenceDto;
|
|
|
|
import ru.ulstu.conference.model.ConferenceUser;
|
|
|
|
import ru.ulstu.conference.model.ConferenceUser;
|
|
|
|
import ru.ulstu.conference.repository.ConferenceRepository;
|
|
|
|
import ru.ulstu.conference.repository.ConferenceRepository;
|
|
|
|
|
|
|
|
import ru.ulstu.conference.service.ConferenceNotificationService;
|
|
|
|
import ru.ulstu.conference.service.ConferenceService;
|
|
|
|
import ru.ulstu.conference.service.ConferenceService;
|
|
|
|
import ru.ulstu.conference.service.ConferenceUserService;
|
|
|
|
import ru.ulstu.conference.service.ConferenceUserService;
|
|
|
|
import ru.ulstu.deadline.model.Deadline;
|
|
|
|
import ru.ulstu.deadline.model.Deadline;
|
|
|
|
import ru.ulstu.deadline.service.DeadlineService;
|
|
|
|
import ru.ulstu.deadline.service.DeadlineService;
|
|
|
|
import ru.ulstu.paper.model.Paper;
|
|
|
|
import ru.ulstu.paper.model.Paper;
|
|
|
|
import ru.ulstu.paper.service.PaperService;
|
|
|
|
import ru.ulstu.paper.service.PaperService;
|
|
|
|
|
|
|
|
import ru.ulstu.timeline.service.EventService;
|
|
|
|
import ru.ulstu.user.model.User;
|
|
|
|
import ru.ulstu.user.model.User;
|
|
|
|
import ru.ulstu.user.service.UserService;
|
|
|
|
import ru.ulstu.user.service.UserService;
|
|
|
|
|
|
|
|
|
|
|
@ -26,6 +28,7 @@ import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertNull;
|
|
|
|
import static org.mockito.Mockito.when;
|
|
|
|
import static org.mockito.Mockito.when;
|
|
|
|
|
|
|
|
|
|
|
|
@RunWith(MockitoJUnitRunner.class)
|
|
|
|
@RunWith(MockitoJUnitRunner.class)
|
|
|
@ -46,6 +49,12 @@ public class ConferenceServiceTest {
|
|
|
|
@Mock
|
|
|
|
@Mock
|
|
|
|
UserService userService;
|
|
|
|
UserService userService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
|
|
|
ConferenceNotificationService conferenceNotificationService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
|
|
|
EventService eventService;
|
|
|
|
|
|
|
|
|
|
|
|
@InjectMocks
|
|
|
|
@InjectMocks
|
|
|
|
ConferenceService conferenceService;
|
|
|
|
ConferenceService conferenceService;
|
|
|
|
|
|
|
|
|
|
|
@ -53,7 +62,9 @@ public class ConferenceServiceTest {
|
|
|
|
private List<Deadline> deadlines;
|
|
|
|
private List<Deadline> deadlines;
|
|
|
|
private List<Paper> papers;
|
|
|
|
private List<Paper> papers;
|
|
|
|
private List<ConferenceUser> conferenceUsers;
|
|
|
|
private List<ConferenceUser> conferenceUsers;
|
|
|
|
private Conference conference;
|
|
|
|
|
|
|
|
|
|
|
|
private Conference conferenceWithId;
|
|
|
|
|
|
|
|
private Conference conferenceWithoutId;
|
|
|
|
private ConferenceUser conferenceUser;
|
|
|
|
private ConferenceUser conferenceUser;
|
|
|
|
|
|
|
|
|
|
|
|
private Paper paperWithId;
|
|
|
|
private Paper paperWithId;
|
|
|
@ -66,10 +77,15 @@ public class ConferenceServiceTest {
|
|
|
|
@Before
|
|
|
|
@Before
|
|
|
|
public void setUp() throws Exception {
|
|
|
|
public void setUp() throws Exception {
|
|
|
|
conferences = new ArrayList<>();
|
|
|
|
conferences = new ArrayList<>();
|
|
|
|
conference = new Conference();
|
|
|
|
conferenceWithId = new Conference();
|
|
|
|
|
|
|
|
conferenceWithoutId = new Conference();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conferenceWithId.setId(1);
|
|
|
|
|
|
|
|
conferenceWithId.setTitle("Название");
|
|
|
|
|
|
|
|
conferenceWithId.setDescription("Описание");
|
|
|
|
|
|
|
|
|
|
|
|
conference.setTitle("Название");
|
|
|
|
conferenceWithoutId.setTitle("Название");
|
|
|
|
conference.setDescription("Описание");
|
|
|
|
conferenceWithoutId.setDescription("Описание");
|
|
|
|
|
|
|
|
|
|
|
|
paperWithId = new Paper();
|
|
|
|
paperWithId = new Paper();
|
|
|
|
paperWithId.setId(1);
|
|
|
|
paperWithId.setId(1);
|
|
|
@ -97,12 +113,16 @@ public class ConferenceServiceTest {
|
|
|
|
conferenceUsers = new ArrayList<>();
|
|
|
|
conferenceUsers = new ArrayList<>();
|
|
|
|
conferenceUsers.add(conferenceUser);
|
|
|
|
conferenceUsers.add(conferenceUser);
|
|
|
|
|
|
|
|
|
|
|
|
conference.setPapers(papers);
|
|
|
|
conferenceWithId.setPapers(papers);
|
|
|
|
conference.setDeadlines(deadlines);
|
|
|
|
conferenceWithId.setDeadlines(deadlines);
|
|
|
|
conference.setUsers(conferenceUsers);
|
|
|
|
conferenceWithId.setUsers(conferenceUsers);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conferenceWithoutId.setPapers(papers);
|
|
|
|
|
|
|
|
conferenceWithoutId.setDeadlines(deadlines);
|
|
|
|
|
|
|
|
conferenceWithoutId.setUsers(conferenceUsers);
|
|
|
|
|
|
|
|
|
|
|
|
conferences.add(conference);
|
|
|
|
conferences.add(conferenceWithId);
|
|
|
|
conferenceDto = new ConferenceDto(conference);
|
|
|
|
conferenceDto = new ConferenceDto(conferenceWithId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -117,7 +137,7 @@ public class ConferenceServiceTest {
|
|
|
|
when(paperService.create(paperWithoutId)).thenReturn(paperWithoutId);
|
|
|
|
when(paperService.create(paperWithoutId)).thenReturn(paperWithoutId);
|
|
|
|
when(deadlineService.saveOrCreate(conferenceDto.getDeadlines())).thenReturn(deadlines);
|
|
|
|
when(deadlineService.saveOrCreate(conferenceDto.getDeadlines())).thenReturn(deadlines);
|
|
|
|
when(conferenceUserService.saveOrCreate(conferenceDto.getUsers())).thenReturn(conferenceUsers);
|
|
|
|
when(conferenceUserService.saveOrCreate(conferenceDto.getUsers())).thenReturn(conferenceUsers);
|
|
|
|
assertEquals(conference, conferenceService.copyFromDto(new Conference(), conferenceDto));
|
|
|
|
assertEquals(conferenceWithoutId, conferenceService.copyFromDto(new Conference(), conferenceDto));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -136,7 +156,17 @@ public class ConferenceServiceTest {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testFindOneDto() throws IOException {
|
|
|
|
public void testFindOneDto() throws IOException {
|
|
|
|
when(conferenceRepository.findOne(1)).thenReturn(conference);
|
|
|
|
when(conferenceRepository.findOne(1)).thenReturn(conferenceWithId);
|
|
|
|
assertEquals(conferenceDto, conferenceService.findOneDto(1));
|
|
|
|
assertEquals(conferenceDto, conferenceService.findOneDto(1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void testCreate() throws IOException {
|
|
|
|
|
|
|
|
when(paperService.findPaperById(paperWithId.getId())).thenReturn(paperWithId);
|
|
|
|
|
|
|
|
when(paperService.create(paperWithoutId)).thenReturn(paperWithoutId);
|
|
|
|
|
|
|
|
when(deadlineService.saveOrCreate(conferenceDto.getDeadlines())).thenReturn(deadlines);
|
|
|
|
|
|
|
|
when(conferenceUserService.saveOrCreate(conferenceDto.getUsers())).thenReturn(conferenceUsers);
|
|
|
|
|
|
|
|
when(conferenceRepository.save(conferenceWithoutId)).thenReturn(conferenceWithoutId);
|
|
|
|
|
|
|
|
assertNull(conferenceService.create(conferenceDto));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|