|
|
@@ -3,14 +3,9 @@ package scot.carricksoftware.grants.bootstrap;
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
-import org.mockito.ArgumentCaptor;
|
|
|
import org.mockito.Mock;
|
|
|
import org.mockito.junit.jupiter.MockitoExtension;
|
|
|
-import scot.carricksoftware.grants.commands.places.organisations.OrganisationCommand;
|
|
|
-import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
|
|
|
|
|
|
-import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
-import static org.mockito.Mockito.atLeast;
|
|
|
import static org.mockito.Mockito.verify;
|
|
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
|
@@ -18,37 +13,28 @@ public class DataLoadOrganisationsTest {
|
|
|
|
|
|
private DataLoadOrganisations dataLoadOrganisations;
|
|
|
|
|
|
+
|
|
|
+ @Mock
|
|
|
+ private DataLoadCertificateAuthorities dataLoadCertificateAuthoritiesMock;
|
|
|
+
|
|
|
@Mock
|
|
|
- private OrganisationService organisationServiceMock;
|
|
|
+ private DataLoadRegistrationAuthorities dataLoadRegistrationAuthoritiesMock;
|
|
|
|
|
|
@BeforeEach
|
|
|
public void setUp() {
|
|
|
- dataLoadOrganisations = new DataLoadOrganisations(organisationServiceMock);
|
|
|
+ dataLoadOrganisations = new DataLoadOrganisations(dataLoadCertificateAuthoritiesMock, dataLoadRegistrationAuthoritiesMock);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void certificateSourcesIsLoadedTest() {
|
|
|
- ArgumentCaptor<OrganisationCommand> captor = ArgumentCaptor.forClass(OrganisationCommand.class);
|
|
|
+ void certificateAuthoritiesAreLoadedTest() {
|
|
|
dataLoadOrganisations.load();
|
|
|
- verify(organisationServiceMock, atLeast(1)).saveOrganisationCommand(captor.capture());
|
|
|
- for (OrganisationCommand command : captor.getAllValues()) {
|
|
|
- if (command.getName().equals("General Register Office For Scotland")) {
|
|
|
- assertTrue(true);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+ verify(dataLoadCertificateAuthoritiesMock).load();
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void registrationAuthorityIsLoadedTest() {
|
|
|
- ArgumentCaptor<OrganisationCommand> captor = ArgumentCaptor.forClass(OrganisationCommand.class);
|
|
|
+ void registrationAuthoritiesAreLoadedTest() {
|
|
|
dataLoadOrganisations.load();
|
|
|
- verify(organisationServiceMock, atLeast(1)).saveOrganisationCommand(captor.capture());
|
|
|
- for (OrganisationCommand command : captor.getAllValues()) {
|
|
|
- if (command.getName().equals("Registration Authority")) {
|
|
|
- assertTrue(true);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+ verify(dataLoadRegistrationAuthoritiesMock).load();
|
|
|
}
|
|
|
+
|
|
|
}
|