Jean-Francois Leveque

Adaptation du code et des tests existants pour que ceux-ci soient à nouveau au vert.

......@@ -24,4 +24,11 @@ public class PublisherAction {
@ManyToOne
private Publisher publisher;
public void setPublisherActionAuthor(User publisherActionAuthor) {
this.publisherActionAuthor = publisherActionAuthor;
}
public void setPublisherActionDatetime(Timestamp publisherActionDatetime) {
this.publisherActionDatetime = publisherActionDatetime;
}
}
......
package org.legrog.entities;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PublisherActionRepository extends JpaRepository<PublisherAction, Integer> {
}
package org.legrog.web.publisher;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherRepository;
import org.legrog.entities.PublisherVersion;
import org.legrog.entities.PublisherVersionRepository;
import org.legrog.entities.*;
import org.legrog.web.xyz.SharedService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -27,14 +24,17 @@ public class PublisherServiceSpring implements PublisherService {
PublisherRepository publisherRepository;
PublisherVersionRepository publisherVersionRepository;
PublisherActionRepository publisherActionRepository;
SharedService sharedService;
@Inject
public PublisherServiceSpring(PublisherRepository publisherRepository,
PublisherVersionRepository publisherVersionRepository,
PublisherActionRepository publisherActionRepository,
SharedService sharedService) {
this.publisherRepository = publisherRepository;
this.publisherVersionRepository = publisherVersionRepository;
this.publisherActionRepository = publisherActionRepository;
this.sharedService = sharedService;
}
......@@ -71,9 +71,11 @@ public class PublisherServiceSpring implements PublisherService {
public void validatePublisherVersion(PublisherVersion publisherVersion) {
Publisher publisher = publisherVersion.getPublisher();
publisher.setValidatedVersion(publisherVersion);
publisher.setValidator(sharedService.getCurrentUser());
publisher.setValidationDateTime(new Timestamp(new Date().getTime()));
PublisherAction publisherAction = new PublisherAction();
publisherAction.setPublisherActionAuthor(sharedService.getCurrentUser());
publisherAction.setPublisherActionDatetime(new Timestamp(new Date().getTime()));
this.savePublisher(publisher);
publisherActionRepository.save(publisherAction);
}
protected void savePublisherVersion(PublisherVersion publisherVersion) {
......
......@@ -6,10 +6,7 @@ import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherRepository;
import org.legrog.entities.PublisherVersion;
import org.legrog.entities.PublisherVersionRepository;
import org.legrog.entities.*;
import org.legrog.test.MockitoExtension;
import org.legrog.web.xyz.SharedService;
import org.mockito.Mock;
......@@ -35,9 +32,10 @@ public class PublisherServiceSpringTest {
@BeforeEach
public void setUp(@Mock PublisherRepository publisherRepository,
@Mock PublisherVersionRepository publisherVersionRepository,
@Mock PublisherActionRepository publisherActionRepository,
@Mock SharedService sharedService) throws Exception {
publisherServiceSpring = new PublisherServiceSpring(publisherRepository,
publisherVersionRepository, sharedService);
publisherVersionRepository, publisherActionRepository, sharedService);
publisherVersion = new PublisherVersion();
publisherVersion1 = new PublisherVersion();
this.publisherRepository = publisherRepository;
......