#104 addDeadline, removeDeadline fixed

This commit is contained in:
Nightblade73 2019-05-16 13:33:26 +04:00
parent 1e06edfcc0
commit ce7b4c9c7a
2 changed files with 22 additions and 8 deletions

View File

@ -65,6 +65,11 @@ public class Deadline extends BaseEntity {
return false;
}
Deadline deadline = (Deadline) o;
if (getId() == null && deadline.getId() == null &&
description == null && deadline.description == null &&
date == null && deadline.date == null) {
return true;
}
return getId().equals(deadline.getId()) &&
description.equals(deadline.description) &&
date.equals(deadline.date);

View File

@ -61,6 +61,9 @@ public class ConferenceServiceTest {
@InjectMocks
ConferenceService conferenceService;
private final Integer ID = 1;
private final Integer ROMOVE_INDEX = 0;
private List<Conference> conferences;
private List<Deadline> deadlines;
private List<Paper> papers;
@ -171,20 +174,26 @@ public class ConferenceServiceTest {
@Test
public void delete() {
when(conferenceRepository.exists(1)).thenReturn(true);
assertTrue(conferenceService.delete(1));
when(conferenceRepository.exists(ID)).thenReturn(true);
when(conferenceRepository.findOne(ID)).thenReturn(conferenceWithId);
assertTrue(conferenceService.delete(ID));
}
@Test
public void addDeadline() {
ConferenceDto newConferenceDto = conferenceService.addDeadline(conferenceDto);
assertEquals(conferenceDto, newConferenceDto);
ConferenceDto newConferenceDto = new ConferenceDto();
newConferenceDto.getDeadlines().add(new Deadline());
conferenceDto.getDeadlines().clear();
assertEquals(newConferenceDto.getDeadlines(), conferenceService.addDeadline(conferenceDto).getDeadlines());
}
@Test
public void removeDeadline() throws IOException {
ConferenceDto newConferenceDto = conferenceService.removeDeadline(conferenceDto, 0);
assertEquals(conferenceDto, newConferenceDto);
ConferenceDto newConferenceDto = new ConferenceDto();
newConferenceDto.getRemovedDeadlineIds().add(ID);
ConferenceDto result = conferenceService.removeDeadline(conferenceDto, ROMOVE_INDEX);
assertEquals(newConferenceDto.getDeadlines(), result.getDeadlines());
assertEquals(newConferenceDto.getRemovedDeadlineIds(), result.getRemovedDeadlineIds());
}
@Test
@ -196,7 +205,7 @@ public class ConferenceServiceTest {
@Test
public void removePaper() throws IOException {
ConferenceDto newConferenceDto = conferenceService.removePaper(conferenceDto, 0);
ConferenceDto newConferenceDto = conferenceService.removePaper(conferenceDto, ROMOVE_INDEX);
assertEquals(conferenceDto, newConferenceDto);
}
@ -234,7 +243,7 @@ public class ConferenceServiceTest {
@Test
public void ping() throws IOException {
when(conferenceRepository.findOne(1)).thenReturn(conferenceWithId);
when(conferenceRepository.findOne(ID)).thenReturn(conferenceWithId);
when(conferenceRepository.updatePingConference(1)).thenReturn(1);
assertEquals(1, conferenceService.ping(conferenceDto));
}