Removing @Column(nullable = false) in favor of @NotNull - better error messages
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/e20dd0ae Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/e20dd0ae Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/e20dd0ae Branch: refs/heads/master Commit: e20dd0ae315244db0f74b29ffe6096760a7536b6 Parents: 9cd9230 Author: Francesco Chicchiriccò <[email protected]> Authored: Thu Oct 22 12:22:06 2015 +0200 Committer: Francesco Chicchiriccò <[email protected]> Committed: Thu Oct 22 12:22:06 2015 +0200 ---------------------------------------------------------------------- .../persistence/jpa/entity/AbstractExec.java | 4 ++-- .../persistence/jpa/entity/JPAConnInstance.java | 9 +++++---- .../persistence/jpa/entity/JPADerSchema.java | 4 ++-- .../persistence/jpa/entity/JPANotification.java | 4 ++-- .../persistence/jpa/entity/JPAPlainSchema.java | 5 +++-- .../persistence/jpa/entity/JPAVirSchema.java | 6 +++--- .../entity/resource/JPAExternalResource.java | 16 ++++++++-------- .../jpa/entity/resource/JPAMapping.java | 4 ++-- .../jpa/entity/resource/JPAMappingItem.java | 11 ++++++----- .../persistence/jpa/inner/AnyObjectTest.java | 5 +++++ .../persistence/jpa/inner/VirSchemaTest.java | 12 ++++++++++++ .../java/data/SchemaDataBinderImpl.java | 20 +++++++++----------- .../fit/core/reference/VirSchemaITCase.java | 9 ++++++++- 13 files changed, 67 insertions(+), 42 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractExec.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractExec.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractExec.java index 5c009d4..a9b5c13 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractExec.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractExec.java @@ -20,11 +20,11 @@ package org.apache.syncope.core.persistence.jpa.entity; import java.util.Date; -import javax.persistence.Column; import javax.persistence.Lob; import javax.persistence.MappedSuperclass; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import javax.validation.constraints.NotNull; import org.apache.syncope.core.persistence.api.entity.Exec; @MappedSuperclass @@ -32,7 +32,7 @@ public abstract class AbstractExec extends AbstractEntity<Long> implements Exec private static final long serialVersionUID = -812344822970166317L; - @Column(nullable = false) + @NotNull protected String status; /** http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstance.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstance.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstance.java index 3929496..054dd69 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstance.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstance.java @@ -36,6 +36,7 @@ import javax.persistence.JoinColumn; import javax.persistence.Lob; import javax.persistence.OneToMany; import javax.persistence.Table; +import javax.validation.constraints.NotNull; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.syncope.common.lib.types.ConnConfProperty; @@ -63,7 +64,7 @@ public class JPAConnInstance extends AbstractEntity<Long> implements ConnInstanc /** * URI identifying the local / remote ConnId location where the related connector bundle is found. */ - @Column(nullable = false) + @NotNull private String location; /** @@ -71,7 +72,7 @@ public class JPAConnInstance extends AbstractEntity<Long> implements ConnInstanc * Within a given location, the triple * (ConnectorBundle-Name, ConnectorBundle-Version, ConnectorBundle-Version) must be unique. */ - @Column(nullable = false) + @NotNull private String connectorName; /** @@ -79,7 +80,7 @@ public class JPAConnInstance extends AbstractEntity<Long> implements ConnInstanc * Within a given location, the triple * (ConnectorBundle-Name, ConnectorBundle-Version, ConnectorBundle-Version) must be unique. */ - @Column(nullable = false) + @NotNull private String bundleName; /** @@ -87,7 +88,7 @@ public class JPAConnInstance extends AbstractEntity<Long> implements ConnInstanc * Within a given location, the triple * (ConnectorBundle-Name, ConnectorBundle-Version, ConnectorBundle-Version) must be unique. */ - @Column(nullable = false) + @NotNull private String version; /** http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPADerSchema.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPADerSchema.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPADerSchema.java index 944afc4..45eea22 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPADerSchema.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPADerSchema.java @@ -19,12 +19,12 @@ package org.apache.syncope.core.persistence.jpa.entity; import javax.persistence.Cacheable; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.OneToOne; import javax.persistence.Table; +import javax.validation.constraints.NotNull; import org.apache.syncope.common.lib.types.AttrSchemaType; import org.apache.syncope.core.persistence.api.entity.AnyTypeClass; import org.apache.syncope.core.persistence.api.entity.DerSchema; @@ -46,7 +46,7 @@ public class JPADerSchema extends AbstractEntity<String> implements DerSchema { @OneToOne(fetch = FetchType.EAGER) private JPAAnyTypeClass anyTypeClass; - @Column(nullable = false) + @NotNull private String expression; @Override http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPANotification.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPANotification.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPANotification.java index 7e3d211..1c42cf0 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPANotification.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPANotification.java @@ -84,7 +84,7 @@ public class JPANotification extends AbstractEntity<Long> implements Notificatio @NotNull private String recipientAttrName; - @Column(nullable = false) + @NotNull @Basic @Min(0) @Max(1) @@ -103,7 +103,7 @@ public class JPANotification extends AbstractEntity<Long> implements Notificatio @Enumerated(EnumType.STRING) private TraceLevel traceLevel; - @Column(nullable = false) + @NotNull @Basic @Min(0) @Max(1) http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAPlainSchema.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAPlainSchema.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAPlainSchema.java index 68eeacf..4ba6fa3 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAPlainSchema.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAPlainSchema.java @@ -32,6 +32,7 @@ import javax.persistence.Table; import javax.persistence.Transient; import javax.validation.constraints.Max; import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; import org.apache.commons.lang3.StringUtils; import org.apache.syncope.common.lib.types.AttrSchemaType; import org.apache.syncope.common.lib.types.CipherAlgorithm; @@ -58,11 +59,11 @@ public class JPAPlainSchema extends AbstractEntity<String> implements PlainSchem @OneToOne(fetch = FetchType.EAGER) private JPAAnyTypeClass anyTypeClass; - @Column(nullable = false) + @NotNull @Enumerated(EnumType.STRING) private AttrSchemaType type; - @Column(nullable = false) + @NotNull private String mandatoryCondition; @Basic http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAVirSchema.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAVirSchema.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAVirSchema.java index b984bb3..419e93a 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAVirSchema.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAVirSchema.java @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.List; import javax.persistence.Basic; import javax.persistence.Cacheable; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; @@ -31,6 +30,7 @@ import javax.persistence.OneToOne; import javax.persistence.Table; import javax.validation.constraints.Max; import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; import org.apache.syncope.common.lib.types.AttrSchemaType; import org.apache.syncope.common.lib.types.IntMappingType; import org.apache.syncope.common.lib.types.MappingPurpose; @@ -63,11 +63,11 @@ public class JPAVirSchema extends AbstractEntity<String> implements VirSchema { @Max(1) private Integer readonly; - @Column(nullable = false) + @NotNull @ManyToOne private JPAProvision provision; - @Column(nullable = false) + @NotNull private String extAttrName; public JPAVirSchema() { http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResource.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResource.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResource.java index e9e59fd..de3931e 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResource.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResource.java @@ -82,7 +82,7 @@ public class JPAExternalResource extends AbstractAnnotatedEntity<String> impleme /** * Should this resource enforce the mandatory constraints? */ - @Column(nullable = false) + @NotNull @Basic @Min(0) @Max(1) @@ -101,7 +101,7 @@ public class JPAExternalResource extends AbstractAnnotatedEntity<String> impleme /** * Is this resource primary, for propagations? */ - @Column(nullable = false) + @NotNull @Basic @Min(0) @Max(1) @@ -110,32 +110,32 @@ public class JPAExternalResource extends AbstractAnnotatedEntity<String> impleme /** * Priority index for propagation ordering. */ - @Column(nullable = false) + @NotNull private Integer propagationPriority; /** * Generate random password for propagation, if not provided? */ - @Column(nullable = false) + @NotNull @Basic @Min(0) @Max(1) private Integer randomPwdIfNotProvided; @Enumerated(EnumType.STRING) - @Column(nullable = false) + @NotNull private TraceLevel createTraceLevel; @Enumerated(EnumType.STRING) - @Column(nullable = false) + @NotNull private TraceLevel updateTraceLevel; @Enumerated(EnumType.STRING) - @Column(nullable = false) + @NotNull private TraceLevel deleteTraceLevel; @Enumerated(EnumType.STRING) - @Column(nullable = false) + @NotNull private TraceLevel syncTraceLevel; @ManyToOne(fetch = FetchType.EAGER) http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMapping.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMapping.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMapping.java index 2d7af3c..872fee7 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMapping.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMapping.java @@ -22,13 +22,13 @@ import java.util.ArrayList; import java.util.List; import javax.persistence.Cacheable; import javax.persistence.CascadeType; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.Table; +import javax.validation.constraints.NotNull; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.syncope.common.lib.types.IntMappingType; @@ -49,7 +49,7 @@ public class JPAMapping extends AbstractEntity<Long> implements Mapping { @Id private Long id; - @Column(nullable = false) + @NotNull @OneToOne private JPAProvision provision; http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMappingItem.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMappingItem.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMappingItem.java index 8dba286..c3ee73b 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMappingItem.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMappingItem.java @@ -35,6 +35,7 @@ import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.validation.constraints.Max; import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; import org.apache.syncope.common.lib.types.IntMappingType; import org.apache.syncope.common.lib.types.MappingPurpose; import org.apache.syncope.core.persistence.api.entity.resource.Mapping; @@ -59,7 +60,7 @@ public class JPAMappingItem extends AbstractEntity<Long> implements MappingItem @Column(nullable = true) private String intAttrName; - @Column(nullable = false) + @NotNull @Enumerated(EnumType.STRING) private IntMappingType intMappingType; @@ -72,13 +73,13 @@ public class JPAMappingItem extends AbstractEntity<Long> implements MappingItem /** * Specify if the mapped target resource's field is nullable. */ - @Column(nullable = false) + @NotNull private String mandatoryCondition; /** * Specify if the mapped target resource's field is the key. */ - @Column(nullable = false) + @NotNull @Basic @Min(0) @Max(1) @@ -87,13 +88,13 @@ public class JPAMappingItem extends AbstractEntity<Long> implements MappingItem /** * Specify if the mapped target resource's field is the password. */ - @Column(nullable = false) + @NotNull @Basic @Min(0) @Max(1) private Integer password; - @Column(nullable = false) + @NotNull @Enumerated(EnumType.STRING) private MappingPurpose purpose; http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java index cd6b535..943a94f 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java @@ -26,6 +26,7 @@ import static org.junit.Assert.assertTrue; import java.util.List; import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO; +import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO; import org.apache.syncope.core.persistence.api.dao.RealmDAO; import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject; import org.apache.syncope.core.persistence.jpa.AbstractTest; @@ -37,6 +38,9 @@ import org.springframework.transaction.annotation.Transactional; public class AnyObjectTest extends AbstractTest { @Autowired + private AnyTypeDAO anyTypeDAO; + + @Autowired private AnyObjectDAO anyObjectDAO; @Autowired @@ -68,6 +72,7 @@ public class AnyObjectTest extends AbstractTest { @Test public void save() { AnyObject anyObject = entityFactory.newEntity(AnyObject.class); + anyObject.setType(anyTypeDAO.find("PRINTER")); anyObject.setRealm(realmDAO.find(SyncopeConstants.ROOT_REALM)); anyObject = anyObjectDAO.save(anyObject); http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/VirSchemaTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/VirSchemaTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/VirSchemaTest.java index 66bd6cb..19193dd 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/VirSchemaTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/VirSchemaTest.java @@ -27,9 +27,13 @@ import static org.junit.Assert.fail; import java.util.List; import org.apache.syncope.common.lib.types.EntityViolationType; import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException; +import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO; import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO; import org.apache.syncope.core.persistence.api.entity.VirSchema; +import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource; +import org.apache.syncope.core.persistence.api.entity.resource.Provision; import org.apache.syncope.core.persistence.jpa.AbstractTest; +import org.identityconnectors.framework.common.objects.ObjectClass; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -40,6 +44,9 @@ public class VirSchemaTest extends AbstractTest { @Autowired private VirSchemaDAO virSchemaDAO; + @Autowired + private ExternalResourceDAO resourceDAO; + @Test public void findAll() { List<VirSchema> list = virSchemaDAO.findAll(); @@ -54,8 +61,13 @@ public class VirSchemaTest extends AbstractTest { @Test public void save() { + ExternalResource csv = resourceDAO.find("resource-csv"); + Provision provision = csv.getProvision(ObjectClass.ACCOUNT); + assertNotNull(provision); + VirSchema virSchema = entityFactory.newEntity(VirSchema.class); virSchema.setKey("virtual"); + virSchema.setProvision(provision); virSchema.setReadonly(true); virSchema.setExtAttrName("EXT_ATTR"); http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SchemaDataBinderImpl.java ---------------------------------------------------------------------- diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SchemaDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SchemaDataBinderImpl.java index 006a998..6e9837f 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SchemaDataBinderImpl.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SchemaDataBinderImpl.java @@ -221,23 +221,21 @@ public class SchemaDataBinderImpl implements SchemaDataBinder { private VirSchema fill(final VirSchema schema, final VirSchemaTO schemaTO) { BeanUtils.copyProperties(schemaTO, schema, IGNORE_PROPERTIES); - VirSchema merged = virSchemaDAO.save(schema); - if (schemaTO.getAnyTypeClass() != null - && (merged.getAnyTypeClass() == null - || !schemaTO.getAnyTypeClass().equals(merged.getAnyTypeClass().getKey()))) { + && (schema.getAnyTypeClass() == null + || !schemaTO.getAnyTypeClass().equals(schema.getAnyTypeClass().getKey()))) { AnyTypeClass anyTypeClass = anyTypeClassDAO.find(schemaTO.getAnyTypeClass()); if (anyTypeClass == null) { LOG.debug("Invalid " + AnyTypeClass.class.getSimpleName() + "{}, ignoring...", schemaTO.getAnyTypeClass()); } else { - anyTypeClass.add(merged); - merged.setAnyTypeClass(anyTypeClass); + anyTypeClass.add(schema); + schema.setAnyTypeClass(anyTypeClass); } - } else if (schemaTO.getAnyTypeClass() == null && merged.getAnyTypeClass() != null) { - merged.getAnyTypeClass().remove(merged); - merged.setAnyTypeClass(null); + } else if (schemaTO.getAnyTypeClass() == null && schema.getAnyTypeClass() != null) { + schema.getAnyTypeClass().remove(schema); + schema.setAnyTypeClass(null); } Provision provision = resourceDAO.findProvision(schemaTO.getProvision()); @@ -246,9 +244,9 @@ public class SchemaDataBinderImpl implements SchemaDataBinder { sce.getElements().add("Provision " + schemaTO.getProvision() + " not found"); throw sce; } - merged.setProvision(provision); + schema.setProvision(provision); - return merged; + return virSchemaDAO.save(schema); } @Override http://git-wip-us.apache.org/repos/asf/syncope/blob/e20dd0ae/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirSchemaITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirSchemaITCase.java index caae156..c4e4ea0 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirSchemaITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirSchemaITCase.java @@ -112,8 +112,15 @@ public class VirSchemaITCase extends AbstractITCase { @Test public void issueSYNCOPE418() { + ResourceTO ws1 = resourceService.read(RESOURCE_NAME_WS1); + assertNotNull(ws1); + assertEquals(1, ws1.getProvisions().size()); + assertTrue(ws1.getProvisions().get(0).getVirSchemas().isEmpty()); + VirSchemaTO schema = new VirSchemaTO(); schema.setKey("http://schemas.examples.org/security/authorization/organizationUnit"); + schema.setExtAttrName("name"); + schema.setProvision(ws1.getProvisions().get(0).getKey()); try { createSchema(SchemaType.VIRTUAL, schema); @@ -121,7 +128,7 @@ public class VirSchemaITCase extends AbstractITCase { } catch (SyncopeClientException e) { assertEquals(ClientExceptionType.InvalidVirSchema, e.getType()); - assertTrue(e.getElements().iterator().next().toString().contains(EntityViolationType.InvalidName.name())); + assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidName.name())); } } }
