コード例 #1
0
  @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);
  }
コード例 #2
0
  @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));
    }
  }
コード例 #3
0
  @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);
  }
コード例 #4
0
  @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());
  }
コード例 #5
0
 @Test(expected = InvalidEntityException.class)
 public void saveInvalidSchema() {
   PlainSchema schema = entityFactory.newEntity(PlainSchema.class);
   schema.setKey("username");
   plainSchemaDAO.save(schema);
 }