syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/5] syncope git commit: Reverting changes for SYNCOPE-755 as SYNCOPE-754 has proven to be invalid
Date Fri, 22 Jan 2016 16:44:40 GMT
Repository: syncope
Updated Branches:
  refs/heads/master 8b5bfca8e -> 95709c9bd


Reverting changes for SYNCOPE-755 as SYNCOPE-754 has proven to be invalid


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/e684e61d
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/e684e61d
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/e684e61d

Branch: refs/heads/master
Commit: e684e61d6b9ef7a8be5971b23d043c6deec885d6
Parents: 537da29
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Fri Jan 22 16:43:59 2016 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Fri Jan 22 16:44:04 2016 +0100

----------------------------------------------------------------------
 .../console/panels/AnyTypeDetailsPanel.java     | 18 ++--------
 .../syncope/common/lib/to/AnyTypeClassTO.java   |  9 +++++
 .../common/lib/types/ClientExceptionType.java   |  1 +
 .../persistence/api/entity/AnyTypeClass.java    |  2 ++
 .../core/persistence/jpa/dao/JPAAnyTypeDAO.java |  9 +++--
 .../core/persistence/jpa/entity/JPAAnyType.java |  4 +--
 .../persistence/jpa/entity/JPAAnyTypeClass.java | 10 ++++++
 .../persistence/jpa/outer/AnyTypeClassTest.java |  1 -
 .../core/persistence/jpa/outer/AnyTypeTest.java | 36 +++++++++++++++-----
 .../java/data/AnyTypeClassDataBinderImpl.java   | 28 +++++++++++++++
 .../java/data/AnyTypeDataBinderImpl.java        |  3 +-
 .../fit/core/reference/AnyTypeITCase.java       | 33 ++++++++++++++++++
 12 files changed, 120 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypeDetailsPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypeDetailsPanel.java
b/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypeDetailsPanel.java
index 8f99675..c83da38 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypeDetailsPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypeDetailsPanel.java
@@ -23,15 +23,13 @@ import java.util.Arrays;
 import java.util.List;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.Transformer;
-import org.apache.syncope.client.console.SyncopeConsoleSession;
+import org.apache.syncope.client.console.rest.AnyTypeClassRestClient;
 import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
 import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel;
 import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
 import org.apache.syncope.common.lib.to.AnyTypeClassTO;
 import org.apache.syncope.common.lib.to.AnyTypeTO;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.rest.api.service.AnyTypeClassService;
-import org.apache.syncope.common.rest.api.service.AnyTypeService;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.panel.Panel;
@@ -43,11 +41,8 @@ public class AnyTypeDetailsPanel extends Panel {
 
     private static final long serialVersionUID = 8131650329622035501L;
 
-    private final AnyTypeTO anyTypeTO;
-
     public AnyTypeDetailsPanel(final String id, final AnyTypeTO anyTypeTO) {
         super(id);
-        this.anyTypeTO = anyTypeTO;
 
         final WebMarkupContainer container = new WebMarkupContainer("container");
         container.setOutputMarkupId(true);
@@ -79,21 +74,12 @@ public class AnyTypeDetailsPanel extends Panel {
     }
 
     private List<String> getAvailableAnyTypeClasses() {
-        final List<String> availableAnyTypeClasses = CollectionUtils.collect(
-                SyncopeConsoleSession.get().getService(AnyTypeClassService.class).list(),
-                new Transformer<AnyTypeClassTO, String>() {
+        return CollectionUtils.collect(new AnyTypeClassRestClient().list(), new Transformer<AnyTypeClassTO,
String>() {
 
             @Override
             public String transform(final AnyTypeClassTO input) {
                 return input.getKey();
             }
         }, new ArrayList<String>());
-
-        for (AnyTypeTO itemTO : SyncopeConsoleSession.get().getService(AnyTypeService.class).list())
{
-            if (anyTypeTO.getKey() == null || !anyTypeTO.getKey().equals(itemTO.getKey()))
{
-                availableAnyTypeClasses.removeAll(itemTO.getClasses());
-            }
-        }
-        return availableAnyTypeClasses;
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/common/lib/src/main/java/org/apache/syncope/common/lib/to/AnyTypeClassTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AnyTypeClassTO.java
b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AnyTypeClassTO.java
index 508d2cb..8e515a8 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AnyTypeClassTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AnyTypeClassTO.java
@@ -36,6 +36,8 @@ public class AnyTypeClassTO extends AbstractBaseBean {
 
     private String key;
 
+    private final List<String> types = new ArrayList<>();
+
     private final List<String> plainSchemas = new ArrayList<>();
 
     private final List<String> derSchemas = new ArrayList<>();
@@ -51,6 +53,13 @@ public class AnyTypeClassTO extends AbstractBaseBean {
         this.key = key;
     }
 
+    @XmlElementWrapper(name = "types")
+    @XmlElement(name = "type")
+    @JsonProperty("types")
+    public List<String> getTypes() {
+        return types;
+    }
+
     @XmlElementWrapper(name = "plainSchemas")
     @XmlElement(name = "schema")
     @JsonProperty("plainSchemas")

http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
b/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
index dfc5fe2..d72d3d2 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
@@ -43,6 +43,7 @@ public enum ClientExceptionType {
     InvalidRelationship(Response.Status.BAD_REQUEST),
     InvalidRelationshipType(Response.Status.BAD_REQUEST),
     InvalidAnyType(Response.Status.BAD_REQUEST),
+    InvalidAnyTypeClass(Response.Status.BAD_REQUEST),
     InvalidAnyObject(Response.Status.BAD_REQUEST),
     InvalidGroup(Response.Status.BAD_REQUEST),
     InvalidSchemaDefinition(Response.Status.BAD_REQUEST),

http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyTypeClass.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyTypeClass.java
b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyTypeClass.java
index fdd00bb..e1e5411 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyTypeClass.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/AnyTypeClass.java
@@ -24,6 +24,8 @@ public interface AnyTypeClass extends Entity<String> {
 
     void setKey(String key);
 
+    List<? extends AnyType> getTypes();
+
     boolean add(PlainSchema schema);
 
     boolean remove(PlainSchema schema);

http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyTypeDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyTypeDAO.java
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyTypeDAO.java
index c4837ae..a980209 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyTypeDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyTypeDAO.java
@@ -49,12 +49,11 @@ public class JPAAnyTypeDAO extends AbstractDAO<AnyType, String>
implements AnyTy
         return find(AnyTypeKind.GROUP.name());
     }
 
+    @Override
     public List<AnyType> findByTypeClass(final AnyTypeClass anyTypeClass) {
-        StringBuilder queryString = new StringBuilder("SELECT e FROM ").
-                append(JPAAnyType.class.getSimpleName()).
-                append(" e WHERE :anyTypeClass MEMBER OF e.classes");
-
-        TypedQuery<AnyType> query = entityManager().createQuery(queryString.toString(),
AnyType.class);
+        TypedQuery<AnyType> query = entityManager().createQuery(
+                "SELECT e FROM " + JPAAnyType.class.getSimpleName() + " e WHERE :anyTypeClass
MEMBER OF e.classes",
+                AnyType.class);
         query.setParameter("anyTypeClass", anyTypeClass);
 
         return query.getResultList();

http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyType.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyType.java
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyType.java
index d50cdba..8f99efc 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyType.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyType.java
@@ -55,9 +55,9 @@ public class JPAAnyType extends AbstractEntity<String> implements
AnyType {
 
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "anyType_name"),
+            @JoinColumn(name = "anyType_name", referencedColumnName = "name"),
             inverseJoinColumns =
-            @JoinColumn(name = "anyTypeClass_name"))
+            @JoinColumn(name = "anyTypeClass_name", referencedColumnName = "name"))
     private List<JPAAnyTypeClass> classes = new ArrayList<>();
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyTypeClass.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyTypeClass.java
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyTypeClass.java
index 6fba644..6a5e03e 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyTypeClass.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyTypeClass.java
@@ -24,8 +24,10 @@ import javax.persistence.Cacheable;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.Id;
+import javax.persistence.ManyToMany;
 import javax.persistence.OneToMany;
 import javax.persistence.Table;
+import org.apache.syncope.core.persistence.api.entity.AnyType;
 import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
 import org.apache.syncope.core.persistence.api.entity.DerSchema;
 import org.apache.syncope.core.persistence.api.entity.PlainSchema;
@@ -43,6 +45,9 @@ public class JPAAnyTypeClass extends AbstractEntity<String> implements
AnyTypeCl
     @Id
     private String name;
 
+    @ManyToMany(fetch = FetchType.EAGER, mappedBy = "classes")
+    private List<JPAAnyType> types = new ArrayList<>();
+
     @OneToMany(fetch = FetchType.EAGER, mappedBy = "anyTypeClass")
     private List<JPAPlainSchema> plainSchemas = new ArrayList<>();
 
@@ -63,6 +68,11 @@ public class JPAAnyTypeClass extends AbstractEntity<String> implements
AnyTypeCl
     }
 
     @Override
+    public List<? extends AnyType> getTypes() {
+        return types;
+    }
+
+    @Override
     public boolean add(final PlainSchema schema) {
         checkType(schema, JPAPlainSchema.class);
         return this.plainSchemas.add((JPAPlainSchema) schema);

http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnyTypeClassTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnyTypeClassTest.java
b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnyTypeClassTest.java
index cef688b..c120757 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnyTypeClassTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnyTypeClassTest.java
@@ -20,7 +20,6 @@ package org.apache.syncope.core.persistence.jpa.outer;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-
 import static org.junit.Assert.assertTrue;
 
 import org.apache.syncope.common.lib.types.AttrSchemaType;

http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnyTypeTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnyTypeTest.java
b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnyTypeTest.java
index 0f25f20..d86b4b9 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnyTypeTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnyTypeTest.java
@@ -19,6 +19,7 @@
 package org.apache.syncope.core.persistence.jpa.outer;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
@@ -41,21 +42,38 @@ public class AnyTypeTest extends AbstractTest {
     private AnyTypeClassDAO anyTypeClassDAO;
 
     @Test
-    public void delete() {
-        AnyType userType = anyTypeDAO.findUser();
-        assertNotNull(userType);
-
+    public void manyToMany() {
         AnyTypeClass other = anyTypeClassDAO.find("other");
         assertNotNull(other);
-        assertTrue(userType.getClasses().contains(other));
-        int before = userType.getClasses().size();
+
+        AnyType user = anyTypeDAO.findUser();
+        assertTrue(user.getClasses().contains(other));
+
+        AnyType group = anyTypeDAO.findGroup();
+        assertFalse(group.getClasses().contains(other));
+
+        group.add(other);
+        anyTypeDAO.save(group);
+
+        anyTypeDAO.flush();
+
+        user = anyTypeDAO.findUser();
+        assertTrue(user.getClasses().contains(other));
+        int userClassesBefore = user.getClasses().size();
+
+        group = anyTypeDAO.findGroup();
+        assertTrue(group.getClasses().contains(other));
+        int groupClassesBefore = group.getClasses().size();
 
         anyTypeClassDAO.delete("other");
 
         anyTypeDAO.flush();
 
-        userType = anyTypeDAO.findUser();
-        assertNotNull(userType);
-        assertEquals(before, userType.getClasses().size() + 1);
+        user = anyTypeDAO.findUser();
+        assertEquals(userClassesBefore, user.getClasses().size() + 1);
+
+        group = anyTypeDAO.findGroup();
+        assertEquals(groupClassesBefore, group.getClasses().size() + 1);
     }
+
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeClassDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeClassDataBinderImpl.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeClassDataBinderImpl.java
index 047633d..b5bc11a 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeClassDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeClassDataBinderImpl.java
@@ -19,10 +19,16 @@
 package org.apache.syncope.core.provisioning.java.data;
 
 import java.util.Collections;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Transformer;
+import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.to.AnyTypeClassTO;
+import org.apache.syncope.common.lib.types.ClientExceptionType;
+import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO;
 import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
 import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
 import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
+import org.apache.syncope.core.persistence.api.entity.AnyType;
 import org.apache.syncope.core.persistence.api.entity.EntityFactory;
 import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
 import org.apache.syncope.core.persistence.api.entity.DerSchema;
@@ -49,6 +55,9 @@ public class AnyTypeClassDataBinderImpl implements AnyTypeClassDataBinder
{
     private VirSchemaDAO virSchemaDAO;
 
     @Autowired
+    private AnyTypeDAO anyTypeDAO;
+
+    @Autowired
     private EntityFactory entityFactory;
 
     @Override
@@ -64,6 +73,20 @@ public class AnyTypeClassDataBinderImpl implements AnyTypeClassDataBinder
{
             anyTypeClass.setKey(anyTypeClassTO.getKey());
         }
 
+        if (!CollectionUtils.disjunction(
+                CollectionUtils.collect(anyTypeClass.getTypes(), new Transformer<AnyType,
String>() {
+
+                    @Override
+                    public String transform(final AnyType anyType) {
+                        return anyType.getKey();
+                    }
+                }), anyTypeClassTO.getTypes()).isEmpty()) {
+
+            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidAnyTypeClass);
+            sce.getElements().add("Cannot update types from classes, do the other way round");
+            throw sce;
+        }
+
         for (PlainSchema schema : plainSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass)))
{
             schema.setAnyTypeClass(null);
         }
@@ -115,6 +138,11 @@ public class AnyTypeClassDataBinderImpl implements AnyTypeClassDataBinder
{
         AnyTypeClassTO anyTypeClassTO = new AnyTypeClassTO();
 
         anyTypeClassTO.setKey(anyTypeClass.getKey());
+
+        for (AnyType anyType : anyTypeDAO.findByTypeClass(anyTypeClass)) {
+            anyTypeClassTO.getTypes().add(anyType.getKey());
+        }
+
         for (PlainSchema schema : anyTypeClass.getPlainSchemas()) {
             anyTypeClassTO.getPlainSchemas().add(schema.getKey());
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeDataBinderImpl.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeDataBinderImpl.java
index 0e85d3a..f74efbc 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeDataBinderImpl.java
@@ -20,6 +20,7 @@ package org.apache.syncope.core.provisioning.java.data;
 
 import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.to.AnyTypeTO;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.core.persistence.api.dao.AnyTypeClassDAO;
 import org.apache.syncope.core.persistence.api.entity.EntityFactory;
@@ -59,7 +60,7 @@ public class AnyTypeDataBinderImpl implements AnyTypeDataBinder {
         }
         if (anyType.getKind() != anyTypeTO.getKind()) {
             SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidAnyType);
-            sce.getElements().add("AnyTypeKind cannot be changed");
+            sce.getElements().add(AnyTypeKind.class.getSimpleName() + " cannot be changed");
             throw sce;
         }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/e684e61d/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyTypeITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyTypeITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyTypeITCase.java
index 58b1004..b82aabd 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyTypeITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyTypeITCase.java
@@ -165,4 +165,37 @@ public class AnyTypeITCase extends AbstractITCase {
         assertNotNull(other);
         assertFalse(other.getClasses().contains(newClass.getKey()));
     }
+
+    @Test
+    public void issueSYNCOPE754() {
+        AnyTypeClassTO other = anyTypeClassService.read("other");
+        assertNotNull(other);
+
+        AnyTypeTO group = anyTypeService.read(AnyTypeKind.GROUP.name());
+        try {
+            assertFalse(group.getClasses().contains("other"));
+            group.getClasses().add("other");
+
+            anyTypeService.update(group);
+
+            group = anyTypeService.read(AnyTypeKind.GROUP.name());
+            assertTrue(group.getClasses().contains("other"));
+
+            other = anyTypeClassService.read("other");
+            assertEquals(2, other.getTypes().size());
+            assertTrue(other.getTypes().contains(AnyTypeKind.USER.name()));
+            assertTrue(other.getTypes().contains(AnyTypeKind.GROUP.name()));
+
+            other.getTypes().remove(AnyTypeKind.GROUP.name());
+            try {
+                anyTypeClassService.update(other);
+                fail();
+            } catch (SyncopeClientException e) {
+                assertEquals(ClientExceptionType.InvalidAnyTypeClass, e.getType());
+            }
+        } finally {
+            group.getClasses().remove("other");
+            anyTypeService.update(group);
+        }
+    }
 }


Mime
View raw message