Przeglądaj źródła

BMDCachePeopleTest(2)

Andrew Grant 3 miesięcy temu
rodzic
commit
f62a4e99f1

+ 2 - 0
src/main/java/scot/carricksoftware/grants/cache/BMDCacheImpl.java

@@ -5,11 +5,13 @@
 
 package scot.carricksoftware.grants.cache;
 
+import org.springframework.stereotype.Component;
 import scot.carricksoftware.grants.domains.people.Person;
 import scot.carricksoftware.grants.services.people.PersonService;
 
 import java.util.List;
 
+@Component
 public class BMDCacheImpl implements BMDCache {
 
     private final PersonService personService;

+ 5 - 5
src/main/java/scot/carricksoftware/grants/controllers/attributes/AddAttributesImpl.java

@@ -7,27 +7,27 @@ package scot.carricksoftware.grants.controllers.attributes;
 
 import org.springframework.stereotype.Component;
 import org.springframework.ui.Model;
+import scot.carricksoftware.grants.cache.BMDCache;
 import scot.carricksoftware.grants.constants.AttributeConstants;
-import scot.carricksoftware.grants.services.people.PersonService;
 import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
 import scot.carricksoftware.grants.services.places.places.PlaceService;
 
 @Component
 public class AddAttributesImpl implements AddAttributes {
 
-    private final PersonService personService;
+    private final BMDCache bmdCache;
     private final PlaceService placeService;
     private final OrganisationService organisationService;
 
-    public AddAttributesImpl(PersonService personService, PlaceService placeService, OrganisationService organisationService) {
-        this.personService = personService;
+    public AddAttributesImpl(BMDCache bmdCache, PlaceService placeService, OrganisationService organisationService) {
+        this.bmdCache = bmdCache;
         this.placeService = placeService;
         this.organisationService = organisationService;
     }
 
     @Override
     public void AddBMDCertificate(Model model) {
-        model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+        model.addAttribute(AttributeConstants.PEOPLE, bmdCache.getPeople());
         model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
         model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
     }

+ 6 - 1
src/test/java/scot/carricksoftware/grants/controllers/attributes/AddAttributesTest.java

@@ -11,6 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.springframework.ui.Model;
+import scot.carricksoftware.grants.cache.BMDCache;
 import scot.carricksoftware.grants.domains.people.Person;
 import scot.carricksoftware.grants.domains.places.Organisation;
 import scot.carricksoftware.grants.domains.places.Place;
@@ -29,6 +30,10 @@ class AddAttributesTest {
 
     private AddAttributes addAttributes;
 
+
+    @Mock
+    private BMDCache bmdCacheMock;
+
     @Mock
     private PersonService personServiceMock;
 
@@ -43,7 +48,7 @@ class AddAttributesTest {
 
     @BeforeEach
     void setUp() {
-        addAttributes = new AddAttributesImpl(personServiceMock, placeServiceMock, organisationServiceMock);
+        addAttributes = new AddAttributesImpl(bmdCacheMock, placeServiceMock, organisationServiceMock);
     }
 
     @Test