From 234176b7fe5c4178449d74a9627c3645212ac821 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 27 Jun 2023 09:29:56 +0200 Subject: test(core): actived and fix some more tests --- ...CertificateAndRequestParameterResolverTest.java | 37 ++++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'pdf-as-lib/src/test/java') diff --git a/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/CertificateAndRequestParameterResolverTest.java b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/CertificateAndRequestParameterResolverTest.java index 7ba6747a..e94d21e8 100644 --- a/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/CertificateAndRequestParameterResolverTest.java +++ b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/CertificateAndRequestParameterResolverTest.java @@ -4,8 +4,10 @@ import static org.junit.Assert.assertEquals; import java.io.IOException; import java.security.cert.CertificateException; +import java.util.HashMap; import java.util.Map; import java.util.Vector; +import java.util.stream.Collectors; import org.junit.Before; import org.junit.Test; @@ -13,6 +15,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import at.gv.egiz.pdfas.common.exceptions.PDFASError; +import at.gv.egiz.pdfas.common.settings.IProfileConstants; import at.gv.egiz.pdfas.common.settings.ISettings; import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings; import at.gv.egiz.pdfas.lib.api.sign.SignParameter; @@ -76,18 +79,23 @@ public class CertificateAndRequestParameterResolverTest { } private ISettings buildDummySettings() { - return new ISettings() { - + Map configMap = new HashMap<>(); + configMap.put(IProfileConstants.SIG_OBJ + "test", "test"); + + return new ISettings() { + @Override public boolean hasValue(String key) { - // TODO Auto-generated method stub - return false; + return configMap.containsKey(key); } @Override public boolean hasPrefix(String prefix) { - // TODO Auto-generated method stub - return false; + return configMap.keySet().stream() + .filter(el -> el.startsWith(prefix)) + .findFirst() + .isPresent(); + } @Override @@ -98,14 +106,16 @@ public class CertificateAndRequestParameterResolverTest { @Override public Map getValuesPrefix(String prefix) { - // TODO Auto-generated method stub - return null; + return configMap.entrySet().stream() + .filter(el -> el.getKey().startsWith(prefix)) + .collect(Collectors.toMap(key -> key.getKey(), value -> value.getValue())); + } @Override public String getValue(String key) { - // TODO Auto-generated method stub - return null; + return configMap.get(key); + } @Override @@ -116,14 +126,13 @@ public class CertificateAndRequestParameterResolverTest { @Override public boolean isValue(String key) { - // TODO Auto-generated method stub - return false; + return isValue(key, false); } @Override public boolean isValue(String key, boolean defaultValue) { - return defaultValue; + return hasValue(key) ? Boolean.valueOf(getValue(key)) : defaultValue; } - }; + }; } } -- cgit v1.2.3