diff options
| author | Paul-Christian Volkmer | 2023-04-03 14:34:32 +0200 |
|---|---|---|
| committer | Paul-Christian Volkmer | 2023-04-03 14:35:31 +0200 |
| commit | a97d76e5bbe42cde2a5729efedcdcdcd7c26bbe9 (patch) | |
| tree | a1d835ea86ba24a13bf5904c49cdb16e1085e0cb /src/test/java/DNPM/config/ConsentManagerServiceFactoryTest.java | |
| parent | d548c5e5a3cb190fd68b90e2c12dc775da5edf5f (diff) | |
Issue #20: Detailimplementierungen für Consent Management
Diffstat (limited to 'src/test/java/DNPM/config/ConsentManagerServiceFactoryTest.java')
| -rw-r--r-- | src/test/java/DNPM/config/ConsentManagerServiceFactoryTest.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/test/java/DNPM/config/ConsentManagerServiceFactoryTest.java b/src/test/java/DNPM/config/ConsentManagerServiceFactoryTest.java new file mode 100644 index 0000000..affbee1 --- /dev/null +++ b/src/test/java/DNPM/config/ConsentManagerServiceFactoryTest.java @@ -0,0 +1,51 @@ +package DNPM.config; + +import DNPM.services.consent.ConsentManagerServiceFactory; +import DNPM.services.consent.MrConsentManagerService; +import de.itc.onkostar.api.IOnkostarApi; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.util.Map; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class ConsentManagerServiceFactoryTest { + + private IOnkostarApi onkostarApi; + + private ConsentManagerServiceFactory consentManagerServiceFactory; + + @BeforeEach + void setup( + @Mock IOnkostarApi onkostarApi + ) { + this.onkostarApi = onkostarApi; + this.consentManagerServiceFactory = new ConsentManagerServiceFactory(onkostarApi); + } + + private static Set<Map.Entry<String, Class<MrConsentManagerService>>> expectedMappings() { + return Map.ofEntries( + Map.entry("MR.Consent", MrConsentManagerService.class) + ).entrySet(); + } + + @ParameterizedTest + @MethodSource("expectedMappings") + void testShouldMapFormNameToService(Map.Entry<String, Class<?>> expectedMapping) { + when(onkostarApi.getGlobalSetting(anyString())).thenReturn(expectedMapping.getKey()); + + var actual = consentManagerServiceFactory.currentUsableInstance(); + + assertThat(actual).isExactlyInstanceOf(expectedMapping.getValue()); + } + +} |
