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 { ...@@ -24,4 +24,11 @@ public class PublisherAction {
24 @ManyToOne 24 @ManyToOne
25 private Publisher publisher; 25 private Publisher publisher;
26 26
27 + public void setPublisherActionAuthor(User publisherActionAuthor) {
28 + this.publisherActionAuthor = publisherActionAuthor;
29 + }
30 +
31 + public void setPublisherActionDatetime(Timestamp publisherActionDatetime) {
32 + this.publisherActionDatetime = publisherActionDatetime;
33 + }
27 } 34 }
......
1 +package org.legrog.entities;
2 +
3 +import org.springframework.data.jpa.repository.JpaRepository;
4 +
5 +public interface PublisherActionRepository extends JpaRepository<PublisherAction, Integer> {
6 +}
1 package org.legrog.web.publisher; 1 package org.legrog.web.publisher;
2 2
3 3
4 -import org.legrog.entities.Publisher; 4 +import org.legrog.entities.*;
5 -import org.legrog.entities.PublisherRepository;
6 -import org.legrog.entities.PublisherVersion;
7 -import org.legrog.entities.PublisherVersionRepository;
8 import org.legrog.web.xyz.SharedService; 5 import org.legrog.web.xyz.SharedService;
9 import org.slf4j.Logger; 6 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory; 7 import org.slf4j.LoggerFactory;
...@@ -27,14 +24,17 @@ public class PublisherServiceSpring implements PublisherService { ...@@ -27,14 +24,17 @@ public class PublisherServiceSpring implements PublisherService {
27 24
28 PublisherRepository publisherRepository; 25 PublisherRepository publisherRepository;
29 PublisherVersionRepository publisherVersionRepository; 26 PublisherVersionRepository publisherVersionRepository;
27 + PublisherActionRepository publisherActionRepository;
30 SharedService sharedService; 28 SharedService sharedService;
31 29
32 @Inject 30 @Inject
33 public PublisherServiceSpring(PublisherRepository publisherRepository, 31 public PublisherServiceSpring(PublisherRepository publisherRepository,
34 PublisherVersionRepository publisherVersionRepository, 32 PublisherVersionRepository publisherVersionRepository,
33 + PublisherActionRepository publisherActionRepository,
35 SharedService sharedService) { 34 SharedService sharedService) {
36 this.publisherRepository = publisherRepository; 35 this.publisherRepository = publisherRepository;
37 this.publisherVersionRepository = publisherVersionRepository; 36 this.publisherVersionRepository = publisherVersionRepository;
37 + this.publisherActionRepository = publisherActionRepository;
38 this.sharedService = sharedService; 38 this.sharedService = sharedService;
39 } 39 }
40 40
...@@ -71,9 +71,11 @@ public class PublisherServiceSpring implements PublisherService { ...@@ -71,9 +71,11 @@ public class PublisherServiceSpring implements PublisherService {
71 public void validatePublisherVersion(PublisherVersion publisherVersion) { 71 public void validatePublisherVersion(PublisherVersion publisherVersion) {
72 Publisher publisher = publisherVersion.getPublisher(); 72 Publisher publisher = publisherVersion.getPublisher();
73 publisher.setValidatedVersion(publisherVersion); 73 publisher.setValidatedVersion(publisherVersion);
74 - publisher.setValidator(sharedService.getCurrentUser()); 74 + PublisherAction publisherAction = new PublisherAction();
75 - publisher.setValidationDateTime(new Timestamp(new Date().getTime())); 75 + publisherAction.setPublisherActionAuthor(sharedService.getCurrentUser());
76 + publisherAction.setPublisherActionDatetime(new Timestamp(new Date().getTime()));
76 this.savePublisher(publisher); 77 this.savePublisher(publisher);
78 + publisherActionRepository.save(publisherAction);
77 } 79 }
78 80
79 protected void savePublisherVersion(PublisherVersion publisherVersion) { 81 protected void savePublisherVersion(PublisherVersion publisherVersion) {
......
...@@ -6,10 +6,7 @@ import org.junit.jupiter.api.DisplayName; ...@@ -6,10 +6,7 @@ import org.junit.jupiter.api.DisplayName;
6 import org.junit.jupiter.api.extension.ExtendWith; 6 import org.junit.jupiter.api.extension.ExtendWith;
7 import org.junit.platform.runner.JUnitPlatform; 7 import org.junit.platform.runner.JUnitPlatform;
8 import org.junit.runner.RunWith; 8 import org.junit.runner.RunWith;
9 -import org.legrog.entities.Publisher; 9 +import org.legrog.entities.*;
10 -import org.legrog.entities.PublisherRepository;
11 -import org.legrog.entities.PublisherVersion;
12 -import org.legrog.entities.PublisherVersionRepository;
13 import org.legrog.test.MockitoExtension; 10 import org.legrog.test.MockitoExtension;
14 import org.legrog.web.xyz.SharedService; 11 import org.legrog.web.xyz.SharedService;
15 import org.mockito.Mock; 12 import org.mockito.Mock;
...@@ -35,9 +32,10 @@ public class PublisherServiceSpringTest { ...@@ -35,9 +32,10 @@ public class PublisherServiceSpringTest {
35 @BeforeEach 32 @BeforeEach
36 public void setUp(@Mock PublisherRepository publisherRepository, 33 public void setUp(@Mock PublisherRepository publisherRepository,
37 @Mock PublisherVersionRepository publisherVersionRepository, 34 @Mock PublisherVersionRepository publisherVersionRepository,
35 + @Mock PublisherActionRepository publisherActionRepository,
38 @Mock SharedService sharedService) throws Exception { 36 @Mock SharedService sharedService) throws Exception {
39 publisherServiceSpring = new PublisherServiceSpring(publisherRepository, 37 publisherServiceSpring = new PublisherServiceSpring(publisherRepository,
40 - publisherVersionRepository, sharedService); 38 + publisherVersionRepository, publisherActionRepository, sharedService);
41 publisherVersion = new PublisherVersion(); 39 publisherVersion = new PublisherVersion();
42 publisherVersion1 = new PublisherVersion(); 40 publisherVersion1 = new PublisherVersion();
43 this.publisherRepository = publisherRepository; 41 this.publisherRepository = publisherRepository;
......