aboutsummaryrefslogtreecommitdiff
path: root/id/server/stork2-commons/src/test/java/eu/stork/peps/tests/PersonalAttributeTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/stork2-commons/src/test/java/eu/stork/peps/tests/PersonalAttributeTestCase.java')
-rw-r--r--id/server/stork2-commons/src/test/java/eu/stork/peps/tests/PersonalAttributeTestCase.java191
1 files changed, 0 insertions, 191 deletions
diff --git a/id/server/stork2-commons/src/test/java/eu/stork/peps/tests/PersonalAttributeTestCase.java b/id/server/stork2-commons/src/test/java/eu/stork/peps/tests/PersonalAttributeTestCase.java
deleted file mode 100644
index 82676ccf0..000000000
--- a/id/server/stork2-commons/src/test/java/eu/stork/peps/tests/PersonalAttributeTestCase.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * This work is Open Source and licensed by the European Commission under the
- * conditions of the European Public License v1.1
- *
- * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1);
- *
- * any use of this file implies acceptance of the conditions of this license.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package eu.stork.peps.tests;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import eu.stork.peps.auth.commons.PersonalAttribute;
-import eu.stork.peps.auth.commons.STORKStatusCode;
-
-/**
- * The PersonalAttribute's Test Case.
- *
- * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com,
- * luis.felix@multicert.com, hugo.magalhaes@multicert.com,
- * paulo.ribeiro@multicert.com
- * @version $Revision: 1.4 $, $Date: 2010-11-17 05:17:03 $
- */
-public final class PersonalAttributeTestCase {
-
- /**
- * An empty attribute.
- */
- private static final PersonalAttribute EMPTYATTR = new PersonalAttribute();
-
- /**
- * An attribute with a complex value (canonicalResidenceAddress).
- */
- private static PersonalAttribute complexAttrValue = null;
-
- /**
- * An attribute with a simple value (age).
- */
- @SuppressWarnings("serial")
- private static final PersonalAttribute ATTR_VALUE = new PersonalAttribute(
- "age", true, new ArrayList<String>() {
- {
- add("15");
- }
- }, STORKStatusCode.STATUS_AVAILABLE.toString());
-
- /**
- * Init PersonalAttributeTestCase class.
- */
- @SuppressWarnings("serial")
- @BeforeClass
- public static void runsBeforeTheTestSuite() {
- final Map<String, String> values = new HashMap<String, String>() {
- {
- put("countryCodeAddress", "PT");
- put("state", "Porto");
- put("town", "Porto");
- put("postalCode", "4100");
- put("streetName", "Avenida Sidonio Pais");
- put("streetNumber", "379");
- put("apartmentNumber", "B");
- }
- };
-
- complexAttrValue
- = new PersonalAttribute("canonicalResidenceAddress", true, values,
- STORKStatusCode.STATUS_AVAILABLE.toString());
-
- }
-
- /**
- * Tests the {@link PersonalAttribute#toString()} method for the given
- * simple attribute value. Values must match.
- */
- @Test
- public void testToStringValues() {
- final String attrVal = ATTR_VALUE.toString();
- assert "age:true:[15]:Available;".equals(attrVal);
- }
-
- /**
- * Tests the {@link PersonalAttribute#toString()} method for the given
- * complex attribute value. Values must match.
- */
- @Test
- public void testToStringComplexValues() {
- //We are testing normal attribute Canonical address, only one value!
- final Map<String,String> complexAttrVal = complexAttrValue.getComplexValue();
- final boolean testResult = containsKeyAndValue(complexAttrVal, "postalCode", "4100") &&
- containsKeyAndValue(complexAttrVal, "apartmentNumber", "B") &&
- containsKeyAndValue(complexAttrVal, "state", "Porto") &&
- containsKeyAndValue(complexAttrVal, "countryCodeAddress", "PT") &&
- containsKeyAndValue(complexAttrVal, "streetNumber", "379") &&
- containsKeyAndValue(complexAttrVal, "streetName", "Avenida Sidonio Pais") &&
- containsKeyAndValue(complexAttrVal, "town", "Porto");
- assert testResult;
- }
-
- private boolean containsKeyAndValue(final Map<String,String> complexAttrVal, final String key, final String expectedValue) {
- final boolean res = complexAttrVal.containsKey(key) && complexAttrVal.get(key).equals(expectedValue);
- return res;
- }
-
- /**
- * Tests the {@link PersonalAttribute#isEmptyStatus()} method for the given
- * empty attribute. Must return true.
- */
- @Test
- public void testToIsEmptyStatusWithNull() {
- assert EMPTYATTR.isEmptyStatus();
- }
-
- /**
- * Tests the {@link PersonalAttribute#isEmptyStatus()} method for the given
- * new attribute. Must return true.
- */
- @Test
- public void testToIsEmptyStatusWithEmptyString() {
- final PersonalAttribute attr = (PersonalAttribute) EMPTYATTR.clone();
- attr.setStatus("");
- assert attr.isEmptyStatus();
- }
-
- /**
- * Tests the {@link PersonalAttribute#isEmptyValue()} method for the given
- * empty attribute. Must return true.
- */
- @Test
- public void testToIsEmptyValueWithNull() {
- final PersonalAttribute attr = (PersonalAttribute) EMPTYATTR.clone();
- attr.setValue(null);
- assert attr.isEmptyValue();
- }
-
- /**
- * Tests the {@link PersonalAttribute#isEmptyValue()} method for the given
- * empty attribute. Must return true.
- */
- @Test
- public void testToIsEmptyValue() {
- assert EMPTYATTR.isEmptyValue();
- }
-
- /**
- * Tests the {@link PersonalAttribute#isEmptyComplexValue()} method for the
- * given empty attribute. Must return true.
- */
- @Test
- public void testToIsEmptyComplexValueWithNull() {
- final PersonalAttribute attr = (PersonalAttribute) EMPTYATTR.clone();
- attr.setComplexValue(null);
- assert attr.isEmptyComplexValue();
- }
-
- /**
- * Tests the {@link PersonalAttribute#isEmptyComplexValue()} method for the
- * given empty attribute. Must return true.
- */
- @Test
- public void testToIsEmptyComplexValueWithEmptyComplexValue() {
- assert EMPTYATTR.isEmptyComplexValue();
- }
-
- /**
- * Tests the {@link PersonalAttribute#clone()} method for the given
- * attribute. Must return true.
- */
- @Test
- public void testCloneToComplexValue() {
- assert (complexAttrValue.getComplexValue().toString().equals(complexAttrValue.getComplexValue().toString()) && !complexAttrValue.equals(complexAttrValue.clone()));
- }
-
- /**
- * Tests the {@link PersonalAttribute#clone()} method for the given
- * attribute. Must return true.
- */
- @Test
- public void testCloneToValue() {
- assert !ATTR_VALUE.equals(ATTR_VALUE.clone());
- }
-}