@Test(expected = InvalidEntityException.class) public void saveNonValid() { PlainSchema schema = entityFactory.newEntity(PlainSchema.class); schema.setKey("secondaryEmail"); schema.setType(AttrSchemaType.String); schema.setValidatorClass("org.apache.syncope.core.validation.EmailAddressValidator"); schema.setMandatoryCondition("false"); schema.setMultivalue(true); schema.setUniqueConstraint(true); plainSchemaDAO.save(schema); }
@Test public void issueSYNCOPE418() { PlainSchema schema = entityFactory.newEntity(PlainSchema.class); schema.setKey("http://schemas.examples.org/security/authorization/organizationUnit"); try { plainSchemaDAO.save(schema); fail(); } catch (InvalidEntityException e) { assertTrue(e.hasViolation(EntityViolationType.InvalidName)); } }
@Test public void save() { PlainSchema schema = entityFactory.newEntity(PlainSchema.class); schema.setKey("secondaryEmail"); schema.setType(AttrSchemaType.String); schema.setValidatorClass("org.apache.syncope.core.validation.EmailAddressValidator"); schema.setMandatoryCondition("false"); schema.setMultivalue(true); plainSchemaDAO.save(schema); PlainSchema actual = plainSchemaDAO.find("secondaryEmail"); assertNotNull("expected save to work", actual); assertEquals(schema, actual); }
@Test public void checkForEnumType() { PlainSchema schema = entityFactory.newEntity(PlainSchema.class); schema.setType(AttrSchemaType.Enum); schema.setKey("color"); try { plainSchemaDAO.save(schema); fail(); } catch (Exception e) { assertNotNull(e); } schema.setEnumerationValues("red" + SyncopeConstants.ENUM_VALUES_SEPARATOR + "yellow"); schema.setEnumerationKeys("1" + SyncopeConstants.ENUM_VALUES_SEPARATOR + "2"); plainSchemaDAO.save(schema); PlainSchema actual = plainSchemaDAO.find(schema.getKey()); assertNotNull(actual); assertNotNull(actual.getEnumerationKeys()); assertFalse(actual.getEnumerationKeys().isEmpty()); }
@Test(expected = InvalidEntityException.class) public void saveInvalidSchema() { PlainSchema schema = entityFactory.newEntity(PlainSchema.class); schema.setKey("username"); plainSchemaDAO.save(schema); }