diff --git a/ldap-services/pom.xml b/ldap-services/pom.xml index 481e045..8a02994 100644 --- a/ldap-services/pom.xml +++ b/ldap-services/pom.xml @@ -127,27 +127,6 @@ - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - migratePostgresLiquibaseChangeLogToH2 - generate-sources - - exec - - - ${project.basedir}/scripts/migratePostgresLiquibaseChangeLogToH2.${script.extension} - - ${project.parent.basedir}/db-migration/src/main/resources/liquibase/db.changelog.xml - ${project.build.directory}/classes/liquibase/db.changelog.xml - - - - - org.apache.openejb.maven tomee-maven-plugin @@ -164,34 +143,6 @@ - - org.apache.openjpa - openjpa-maven-plugin - 2.4.2 - - **/bo/*.class - true - true - - - - enhancer - process-classes - - enhance - - - - - - org.apache.openjpa - openjpa - - 2.4.2 - compile - - - diff --git a/ldap-services/src/test/java/de/hsadmin/service/ldap/ValidationTest.java b/ldap-services/src/test/java/de/hsadmin/service/ldap/ValidationTest.java index c596f0f..81f3f4c 100644 --- a/ldap-services/src/test/java/de/hsadmin/service/ldap/ValidationTest.java +++ b/ldap-services/src/test/java/de/hsadmin/service/ldap/ValidationTest.java @@ -20,6 +20,18 @@ public class ValidationTest { @Before public void setUp() throws Exception { vo = new LdapUserVO(); + final String uidOk = "abc-someuid"; + final String mailOk = "someone@example.org"; + final String snOk = "Mustermann"; + ((StringProperty) vo.get("uid")).setValue(uidOk); + String uid = vo.getUid(); + assertEquals(uidOk, uid); + ((StringProperty) vo.get("mail")).setValue(mailOk); + String mail = vo.getMail(); + assertEquals(mailOk, mail); + ((StringProperty) vo.get("sn")).setValue(snOk); + String sn = vo.getSn(); + assertEquals(snOk, sn); val = new ValidationDelegate(); } @@ -30,6 +42,11 @@ public class ValidationTest { @Test public void testSetUid() { + try { + val.checkPrototypeIsCreateable(vo); + } catch (UserException | TechnicalException e) { + fail(e.getMessage()); + } final String uidFail = "ac-someuid"; try { ((StringProperty) vo.get("uid")).setValue(uidFail); @@ -45,38 +62,53 @@ public class ValidationTest { fail(e.getMessage()); } } - final String uidOk = "abc-someuid"; - final String mailOk = "someone@example.org"; - final String snOk = "Mustermann"; + } + + @Test + public void testSetMail() { + final String mailFail = "someuid"; try { - ((StringProperty) vo.get("uid")).setValue(uidOk); - String uid = vo.getUid(); - assertEquals(uidOk, uid); - ((StringProperty) vo.get("mail")).setValue(mailOk); + ((StringProperty) vo.get("mail")).setValue(mailFail); String mail = vo.getMail(); - assertEquals(mailOk, mail); - ((StringProperty) vo.get("sn")).setValue(snOk); - String sn = vo.getSn(); - assertEquals(snOk, sn); + assertEquals(mailFail, mail); + val.checkPrototypeIsCreateable(vo); + fail("expect UserException"); + } catch (UserException | TechnicalException e) { + if (e instanceof UserException) { + UserException ue = (UserException) e; + assertTrue("expect validationerror " + UserError.MSG_FIELD_DOESNOT_VALIDATE, ue.hasError(UserError.MSG_FIELD_DOESNOT_VALIDATE)); + } else { + fail(e.getMessage()); + } + } + } + + @Test + public void testSetMobile() { + try { + final String phoneFail = "+49 1234 S55678"; + ((StringProperty) vo.get("mobile")).setValue(phoneFail); + String mobile = vo.getMobile(); + assertEquals(phoneFail, mobile); + val.checkPrototypeIsCreateable(vo); + fail("expect UserException"); + } catch (UserException | TechnicalException e) { + if (e instanceof UserException) { + UserException ue = (UserException) e; + assertTrue("expect validationerror " + UserError.MSG_FIELD_DOESNOT_VALIDATE, ue.hasError(UserError.MSG_FIELD_DOESNOT_VALIDATE)); + } else { + fail(e.getMessage()); + } + } + try { + final String phoneOk = "+49 1234 555678"; + ((StringProperty) vo.get("mobile")).setValue(phoneOk); + String mobile = vo.getMobile(); + assertEquals(phoneOk, mobile); val.checkPrototypeIsCreateable(vo); } catch (UserException | TechnicalException e) { fail(e.getMessage()); } } -// @Test - public void testSetMail() { - fail("Not yet implemented"); - } - -// @Test - public void testSetMobile() { - fail("Not yet implemented"); - } - -// @Test - public void testSetNickName() { - fail("Not yet implemented"); - } - }