Jelajahi Sumber

BMDCachePlacesTest(2)

Andrew Grant 3 bulan lalu
induk
melakukan
72c025120d

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

@@ -10,25 +10,22 @@ import org.springframework.ui.Model;
 import scot.carricksoftware.grants.cache.BMDCache;
 import scot.carricksoftware.grants.constants.AttributeConstants;
 import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
-import scot.carricksoftware.grants.services.places.places.PlaceService;
 
 @Component
 public class AddAttributesImpl implements AddAttributes {
 
     private final BMDCache bmdCache;
-    private final PlaceService placeService;
     private final OrganisationService organisationService;
 
-    public AddAttributesImpl(BMDCache bmdCache, PlaceService placeService, OrganisationService organisationService) {
+    public AddAttributesImpl(BMDCache bmdCache, OrganisationService organisationService) {
         this.bmdCache = bmdCache;
-        this.placeService = placeService;
         this.organisationService = organisationService;
     }
 
     @Override
     public void AddBMDCertificate(Model model) {
         model.addAttribute(AttributeConstants.PEOPLE, bmdCache.getPeople());
-        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+        model.addAttribute(AttributeConstants.PLACES, bmdCache.getPlaces());
         model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
     }
 

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

@@ -16,7 +16,6 @@ import scot.carricksoftware.grants.domains.people.Person;
 import scot.carricksoftware.grants.domains.places.Organisation;
 import scot.carricksoftware.grants.domains.places.Place;
 import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
-import scot.carricksoftware.grants.services.places.places.PlaceService;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -29,12 +28,9 @@ class AddAttributesTest {
 
     private AddAttributes addAttributes;
 
-
     @Mock
     private BMDCache bmdCacheMock;
 
-    @Mock
-    private PlaceService placeServiceMock;
 
     @Mock
     private OrganisationService organisationServiceMock;
@@ -44,7 +40,7 @@ class AddAttributesTest {
 
     @BeforeEach
     void setUp() {
-        addAttributes = new AddAttributesImpl(bmdCacheMock, placeServiceMock, organisationServiceMock);
+        addAttributes = new AddAttributesImpl(bmdCacheMock, organisationServiceMock);
     }
 
     @Test
@@ -57,7 +53,6 @@ class AddAttributesTest {
     @Test
     void AddBMDCertificatePlacesTest() {
         List<Place> placeList = new ArrayList<>();
-        when(placeServiceMock.findAll()).thenReturn(placeList);
         addAttributes.AddBMDCertificate(modelMock);
         verify(modelMock).addAttribute("places", placeList);
     }