summaryrefslogtreecommitdiff
path: root/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/GivenNameAttrBuilderTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/GivenNameAttrBuilderTest.java')
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/GivenNameAttrBuilderTest.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/GivenNameAttrBuilderTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/GivenNameAttrBuilderTest.java
new file mode 100644
index 00000000..dd1dfa5e
--- /dev/null
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/attributes/GivenNameAttrBuilderTest.java
@@ -0,0 +1,72 @@
+package at.gv.egiz.eaaf.core.impl.idp.auth.attributes;
+
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import at.gv.egiz.eaaf.core.api.data.PVPAttributeDefinitions;
+import at.gv.egiz.eaaf.core.api.idp.IAttributeBuilder;
+import at.gv.egiz.eaaf.core.api.idp.IAuthData;
+import at.gv.egiz.eaaf.core.exceptions.UnavailableAttributeException;
+import at.gv.egiz.eaaf.core.impl.idp.AuthenticationData;
+import at.gv.egiz.eaaf.core.impl.idp.builder.attributes.GivenNameAttributeBuilder;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/SpringTest-context_eaaf_core.xml")
+public class GivenNameAttrBuilderTest extends AbstractAttributeBuilderTest{
+
+ private final IAttributeBuilder attrBuilde = new GivenNameAttributeBuilder();
+
+ @Test
+ public void performTest_ok() {
+ try {
+ final IAuthData authData = buildAuthData();
+ final String value = attrBuilde.build(spConfig, authData, g);
+ Assert.assertEquals("GivenName does NOT match", authData.getGivenName(), value);
+
+ } catch (final Exception e) {
+ Assert.assertTrue("Attr. builder has an exception", e == null);
+
+ }
+
+ }
+
+ @Test
+ public void performTest_null() {
+ try {
+ final AuthenticationData authData = (AuthenticationData) buildAuthData();
+ authData.setGivenName(null);
+
+ attrBuilde.build(spConfig, authData, g);
+ Assert.assertTrue("Attr. Builder provide no 'UnavailableAttributeException'", false);
+
+ } catch (final Exception e) {
+ Assert.assertTrue("Attr. builder provide wrong exception", e instanceof UnavailableAttributeException);
+ Assert.assertEquals("Attr. name in exception does NOT match",
+ PVPAttributeDefinitions.GIVEN_NAME_NAME, ((UnavailableAttributeException) e).getAttributeName());
+
+ }
+
+ }
+
+ @Test
+ public void performTest_emtpty() {
+ try {
+ final AuthenticationData authData = (AuthenticationData) buildAuthData();
+ authData.setGivenName(StringUtils.EMPTY);
+
+ attrBuilde.build(spConfig, authData, g);
+ Assert.assertTrue("Attr. Builder provide no 'UnavailableAttributeException'", false);
+
+ } catch (final Exception e) {
+ Assert.assertTrue("Attr. builder provide wrong exception", e instanceof UnavailableAttributeException);
+ Assert.assertEquals("Attr. name in exception does NOT match",
+ PVPAttributeDefinitions.GIVEN_NAME_NAME, ((UnavailableAttributeException) e).getAttributeName());
+
+ }
+
+ }
+}