#104 add new tests, fixes
This commit is contained in:
parent
00c5d5f755
commit
7952787229
@ -42,12 +42,12 @@ public class Conference extends BaseEntity {
|
|||||||
@Column(name = "begin_date")
|
@Column(name = "begin_date")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
private Date beginDate;
|
private Date beginDate = new Date();
|
||||||
|
|
||||||
@Column(name = "end_date")
|
@Column(name = "end_date")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
private Date endDate;
|
private Date endDate = new Date();
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "conference_id", unique = true)
|
@JoinColumn(name = "conference_id", unique = true)
|
||||||
|
@ -225,9 +225,9 @@ public class ConferenceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void ping(ConferenceDto conferenceDto) throws IOException {
|
public int ping(ConferenceDto conferenceDto) throws IOException {
|
||||||
pingService.addPing(findOne(conferenceDto.getId()));
|
pingService.addPing(findOne(conferenceDto.getId()));
|
||||||
conferenceRepository.updatePingConference(conferenceDto.getId());
|
return conferenceRepository.updatePingConference(conferenceDto.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Conference findOne(Integer conferenceId) {
|
private Conference findOne(Integer conferenceId) {
|
||||||
|
@ -9,12 +9,14 @@ import org.mockito.runners.MockitoJUnitRunner;
|
|||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import ru.ulstu.conference.model.Conference;
|
import ru.ulstu.conference.model.Conference;
|
||||||
import ru.ulstu.conference.model.ConferenceDto;
|
import ru.ulstu.conference.model.ConferenceDto;
|
||||||
|
import ru.ulstu.conference.model.ConferenceFilterDto;
|
||||||
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.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.ping.service.PingService;
|
||||||
import ru.ulstu.timeline.service.EventService;
|
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;
|
||||||
@ -47,11 +49,14 @@ public class ConferenceServiceTest {
|
|||||||
@Mock
|
@Mock
|
||||||
UserService userService;
|
UserService userService;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
EventService eventService;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
ConferenceNotificationService conferenceNotificationService;
|
ConferenceNotificationService conferenceNotificationService;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
EventService eventService;
|
PingService pingService;
|
||||||
|
|
||||||
@InjectMocks
|
@InjectMocks
|
||||||
ConferenceService conferenceService;
|
ConferenceService conferenceService;
|
||||||
@ -62,12 +67,9 @@ public class ConferenceServiceTest {
|
|||||||
private List<ConferenceUser> conferenceUsers;
|
private List<ConferenceUser> conferenceUsers;
|
||||||
|
|
||||||
private Conference conferenceWithId;
|
private Conference conferenceWithId;
|
||||||
private Conference conferenceWithoutId;
|
|
||||||
private ConferenceUser conferenceUser;
|
|
||||||
|
|
||||||
private Paper paperWithId;
|
private Paper paperWithId;
|
||||||
private Paper paperWithoutId;
|
private Paper paperWithoutId;
|
||||||
private Deadline deadline;
|
|
||||||
|
|
||||||
private ConferenceDto conferenceDto;
|
private ConferenceDto conferenceDto;
|
||||||
private User user;
|
private User user;
|
||||||
@ -76,7 +78,7 @@ public class ConferenceServiceTest {
|
|||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
conferences = new ArrayList<>();
|
conferences = new ArrayList<>();
|
||||||
conferenceWithId = new Conference();
|
conferenceWithId = new Conference();
|
||||||
conferenceWithoutId = new Conference();
|
Conference conferenceWithoutId = new Conference();
|
||||||
|
|
||||||
conferenceWithId.setId(1);
|
conferenceWithId.setId(1);
|
||||||
conferenceWithId.setTitle("Название");
|
conferenceWithId.setTitle("Название");
|
||||||
@ -97,11 +99,11 @@ public class ConferenceServiceTest {
|
|||||||
papers.add(paperWithoutId);
|
papers.add(paperWithoutId);
|
||||||
|
|
||||||
deadlines = new ArrayList<>();
|
deadlines = new ArrayList<>();
|
||||||
deadline = new Deadline(new Date(), "desc");
|
Deadline deadline = new Deadline(new Date(), "desc");
|
||||||
deadline.setId(1);
|
deadline.setId(1);
|
||||||
deadlines.add(deadline);
|
deadlines.add(deadline);
|
||||||
|
|
||||||
conferenceUser = new ConferenceUser();
|
ConferenceUser conferenceUser = new ConferenceUser();
|
||||||
conferenceUser.setDeposit(ConferenceUser.Deposit.ARTICLE);
|
conferenceUser.setDeposit(ConferenceUser.Deposit.ARTICLE);
|
||||||
conferenceUser.setParticipation(ConferenceUser.Participation.INTRAMURAL);
|
conferenceUser.setParticipation(ConferenceUser.Participation.INTRAMURAL);
|
||||||
user = new User();
|
user = new User();
|
||||||
@ -164,7 +166,7 @@ public class ConferenceServiceTest {
|
|||||||
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);
|
||||||
when(conferenceRepository.save(new Conference())).thenReturn(conferenceWithId);
|
when(conferenceRepository.save(new Conference())).thenReturn(conferenceWithId);
|
||||||
assertEquals(conferenceWithId.getId(), conferenceService.create(conferenceDto));
|
assertEquals(conferenceWithId.getId(), conferenceService.update(conferenceDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -216,22 +218,24 @@ public class ConferenceServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void filter() {
|
public void filter() {
|
||||||
|
ConferenceFilterDto conferenceFilterDto = new ConferenceFilterDto();
|
||||||
|
conferenceFilterDto.setFilterUserId(1);
|
||||||
|
conferenceFilterDto.setYear(2019);
|
||||||
|
when(userService.findById(1)).thenReturn(user);
|
||||||
|
when(conferenceRepository.findByUserAndYear(user, 2019)).thenReturn(conferences);
|
||||||
|
assertEquals(Collections.singletonList(conferenceDto), conferenceService.filter(conferenceFilterDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAttachedToConference() {
|
public void isAttachedToConference() {
|
||||||
|
when(conferenceRepository.isPaperAttached(1)).thenReturn(true);
|
||||||
|
assertTrue(conferenceService.isAttachedToConference(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ping() {
|
public void ping() throws IOException {
|
||||||
}
|
when(conferenceRepository.findOne(1)).thenReturn(conferenceWithId);
|
||||||
|
when(conferenceRepository.updatePingConference(1)).thenReturn(1);
|
||||||
|
assertEquals(1, conferenceService.ping(conferenceDto));
|
||||||
@Test
|
|
||||||
public void checkEmptyFieldsOfDeadline() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void filterEmptyDeadlines() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user