#104 some methods fixed
This commit is contained in:
parent
c0937d721a
commit
bde9cb51fb
@ -16,6 +16,7 @@ import ru.ulstu.deadline.service.DeadlineService;
|
|||||||
import ru.ulstu.name.BaseService;
|
import ru.ulstu.name.BaseService;
|
||||||
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.model.Ping;
|
||||||
import ru.ulstu.ping.service.PingService;
|
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;
|
||||||
@ -240,9 +241,10 @@ public class ConferenceService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public int ping(ConferenceDto conferenceDto) throws IOException {
|
public Ping ping(ConferenceDto conferenceDto) throws IOException {
|
||||||
pingService.addPing(findOne(conferenceDto.getId()));
|
Ping ping = pingService.addPing(findOne(conferenceDto.getId()));
|
||||||
return conferenceRepository.updatePingConference(conferenceDto.getId());
|
conferenceRepository.updatePingConference(conferenceDto.getId());
|
||||||
|
return ping;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Conference findOne(Integer conferenceId) {
|
private Conference findOne(Integer conferenceId) {
|
||||||
|
@ -268,9 +268,15 @@ public class Paper extends BaseEntity implements UserContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) {
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
return true;
|
||||||
if (!super.equals(o)) return false;
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!super.equals(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Paper paper = (Paper) o;
|
Paper paper = (Paper) o;
|
||||||
return Objects.equals(title, paper.title) &&
|
return Objects.equals(title, paper.title) &&
|
||||||
status == paper.status &&
|
status == paper.status &&
|
||||||
|
@ -23,10 +23,10 @@ public class PingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void addPing(Conference conference) throws IOException {
|
public Ping addPing(Conference conference) throws IOException {
|
||||||
Ping newPing = new Ping(new Date(), userService.getCurrentUser());
|
Ping newPing = new Ping(new Date(), userService.getCurrentUser());
|
||||||
newPing.setConference(conference);
|
newPing.setConference(conference);
|
||||||
pingRepository.save(newPing);
|
return pingRepository.save(newPing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer countPingYesterday(Conference conference, Calendar calendar) {
|
public Integer countPingYesterday(Conference conference, Calendar calendar) {
|
||||||
|
@ -16,6 +16,7 @@ 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.model.Ping;
|
||||||
import ru.ulstu.ping.service.PingService;
|
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;
|
||||||
@ -65,6 +66,7 @@ public class ConferenceServiceTest {
|
|||||||
private final Integer INDEX = 0;
|
private final Integer INDEX = 0;
|
||||||
private final String NAME = "Name";
|
private final String NAME = "Name";
|
||||||
private final boolean DISABLED = true;
|
private final boolean DISABLED = true;
|
||||||
|
private final Integer YEAR = 2019;
|
||||||
|
|
||||||
private List<Conference> conferences;
|
private List<Conference> conferences;
|
||||||
private List<Deadline> deadlines;
|
private List<Deadline> deadlines;
|
||||||
@ -127,19 +129,27 @@ public class ConferenceServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getExistConferenceById() {
|
public void getExistConferenceById() {
|
||||||
when(conferenceRepository.findOne(1)).thenReturn(conferenceWithId);
|
when(conferenceRepository.findOne(ID)).thenReturn(conferenceWithId);
|
||||||
when(paperService.findAllNotSelect(new ArrayList<>())).thenReturn(papers);
|
when(paperService.findAllNotSelect(new ArrayList<>())).thenReturn(papers);
|
||||||
when(userService.getCurrentUser()).thenReturn(user);
|
when(userService.getCurrentUser()).thenReturn(user);
|
||||||
conferenceDto.setDisabledTakePart(true);
|
ConferenceDto newConferenceDto = new ConferenceDto(conferenceWithId);
|
||||||
assertEquals(conferenceDto, conferenceService.getExistConferenceById(1));
|
newConferenceDto.setNotSelectedPapers(papers);
|
||||||
|
newConferenceDto.setDisabledTakePart(!DISABLED);
|
||||||
|
ConferenceDto result = conferenceService.getExistConferenceById(ID);
|
||||||
|
assertEquals(newConferenceDto.getId(), result.getId());
|
||||||
|
assertEquals(newConferenceDto.getNotSelectedPapers(), result.getNotSelectedPapers());
|
||||||
|
assertEquals(newConferenceDto.isDisabledTakePart(), result.isDisabledTakePart());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getNewConference() {
|
public void getNewConference() {
|
||||||
|
when(paperService.findAllNotSelect(new ArrayList<>())).thenReturn(papers);
|
||||||
ConferenceDto newConferenceDto = new ConferenceDto();
|
ConferenceDto newConferenceDto = new ConferenceDto();
|
||||||
newConferenceDto.setNotSelectedPapers(papers);
|
newConferenceDto.setNotSelectedPapers(papers);
|
||||||
when(paperService.findAllNotSelect(new ArrayList<>())).thenReturn(papers);
|
ConferenceDto result = conferenceService.getNewConference();
|
||||||
assertEquals(newConferenceDto, conferenceService.getNewConference());
|
assertEquals(newConferenceDto.getId(), result.getId());
|
||||||
|
assertEquals(newConferenceDto.getNotSelectedPapers(), result.getNotSelectedPapers());
|
||||||
|
assertEquals(newConferenceDto.isDisabledTakePart(), result.isDisabledTakePart());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -239,23 +249,25 @@ public class ConferenceServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void filter() {
|
public void filter() {
|
||||||
ConferenceFilterDto conferenceFilterDto = new ConferenceFilterDto();
|
ConferenceFilterDto conferenceFilterDto = new ConferenceFilterDto();
|
||||||
conferenceFilterDto.setFilterUserId(1);
|
conferenceFilterDto.setFilterUserId(ID);
|
||||||
conferenceFilterDto.setYear(2019);
|
conferenceFilterDto.setYear(YEAR);
|
||||||
when(userService.findById(1)).thenReturn(user);
|
when(userService.findById(ID)).thenReturn(user);
|
||||||
when(conferenceRepository.findByUserAndYear(user, 2019)).thenReturn(conferences);
|
when(conferenceRepository.findByUserAndYear(user, YEAR)).thenReturn(conferences);
|
||||||
assertEquals(Collections.singletonList(conferenceDto), conferenceService.filter(conferenceFilterDto));
|
assertEquals(Collections.singletonList(conferenceDto), conferenceService.filter(conferenceFilterDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAttachedToConference() {
|
public void isAttachedToConference() {
|
||||||
when(conferenceRepository.isPaperAttached(1)).thenReturn(true);
|
when(conferenceRepository.isPaperAttached(ID)).thenReturn(true);
|
||||||
assertTrue(conferenceService.isAttachedToConference(1));
|
assertTrue(conferenceService.isAttachedToConference(ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ping() throws IOException {
|
public void ping() throws IOException {
|
||||||
|
Ping ping = new Ping();
|
||||||
when(conferenceRepository.findOne(ID)).thenReturn(conferenceWithId);
|
when(conferenceRepository.findOne(ID)).thenReturn(conferenceWithId);
|
||||||
when(conferenceRepository.updatePingConference(1)).thenReturn(1);
|
when(pingService.addPing(conferenceWithId)).thenReturn(ping);
|
||||||
assertEquals(1, conferenceService.ping(conferenceDto));
|
when(conferenceRepository.updatePingConference(ID)).thenReturn(INDEX);
|
||||||
|
assertEquals(ping, conferenceService.ping(conferenceDto));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user