|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
package conference.module_test;
|
|
|
|
|
package ru.ulstu.conference.service;
|
|
|
|
|
|
|
|
|
|
import org.junit.Before;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
@ -11,9 +11,6 @@ import ru.ulstu.conference.model.Conference;
|
|
|
|
|
import ru.ulstu.conference.model.ConferenceDto;
|
|
|
|
|
import ru.ulstu.conference.model.ConferenceUser;
|
|
|
|
|
import ru.ulstu.conference.repository.ConferenceRepository;
|
|
|
|
|
import ru.ulstu.conference.service.ConferenceNotificationService;
|
|
|
|
|
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;
|
|
|
|
@ -24,11 +21,12 @@ import ru.ulstu.user.service.UserService;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
import static org.junit.Assert.assertNull;
|
|
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
|
import static org.mockito.Mockito.when;
|
|
|
|
|
|
|
|
|
|
@RunWith(MockitoJUnitRunner.class)
|
|
|
|
@ -126,28 +124,82 @@ public class ConferenceServiceTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testFindAllConferences() {
|
|
|
|
|
public void getExistConferenceById() {
|
|
|
|
|
when(conferenceRepository.findOne(1)).thenReturn(conferenceWithId);
|
|
|
|
|
when(paperService.findAllNotSelect(new ArrayList<>())).thenReturn(papers);
|
|
|
|
|
when(userService.getCurrentUser()).thenReturn(user);
|
|
|
|
|
conferenceDto.setDisabledTakePart(true);
|
|
|
|
|
assertEquals(conferenceDto, conferenceService.getExistConferenceById(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void getNewConference() {
|
|
|
|
|
ConferenceDto newConferenceDto = new ConferenceDto();
|
|
|
|
|
newConferenceDto.setNotSelectedPapers(papers);
|
|
|
|
|
when(paperService.findAllNotSelect(new ArrayList<>())).thenReturn(papers);
|
|
|
|
|
assertEquals(newConferenceDto, conferenceService.getNewConference());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void findAll() {
|
|
|
|
|
when(conferenceRepository.findAll(new Sort(Sort.Direction.DESC, "beginDate"))).thenReturn(conferences);
|
|
|
|
|
assertEquals(conferences, conferenceService.findAll());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCopyFromDto() throws IOException {
|
|
|
|
|
public void create() 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(new Conference())).thenReturn(conferenceWithId);
|
|
|
|
|
assertEquals(conferenceWithId.getId(), conferenceService.create(conferenceDto));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void update() throws IOException {
|
|
|
|
|
when(conferenceRepository.findOne(1)).thenReturn(conferenceWithId);
|
|
|
|
|
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);
|
|
|
|
|
assertEquals(conferenceWithoutId, conferenceService.copyFromDto(new Conference(), conferenceDto));
|
|
|
|
|
when(conferenceRepository.save(new Conference())).thenReturn(conferenceWithId);
|
|
|
|
|
assertEquals(conferenceWithId.getId(), conferenceService.create(conferenceDto));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void delete() {
|
|
|
|
|
when(conferenceRepository.exists(1)).thenReturn(true);
|
|
|
|
|
assertTrue(conferenceService.delete(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void addDeadline() {
|
|
|
|
|
ConferenceDto newConferenceDto = conferenceService.addDeadline(conferenceDto);
|
|
|
|
|
assertEquals(conferenceDto, newConferenceDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void removeDeadline() throws IOException {
|
|
|
|
|
ConferenceDto newConferenceDto = conferenceService.removeDeadline(conferenceDto, 0);
|
|
|
|
|
assertEquals(conferenceDto, newConferenceDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testIsCurrentUserParticipant() throws IOException {
|
|
|
|
|
public void addPaper() {
|
|
|
|
|
when(userService.getCurrentUser()).thenReturn(user);
|
|
|
|
|
assertEquals(true, conferenceService.isCurrentUserParticipant(conferenceUsers));
|
|
|
|
|
ConferenceDto newConferenceDto = conferenceService.addPaper(conferenceDto);
|
|
|
|
|
assertEquals(conferenceDto, newConferenceDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void removePaper() throws IOException {
|
|
|
|
|
ConferenceDto newConferenceDto = conferenceService.removePaper(conferenceDto, 0);
|
|
|
|
|
assertEquals(conferenceDto, newConferenceDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testTakePart() throws IOException {
|
|
|
|
|
public void takePart() throws IOException {
|
|
|
|
|
when(userService.getCurrentUser()).thenReturn(user);
|
|
|
|
|
ConferenceDto newConferenceDto = new ConferenceDto();
|
|
|
|
|
conferenceService.takePart(newConferenceDto);
|
|
|
|
@ -155,18 +207,31 @@ public class ConferenceServiceTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testFindOneDto() throws IOException {
|
|
|
|
|
when(conferenceRepository.findOne(1)).thenReturn(conferenceWithId);
|
|
|
|
|
assertEquals(conferenceDto, conferenceService.findOneDto(1));
|
|
|
|
|
public void getAllUsers() {
|
|
|
|
|
List<User> users = Collections.singletonList(user);
|
|
|
|
|
when(userService.findAll()).thenReturn(users);
|
|
|
|
|
assertEquals(users, conferenceService.getAllUsers());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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));
|
|
|
|
|
public void filter() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void isAttachedToConference() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void ping() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void checkEmptyFieldsOfDeadline() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void filterEmptyDeadlines() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|