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