#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; return false;
} }
Deadline deadline = (Deadline) o; 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()) && return getId().equals(deadline.getId()) &&
description.equals(deadline.description) && description.equals(deadline.description) &&
date.equals(deadline.date); date.equals(deadline.date);

View File

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