You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/01/12 17:31:54 UTC
[15/52] [abbrv] [partial] syncope git commit: [SYNCOPE-620] Unit
tests all in
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ConnInstanceTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ConnInstanceTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ConnInstanceTest.java
new file mode 100644
index 0000000..476672b
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ConnInstanceTest.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.server.persistence.jpa.relationship;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import org.apache.syncope.common.lib.types.ConnectorCapability;
+import org.apache.syncope.server.persistence.api.dao.ConnInstanceDAO;
+import org.apache.syncope.server.persistence.api.dao.ExternalResourceDAO;
+import org.apache.syncope.server.persistence.api.entity.ConnInstance;
+import org.apache.syncope.server.persistence.api.entity.ExternalResource;
+import org.apache.syncope.server.persistence.jpa.AbstractTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class ConnInstanceTest extends AbstractTest {
+
+ @Autowired
+ private ExternalResourceDAO resourceDAO;
+
+ @Autowired
+ private ConnInstanceDAO connInstanceDAO;
+
+ @Test
+ public void deleteCascade() {
+ ConnInstance connInstance = connInstanceDAO.find(103L);
+ assertNotNull(connInstance);
+
+ List<? extends ExternalResource> resources = connInstance.getResources();
+ assertNotNull(resources);
+ assertFalse(resources.isEmpty());
+
+ connInstanceDAO.delete(connInstance.getKey());
+
+ connInstanceDAO.flush();
+
+ ConnInstance actual = connInstanceDAO.find(103L);
+ assertNull(actual);
+
+ for (ExternalResource resource : resources) {
+ assertNull(resourceDAO.find(resource.getKey()));
+ }
+ }
+
+ /**
+ * Connector change used to miss connector bean registration.
+ *
+ * http://code.google.com/p/syncope/issues/detail?id=176
+ */
+ @Test
+ public void issue176() {
+ ConnInstance connInstance = connInstanceDAO.find(103L);
+ assertNotNull(connInstance);
+ assertTrue(connInstance.getCapabilities().isEmpty());
+
+ List<? extends ExternalResource> resources = connInstance.getResources();
+ assertNotNull(resources);
+ assertEquals(4, resources.size());
+ assertTrue(
+ "ws-target-resource-nopropagation".equalsIgnoreCase(resources.get(0).getKey())
+ || "ws-target-resource-nopropagation".equalsIgnoreCase(resources.get(1).getKey())
+ || "ws-target-resource-nopropagation".equalsIgnoreCase(resources.get(2).getKey())
+ || "ws-target-resource-nopropagation".equalsIgnoreCase(resources.get(3).getKey()));
+
+ connInstance.addCapability(ConnectorCapability.SEARCH);
+
+ connInstance = connInstanceDAO.save(connInstance);
+ assertNotNull(connInstance);
+ assertFalse(connInstance.getCapabilities().isEmpty());
+
+ resources = connInstance.getResources();
+ assertNotNull(resources);
+ assertEquals(4, resources.size());
+ assertTrue(
+ "ws-target-resource-nopropagation".equalsIgnoreCase(resources.get(0).getKey())
+ || "ws-target-resource-nopropagation".equalsIgnoreCase(resources.get(1).getKey())
+ || "ws-target-resource-nopropagation".equalsIgnoreCase(resources.get(2).getKey())
+ || "ws-target-resource-nopropagation".equalsIgnoreCase(resources.get(3).getKey()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/DerSchemaTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/DerSchemaTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/DerSchemaTest.java
new file mode 100644
index 0000000..933546b
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/DerSchemaTest.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.server.persistence.jpa.relationship;
+
+import static org.junit.Assert.assertNull;
+
+import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.syncope.server.persistence.api.dao.DerAttrDAO;
+import org.apache.syncope.server.persistence.api.dao.DerSchemaDAO;
+import org.apache.syncope.server.persistence.api.dao.UserDAO;
+import org.apache.syncope.server.persistence.api.entity.user.UDerAttr;
+import org.apache.syncope.server.persistence.api.entity.user.UDerSchema;
+import org.apache.syncope.server.persistence.jpa.AbstractTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class DerSchemaTest extends AbstractTest {
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private DerSchemaDAO derSchemaDAO;
+
+ @Autowired
+ private DerAttrDAO derAttrDAO;
+
+ @Test
+ public void test() {
+ UDerSchema schema = derSchemaDAO.find("cn", UDerSchema.class);
+
+ derSchemaDAO.delete(schema.getKey(), attrUtilFactory.getInstance(AttributableType.USER));
+
+ derSchemaDAO.flush();
+
+ assertNull(derSchemaDAO.find(schema.getKey(), UDerSchema.class));
+ assertNull(derAttrDAO.find(100L, UDerAttr.class));
+ assertNull(userDAO.find(3L).getDerAttr(schema.getKey()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/EntitlementTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/EntitlementTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/EntitlementTest.java
new file mode 100644
index 0000000..dfe418f
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/EntitlementTest.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.server.persistence.jpa.relationship;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.dao.EntitlementDAO;
+import org.apache.syncope.server.persistence.api.dao.RoleDAO;
+import org.apache.syncope.server.persistence.api.entity.Entitlement;
+import org.apache.syncope.server.persistence.api.entity.role.Role;
+import org.apache.syncope.server.persistence.jpa.AbstractTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class EntitlementTest extends AbstractTest {
+
+ @Autowired
+ private EntitlementDAO entitlementDAO;
+
+ @Autowired
+ private RoleDAO roleDAO;
+
+ @Test
+ public void delete() {
+ Entitlement entitlement = entitlementDAO.find("base");
+ assertNotNull("did not find expected entitlement", entitlement);
+
+ List<Role> roles = roleDAO.findByEntitlement(entitlement);
+ assertEquals("expected two roles", 2, roles.size());
+
+ entitlementDAO.delete("base");
+
+ roles = roleDAO.findByEntitlement(entitlement);
+ assertTrue(roles.isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/MembershipTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/MembershipTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/MembershipTest.java
new file mode 100644
index 0000000..78be82b
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/MembershipTest.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.server.persistence.jpa.relationship;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.syncope.server.persistence.api.dao.MembershipDAO;
+import org.apache.syncope.server.persistence.api.dao.RoleDAO;
+import org.apache.syncope.server.persistence.api.entity.membership.Membership;
+import org.apache.syncope.server.persistence.api.entity.role.Role;
+import org.apache.syncope.server.persistence.api.entity.user.User;
+import org.apache.syncope.server.persistence.jpa.AbstractTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class MembershipTest extends AbstractTest {
+
+ @Autowired
+ private MembershipDAO membershipDAO;
+
+ @Autowired
+ private RoleDAO roleDAO;
+
+ @Test
+ public void delete() {
+ Membership membership = membershipDAO.find(4L);
+ User user = membership.getUser();
+ Role role = membership.getRole();
+
+ membershipDAO.delete(4L);
+
+ membershipDAO.flush();
+
+ for (Membership m : user.getMemberships()) {
+ assertTrue(m.getKey() != 4L);
+ }
+ for (Membership m : roleDAO.findMemberships(role)) {
+ assertTrue(m.getKey() != 4L);
+ }
+ }
+
+ @Test
+ public void deleteAndCreate() {
+ Membership membership = membershipDAO.find(3L);
+ User user = membership.getUser();
+ Role role = membership.getRole();
+
+ // 1. delete that membership
+ membershipDAO.delete(membership.getKey());
+
+ // if not flushing here, the INSERT below will be executed
+ // before the DELETE above
+ membershipDAO.flush();
+
+ // 2. (in the same transaction) create new membership with same user
+ // and role (in order to check the UNIQE constraint on Membership)
+ membership = entityFactory.newEntity(Membership.class);
+ membership.setUser(user);
+ membership.setRole(role);
+
+ membership = membershipDAO.save(membership);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/PlainSchemaTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/PlainSchemaTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/PlainSchemaTest.java
new file mode 100644
index 0000000..7e59f9b
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/PlainSchemaTest.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.server.persistence.jpa.relationship;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.syncope.server.persistence.api.dao.ExternalResourceDAO;
+import org.apache.syncope.server.persistence.api.dao.PlainAttrDAO;
+import org.apache.syncope.server.persistence.api.dao.PlainSchemaDAO;
+import org.apache.syncope.server.persistence.api.dao.UserDAO;
+import org.apache.syncope.server.persistence.api.entity.ExternalResource;
+import org.apache.syncope.server.persistence.api.entity.MappingItem;
+import org.apache.syncope.server.persistence.api.entity.user.UPlainAttr;
+import org.apache.syncope.server.persistence.api.entity.user.UPlainSchema;
+import org.apache.syncope.server.persistence.jpa.AbstractTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class PlainSchemaTest extends AbstractTest {
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private PlainSchemaDAO plainSchemaDAO;
+
+ @Autowired
+ private PlainAttrDAO plainAttrDAO;
+
+ @Autowired
+ private ExternalResourceDAO resourceDAO;
+
+ @Test
+ public void deleteFullname() {
+ // fullname is mapped as AccountId for ws-target-resource-2, need to swap it otherwise validation errors
+ // will be raised
+ for (MappingItem item : resourceDAO.find("ws-target-resource-2").getUmapping().getItems()) {
+ if ("fullname".equals(item.getIntAttrName())) {
+ item.setAccountid(false);
+ } else if ("surname".equals(item.getIntAttrName())) {
+ item.setAccountid(true);
+ }
+ }
+
+ // search for user schema fullname
+ UPlainSchema schema = plainSchemaDAO.find("fullname", UPlainSchema.class);
+ assertNotNull(schema);
+
+ // check for associated mappings
+ Set<MappingItem> mapItems = new HashSet<>();
+ for (ExternalResource resource : resourceDAO.findAll()) {
+ if (resource.getUmapping() != null) {
+ for (MappingItem mapItem : resource.getUmapping().getItems()) {
+ if (schema.getKey().equals(mapItem.getIntAttrName())) {
+ mapItems.add(mapItem);
+ }
+ }
+ }
+ }
+ assertFalse(mapItems.isEmpty());
+
+ // delete user schema fullname
+ plainSchemaDAO.delete("fullname", attrUtilFactory.getInstance(AttributableType.USER));
+
+ plainSchemaDAO.flush();
+
+ // check for schema deletion
+ schema = plainSchemaDAO.find("fullname", UPlainSchema.class);
+ assertNull(schema);
+
+ plainSchemaDAO.clear();
+
+ // check for mappings deletion
+ mapItems = new HashSet<>();
+ for (ExternalResource resource : resourceDAO.findAll()) {
+ if (resource.getUmapping() != null) {
+ for (MappingItem mapItem : resource.getUmapping().getItems()) {
+ if ("fullname".equals(mapItem.getIntAttrName())) {
+ mapItems.add(mapItem);
+ }
+ }
+ }
+ }
+ assertTrue(mapItems.isEmpty());
+
+ assertNull(plainAttrDAO.find(100L, UPlainAttr.class));
+ assertNull(plainAttrDAO.find(300L, UPlainAttr.class));
+ assertNull(userDAO.find(1L).getPlainAttr("fullname"));
+ assertNull(userDAO.find(3L).getPlainAttr("fullname"));
+ }
+
+ @Test
+ public void deleteSurname() {
+ // search for user schema fullname
+ UPlainSchema schema = plainSchemaDAO.find("surname", UPlainSchema.class);
+ assertNotNull(schema);
+
+ // check for associated mappings
+ Set<MappingItem> mappings = new HashSet<>();
+ for (ExternalResource resource : resourceDAO.findAll()) {
+ if (resource.getUmapping() != null) {
+ for (MappingItem mapItem : resource.getUmapping().getItems()) {
+ if (schema.getKey().equals(mapItem.getIntAttrName())) {
+ mappings.add(mapItem);
+ }
+ }
+ }
+ }
+ assertFalse(mappings.isEmpty());
+
+ // delete user schema fullname
+ plainSchemaDAO.delete("surname", attrUtilFactory.getInstance(AttributableType.USER));
+
+ plainSchemaDAO.flush();
+
+ // check for schema deletion
+ schema = plainSchemaDAO.find("surname", UPlainSchema.class);
+ assertNull(schema);
+ }
+
+ @Test
+ public void deleteALong() {
+ assertEquals(6, resourceDAO.find("resource-db-sync").getUmapping().getItems().size());
+
+ plainSchemaDAO.delete("aLong", attrUtilFactory.getInstance(AttributableType.USER));
+ assertNull(plainSchemaDAO.find("aLong", UPlainSchema.class));
+
+ plainSchemaDAO.flush();
+
+ assertEquals(5, resourceDAO.find("resource-db-sync").getUmapping().getItems().size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ReportTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ReportTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ReportTest.java
new file mode 100644
index 0000000..c96e44b
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ReportTest.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.server.persistence.jpa.relationship;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.Date;
+import javax.persistence.EntityExistsException;
+import org.apache.syncope.common.lib.types.ReportExecStatus;
+import org.apache.syncope.server.persistence.api.dao.ReportDAO;
+import org.apache.syncope.server.persistence.api.dao.ReportExecDAO;
+import org.apache.syncope.server.persistence.api.entity.Report;
+import org.apache.syncope.server.persistence.api.entity.ReportExec;
+import org.apache.syncope.server.persistence.jpa.AbstractTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class ReportTest extends AbstractTest {
+
+ @Autowired
+ private ReportDAO reportDAO;
+
+ @Autowired
+ private ReportExecDAO reportExecDAO;
+
+ @Test
+ public void find() {
+ Report report = reportDAO.find(1L);
+ assertNotNull(report);
+
+ assertNotNull(report.getExecs());
+ assertFalse(report.getExecs().isEmpty());
+ assertEquals(1, report.getExecs().size());
+ }
+
+ @Test(expected = EntityExistsException.class)
+ public void saveWithExistingName() {
+ Report report = reportDAO.find(1L);
+ assertNotNull(report);
+
+ String name = report.getName();
+
+ report = entityFactory.newEntity(Report.class);
+ report.setName(name);
+
+ reportDAO.save(report);
+ reportDAO.flush();
+ }
+
+ @Test
+ public void save() {
+ Report report = reportDAO.find(1L);
+ assertNotNull(report);
+ assertEquals(1, report.getExecs().size());
+
+ ReportExec reportExec = entityFactory.newEntity(ReportExec.class);
+ reportExec.setReport(report);
+ reportExec.setStartDate(new Date());
+ reportExec.setEndDate(new Date());
+ reportExec.setStatus(ReportExecStatus.SUCCESS);
+
+ report.addExec(reportExec);
+
+ reportExec = reportExecDAO.save(reportExec);
+ assertNotNull(reportExec);
+ assertNotNull(reportExec.getKey());
+
+ reportExecDAO.flush();
+
+ report = reportDAO.find(1L);
+ assertNotNull(report);
+ assertEquals(2, report.getExecs().size());
+ }
+
+ @Test
+ public void deleteReport() {
+ reportDAO.delete(1L);
+
+ reportDAO.flush();
+
+ assertNull(reportDAO.find(1L));
+ assertNull(reportExecDAO.find(1L));
+ }
+
+ @Test
+ public void deleteReportExecution() {
+ ReportExec execution = reportExecDAO.find(1L);
+ int executionNumber = execution.getReport().getExecs().size();
+
+ reportExecDAO.delete(1L);
+
+ reportExecDAO.flush();
+
+ assertNull(reportExecDAO.find(1L));
+
+ Report report = reportDAO.find(1L);
+ assertEquals(report.getExecs().size(), executionNumber - 1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ResourceTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ResourceTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ResourceTest.java
new file mode 100644
index 0000000..c5fbf29
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/ResourceTest.java
@@ -0,0 +1,295 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.server.persistence.jpa.relationship;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.persistence.EntityManager;
+import org.apache.syncope.common.lib.types.IntMappingType;
+import org.apache.syncope.common.lib.types.MappingPurpose;
+import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.server.persistence.api.dao.ConnInstanceDAO;
+import org.apache.syncope.server.persistence.api.dao.ExternalResourceDAO;
+import org.apache.syncope.server.persistence.api.dao.PolicyDAO;
+import org.apache.syncope.server.persistence.api.dao.TaskDAO;
+import org.apache.syncope.server.persistence.api.dao.UserDAO;
+import org.apache.syncope.server.persistence.api.entity.ConnInstance;
+import org.apache.syncope.server.persistence.api.entity.ExternalResource;
+import org.apache.syncope.server.persistence.api.entity.PasswordPolicy;
+import org.apache.syncope.server.persistence.api.entity.role.RMappingItem;
+import org.apache.syncope.server.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.server.persistence.api.entity.user.UMapping;
+import org.apache.syncope.server.persistence.api.entity.user.UMappingItem;
+import org.apache.syncope.server.persistence.api.entity.user.User;
+import org.apache.syncope.server.persistence.jpa.AbstractTest;
+import org.apache.syncope.server.persistence.jpa.entity.role.JPARMappingItem;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class ResourceTest extends AbstractTest {
+
+ @Autowired
+ private EntityManager entityManager;
+
+ @Autowired
+ private ExternalResourceDAO resourceDAO;
+
+ @Autowired
+ private ConnInstanceDAO connInstanceDAO;
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private TaskDAO taskDAO;
+
+ @Autowired
+ private PolicyDAO policyDAO;
+
+ @Test
+ public void createWithPasswordPolicy() {
+ final String resourceName = "resourceWithPasswordPolicy";
+
+ PasswordPolicy policy = (PasswordPolicy) policyDAO.find(4L);
+ ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
+ resource.setKey(resourceName);
+ resource.setPasswordPolicy(policy);
+
+ ConnInstance connector = connInstanceDAO.find(100L);
+ assertNotNull("connector not found", connector);
+ resource.setConnector(connector);
+
+ ExternalResource actual = resourceDAO.save(resource);
+ assertNotNull(actual);
+
+ actual = resourceDAO.find(actual.getKey());
+ assertNotNull(actual);
+ assertNotNull(actual.getPasswordPolicy());
+
+ resourceDAO.delete(resourceName);
+ assertNull(resourceDAO.find(resourceName));
+
+ assertNotNull(policyDAO.find(4L));
+ }
+
+ @Test
+ public void save() {
+ ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
+ resource.setKey("ws-target-resource-save");
+
+ // specify the connector
+ ConnInstance connector = connInstanceDAO.find(100L);
+ assertNotNull("connector not found", connector);
+
+ resource.setConnector(connector);
+
+ UMapping mapping = entityFactory.newEntity(UMapping.class);
+ mapping.setResource(resource);
+ resource.setUmapping(mapping);
+
+ // specify mappings
+ for (int i = 0; i < 3; i++) {
+ UMappingItem item = entityFactory.newEntity(UMappingItem.class);
+ item.setExtAttrName("test" + i);
+ item.setIntAttrName("nonexistent" + i);
+ item.setIntMappingType(IntMappingType.UserSchema);
+ item.setMandatoryCondition("false");
+ item.setPurpose(MappingPurpose.SYNCHRONIZATION);
+ mapping.addItem(item);
+ item.setMapping(mapping);
+ }
+ UMappingItem accountId = entityFactory.newEntity(UMappingItem.class);
+ accountId.setExtAttrName("username");
+ accountId.setIntAttrName("username");
+ accountId.setIntMappingType(IntMappingType.UserId);
+ accountId.setPurpose(MappingPurpose.PROPAGATION);
+ mapping.setAccountIdItem(accountId);
+ accountId.setMapping(mapping);
+
+ // map a derived attribute
+ UMappingItem derived = entityFactory.newEntity(UMappingItem.class);
+ derived.setAccountid(false);
+ derived.setExtAttrName("fullname");
+ derived.setIntAttrName("cn");
+ derived.setIntMappingType(IntMappingType.UserDerivedSchema);
+ derived.setPurpose(MappingPurpose.PROPAGATION);
+ mapping.addItem(derived);
+ derived.setMapping(mapping);
+
+ // save the resource
+ ExternalResource actual = resourceDAO.save(resource);
+ assertNotNull(actual);
+ assertNotNull(actual.getUmapping());
+
+ resourceDAO.flush();
+ resourceDAO.detach(actual);
+ connInstanceDAO.detach(connector);
+
+ // assign the new resource to an user
+ User user = userDAO.find(1L);
+ assertNotNull("user not found", user);
+
+ user.addResource(actual);
+
+ resourceDAO.flush();
+
+ // retrieve resource
+ resource = resourceDAO.find(actual.getKey());
+ assertNotNull(resource);
+
+ // check connector
+ connector = connInstanceDAO.find(100L);
+ assertNotNull(connector);
+
+ assertNotNull(connector.getResources());
+ assertTrue(connector.getResources().contains(resource));
+
+ assertNotNull(resource.getConnector());
+ assertTrue(resource.getConnector().equals(connector));
+
+ // check mappings
+ List<? extends UMappingItem> items = resource.getUmapping().getItems();
+ assertNotNull(items);
+ assertEquals(5, items.size());
+
+ // check user
+ user = userDAO.find(1L);
+ assertNotNull(user);
+ assertNotNull(user.getResources());
+ assertTrue(user.getResources().contains(actual));
+ }
+
+ @Test
+ public void delete() {
+ ExternalResource resource = resourceDAO.find("ws-target-resource-2");
+ assertNotNull("find to delete did not work", resource);
+
+ // -------------------------------------
+ // Get originally associated connector
+ // -------------------------------------
+ ConnInstance connector = resource.getConnector();
+ assertNotNull(connector);
+
+ Long connectorId = connector.getKey();
+ // -------------------------------------
+
+ // -------------------------------------
+ // Get originally associated users
+ // -------------------------------------
+ List<User> users = userDAO.findByResource(resource);
+ assertNotNull(users);
+
+ Set<Long> userIds = new HashSet<Long>();
+ for (User user : users) {
+ userIds.add(user.getKey());
+ }
+ // -------------------------------------
+
+ // Get tasks
+ List<PropagationTask> propagationTasks = taskDAO.findAll(resource, TaskType.PROPAGATION);
+ assertFalse(propagationTasks.isEmpty());
+
+ // delete resource
+ resourceDAO.delete(resource.getKey());
+
+ // close the transaction
+ resourceDAO.flush();
+
+ // resource must be removed
+ ExternalResource actual = resourceDAO.find("ws-target-resource-2");
+ assertNull("delete did not work", actual);
+
+ // resource must be not referenced any more from users
+ for (Long id : userIds) {
+ User actualUser = userDAO.find(id);
+ assertNotNull(actualUser);
+ for (ExternalResource res : actualUser.getResources()) {
+ assertFalse(res.getKey().equalsIgnoreCase(resource.getKey()));
+ }
+ }
+
+ // resource must be not referenced any more from the connector
+ ConnInstance actualConnector = connInstanceDAO.find(connectorId);
+ assertNotNull(actualConnector);
+ for (ExternalResource res : actualConnector.getResources()) {
+ assertFalse(res.getKey().equalsIgnoreCase(resource.getKey()));
+ }
+
+ // there must be no tasks
+ for (PropagationTask task : propagationTasks) {
+ assertNull(taskDAO.find(task.getKey()));
+ }
+ }
+
+ @Test
+ public void emptyMapping() {
+ ExternalResource ldap = resourceDAO.find("resource-ldap");
+ assertNotNull(ldap);
+ assertNotNull(ldap.getUmapping());
+ assertNotNull(ldap.getRmapping());
+
+ List<? extends RMappingItem> items = ldap.getRmapping().getItems();
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ List<Long> itemIds = new ArrayList<Long>(items.size());
+ for (RMappingItem item : items) {
+ itemIds.add(item.getKey());
+ }
+
+ ldap.setRmapping(null);
+
+ resourceDAO.save(ldap);
+ resourceDAO.flush();
+
+ for (Long itemId : itemIds) {
+ assertNull(entityManager.find(JPARMappingItem.class, itemId));
+ }
+ }
+
+ @Test
+ public void issue243() {
+ ExternalResource csv = resourceDAO.find("resource-csv");
+ assertNotNull(csv);
+
+ int origMapItems = csv.getUmapping().getItems().size();
+
+ UMappingItem newMapItem = entityFactory.newEntity(UMappingItem.class);
+ newMapItem.setIntMappingType(IntMappingType.Username);
+ newMapItem.setExtAttrName("TEST");
+ newMapItem.setPurpose(MappingPurpose.PROPAGATION);
+ csv.getUmapping().addItem(newMapItem);
+
+ resourceDAO.save(csv);
+ resourceDAO.flush();
+
+ csv = resourceDAO.find("resource-csv");
+ assertNotNull(csv);
+ assertEquals(origMapItems + 1, csv.getUmapping().getItems().size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/RoleTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/RoleTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/RoleTest.java
new file mode 100644
index 0000000..dbf1029
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/RoleTest.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.server.persistence.jpa.relationship;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.dao.EntitlementDAO;
+import org.apache.syncope.server.persistence.api.dao.PlainAttrDAO;
+import org.apache.syncope.server.persistence.api.dao.PlainAttrValueDAO;
+import org.apache.syncope.server.persistence.api.dao.PlainSchemaDAO;
+import org.apache.syncope.server.persistence.api.dao.PolicyDAO;
+import org.apache.syncope.server.persistence.api.dao.RoleDAO;
+import org.apache.syncope.server.persistence.api.dao.UserDAO;
+import org.apache.syncope.server.persistence.api.entity.PasswordPolicy;
+import org.apache.syncope.server.persistence.api.entity.role.RPlainAttr;
+import org.apache.syncope.server.persistence.api.entity.role.RPlainAttrValue;
+import org.apache.syncope.server.persistence.api.entity.role.RPlainSchema;
+import org.apache.syncope.server.persistence.api.entity.role.Role;
+import org.apache.syncope.server.persistence.api.entity.user.User;
+import org.apache.syncope.server.persistence.jpa.AbstractTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class RoleTest extends AbstractTest {
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private RoleDAO roleDAO;
+
+ @Autowired
+ private PlainSchemaDAO plainSchemaDAO;
+
+ @Autowired
+ private PlainAttrDAO plainAttrDAO;
+
+ @Autowired
+ private PlainAttrValueDAO plainAttrValueDAO;
+
+ @Autowired
+ private EntitlementDAO entitlementDAO;
+
+ @Autowired
+ private PolicyDAO policyDAO;
+
+ @Test(expected = InvalidEntityException.class)
+ public void saveWithTwoOwners() {
+ Role root = roleDAO.find("root", null);
+ assertNotNull("did not find expected role", root);
+
+ User user = userDAO.find(1L);
+ assertNotNull("did not find expected user", user);
+
+ Role role = entityFactory.newEntity(Role.class);
+ role.setName("error");
+ role.setUserOwner(user);
+ role.setRoleOwner(root);
+
+ roleDAO.save(role);
+ }
+
+ @Test
+ public void findByOwner() {
+ Role role = roleDAO.find(6L);
+ assertNotNull("did not find expected role", role);
+
+ User user = userDAO.find(5L);
+ assertNotNull("did not find expected user", user);
+
+ assertEquals(user, role.getUserOwner());
+
+ Role child1 = roleDAO.find(7L);
+ assertNotNull(child1);
+ assertEquals(role, child1.getParent());
+
+ Role child2 = roleDAO.find(10L);
+ assertNotNull(child2);
+ assertEquals(role, child2.getParent());
+
+ List<Role> ownedRoles = roleDAO.findOwnedByUser(user.getKey());
+ assertFalse(ownedRoles.isEmpty());
+ assertEquals(2, ownedRoles.size());
+ assertTrue(ownedRoles.contains(role));
+ assertTrue(ownedRoles.contains(child1));
+ assertFalse(ownedRoles.contains(child2));
+ }
+
+ public void createWithPasswordPolicy() {
+ PasswordPolicy policy = (PasswordPolicy) policyDAO.find(4L);
+ Role role = entityFactory.newEntity(Role.class);
+ role.setName("roleWithPasswordPolicy");
+ role.setPasswordPolicy(policy);
+
+ Role actual = roleDAO.save(role);
+ assertNotNull(actual);
+
+ actual = roleDAO.find(actual.getKey());
+ assertNotNull(actual);
+ assertNotNull(actual.getPasswordPolicy());
+
+ roleDAO.delete(actual.getKey());
+ assertNull(roleDAO.find(actual.getKey()));
+
+ assertNotNull(policyDAO.find(4L));
+ }
+
+ @Test
+ public void delete() {
+ roleDAO.delete(2L);
+
+ roleDAO.flush();
+
+ assertNull(roleDAO.find(2L));
+ assertEquals(1, roleDAO.findByEntitlement(entitlementDAO.find("base")).size());
+ assertEquals(userDAO.find(2L).getRoles().size(), 2);
+ assertNull(plainAttrDAO.find(700L, RPlainAttr.class));
+ assertNull(plainAttrValueDAO.find(41L, RPlainAttrValue.class));
+ assertNotNull(plainSchemaDAO.find("icon", RPlainSchema.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/SecurityQuestionTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/SecurityQuestionTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/SecurityQuestionTest.java
new file mode 100644
index 0000000..660e3bf
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/SecurityQuestionTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.server.persistence.jpa.relationship;
+
+import static org.junit.Assert.assertNull;
+
+import org.apache.syncope.server.persistence.api.dao.SecurityQuestionDAO;
+import org.apache.syncope.server.persistence.api.dao.UserDAO;
+import org.apache.syncope.server.persistence.api.entity.user.User;
+import org.apache.syncope.server.persistence.jpa.AbstractTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class SecurityQuestionTest extends AbstractTest {
+
+ @Autowired
+ private SecurityQuestionDAO securityQuestionDAO;
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Test
+ public void test() {
+ User user = userDAO.find(4L);
+ assertNull(user.getSecurityQuestion());
+ assertNull(user.getSecurityAnswer());
+
+ user.setSecurityQuestion(securityQuestionDAO.find(1L));
+ user.setSecurityAnswer("Rossi");
+ userDAO.save(user);
+
+ userDAO.flush();
+
+ securityQuestionDAO.delete(1L);
+
+ userDAO.flush();
+
+ user = userDAO.find(4L);
+
+ assertNull(user.getSecurityQuestion());
+ assertNull(user.getSecurityAnswer());
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/TaskTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/TaskTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/TaskTest.java
new file mode 100644
index 0000000..d4a0c2a
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/TaskTest.java
@@ -0,0 +1,291 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.server.persistence.jpa.relationship;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.syncope.common.lib.types.MatchingRule;
+import org.apache.syncope.common.lib.types.PropagationMode;
+import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
+import org.apache.syncope.common.lib.types.ResourceOperation;
+import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.common.lib.types.UnmatchingRule;
+import org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.server.persistence.api.dao.ExternalResourceDAO;
+import org.apache.syncope.server.persistence.api.dao.TaskDAO;
+import org.apache.syncope.server.persistence.api.dao.TaskExecDAO;
+import org.apache.syncope.server.persistence.api.dao.UserDAO;
+import org.apache.syncope.server.persistence.api.entity.ExternalResource;
+import org.apache.syncope.server.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.server.persistence.api.entity.task.PushTask;
+import org.apache.syncope.server.persistence.api.entity.task.SyncTask;
+import org.apache.syncope.server.persistence.api.entity.task.TaskExec;
+import org.apache.syncope.server.persistence.api.entity.user.User;
+import org.apache.syncope.server.persistence.jpa.AbstractTest;
+import org.apache.syncope.server.provisioning.api.sync.SyncActions;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.AttributeBuilder;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class TaskTest extends AbstractTest {
+
+ @Autowired
+ private TaskDAO taskDAO;
+
+ @Autowired
+ private TaskExecDAO taskExecDAO;
+
+ @Autowired
+ private ExternalResourceDAO resourceDAO;
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Test
+ public void read() {
+ PropagationTask task = taskDAO.find(1L);
+ assertNotNull(task);
+
+ assertNotNull(task.getExecs());
+ assertFalse(task.getExecs().isEmpty());
+ assertEquals(1, task.getExecs().size());
+ }
+
+ @Test
+ public void save() {
+ ExternalResource resource = resourceDAO.find("ws-target-resource-1");
+ assertNotNull(resource);
+
+ User user = userDAO.find(2L);
+ assertNotNull(user);
+
+ PropagationTask task = entityFactory.newEntity(PropagationTask.class);
+ task.setResource(resource);
+ task.setSubjectType(AttributableType.USER);
+ task.setPropagationMode(PropagationMode.TWO_PHASES);
+ task.setPropagationOperation(ResourceOperation.CREATE);
+ task.setAccountId("one@two.com");
+
+ Set<Attribute> attributes = new HashSet<>();
+ attributes.add(AttributeBuilder.build("testAttribute", "testValue1", "testValue2"));
+ attributes.add(AttributeBuilder.buildPassword("password".toCharArray()));
+ task.setAttributes(attributes);
+
+ task = taskDAO.save(task);
+ assertNotNull(task);
+
+ PropagationTask actual = taskDAO.find(task.getKey());
+ assertEquals(task, actual);
+
+ taskDAO.flush();
+
+ resource = resourceDAO.find("ws-target-resource-1");
+ assertTrue(taskDAO.findAll(resource, TaskType.PROPAGATION).contains(task));
+ }
+
+ @Test
+ public void addPropagationTaskExecution() {
+ PropagationTask task = taskDAO.find(1L);
+ assertNotNull(task);
+
+ int executionNumber = task.getExecs().size();
+
+ TaskExec execution = entityFactory.newEntity(TaskExec.class);
+ execution.setTask(task);
+ execution.setStatus(PropagationTaskExecStatus.CREATED.name());
+ task.addExec(execution);
+ execution.setStartDate(new Date());
+
+ taskDAO.save(task);
+ taskDAO.flush();
+
+ task = taskDAO.find(1L);
+ assertNotNull(task);
+
+ assertEquals(executionNumber + 1, task.getExecs().size());
+ }
+
+ @Test
+ public void addSyncTaskExecution() {
+ SyncTask task = taskDAO.find(4L);
+ assertNotNull(task);
+
+ int executionNumber = task.getExecs().size();
+
+ TaskExec execution = entityFactory.newEntity(TaskExec.class);
+ execution.setStatus("Text-free status");
+ execution.setTask(task);
+ task.addExec(execution);
+ execution.setMessage("A message");
+
+ taskDAO.save(task);
+ taskDAO.flush();
+
+ task = taskDAO.find(4L);
+ assertNotNull(task);
+
+ assertEquals(executionNumber + 1, task.getExecs().size());
+ }
+
+ @Test
+ public void addPushTaskExecution() {
+ PushTask task = taskDAO.find(13L);
+ assertNotNull(task);
+
+ int executionNumber = task.getExecs().size();
+
+ TaskExec execution = entityFactory.newEntity(TaskExec.class);
+ execution.setStatus("Text-free status");
+ execution.setTask(task);
+ task.addExec(execution);
+ execution.setMessage("A message");
+
+ taskDAO.save(task);
+ taskDAO.flush();
+
+ task = taskDAO.find(13L);
+ assertNotNull(task);
+
+ assertEquals(executionNumber + 1, task.getExecs().size());
+ }
+
+ @Test
+ public void deleteTask() {
+ taskDAO.delete(1L);
+
+ taskDAO.flush();
+
+ assertNull(taskDAO.find(1L));
+ assertNull(taskExecDAO.find(1L));
+ }
+
+ @Test
+ public void deleteTaskExecution() {
+ TaskExec execution = taskExecDAO.find(1L);
+ int executionNumber = execution.getTask().getExecs().size();
+
+ taskExecDAO.delete(1L);
+
+ taskExecDAO.flush();
+
+ assertNull(taskExecDAO.find(1L));
+
+ PropagationTask task = taskDAO.find(1L);
+ assertEquals(task.getExecs().size(), executionNumber - 1);
+ }
+
+ @Test
+ public void saveSyncTask() {
+ ExternalResource resource = resourceDAO.find("ws-target-resource-1");
+ assertNotNull(resource);
+
+ SyncTask task = entityFactory.newEntity(SyncTask.class);
+ task.setName("saveSyncTask");
+ task.setDescription("SyncTask description");
+ task.setUserTemplate(new UserTO());
+ task.setCronExpression("BLA BLA");
+ task.setMatchingRule(MatchingRule.UPDATE);
+ task.setUnmatchingRule(UnmatchingRule.PROVISION);
+
+ // this save() fails because of an invalid Cron Expression
+ InvalidEntityException exception = null;
+ try {
+ taskDAO.save(task);
+ } catch (InvalidEntityException e) {
+ exception = e;
+ }
+ assertNotNull(exception);
+
+ task.setCronExpression(null);
+ // this save() fails because a SyncTask requires a target resource
+ exception = null;
+ try {
+ taskDAO.save(task);
+ } catch (InvalidEntityException e) {
+ exception = e;
+ }
+ assertNotNull(exception);
+
+ task.setResource(resource);
+ task.getActionsClassNames().add(getClass().getName());
+
+ // this save() fails because jobActionsClassName does not implement
+ // the right interface
+ exception = null;
+ try {
+ taskDAO.save(task);
+ } catch (InvalidEntityException e) {
+ exception = e;
+ }
+ assertNotNull(exception);
+
+ task.getActionsClassNames().clear();
+ task.getActionsClassNames().add(SyncActions.class.getName());
+ // this save() finally works
+ task = taskDAO.save(task);
+ assertNotNull(task);
+
+ SyncTask actual = taskDAO.find(task.getKey());
+ assertEquals(task, actual);
+ }
+
+ @Test
+ public void issueSYNCOPE144() {
+ ExternalResource resource = resourceDAO.find("ws-target-resource-1");
+ assertNotNull(resource);
+
+ SyncTask task = entityFactory.newEntity(SyncTask.class);
+
+ task.setResource(resource);
+ task.setName("issueSYNCOPE144");
+ task.setDescription("issueSYNCOPE144 Description");
+ task.getActionsClassNames().add(SyncActions.class.getName());
+ task.setMatchingRule(MatchingRule.UPDATE);
+ task.setUnmatchingRule(UnmatchingRule.PROVISION);
+
+ task = taskDAO.save(task);
+ assertNotNull(task);
+
+ SyncTask actual = taskDAO.find(task.getKey());
+ assertEquals(task, actual);
+ assertEquals("issueSYNCOPE144", actual.getName());
+ assertEquals("issueSYNCOPE144 Description", actual.getDescription());
+
+ actual.setName("issueSYNCOPE144_2");
+ actual.setDescription("issueSYNCOPE144 Description_2");
+
+ actual = taskDAO.save(actual);
+ assertNotNull(actual);
+ assertEquals("issueSYNCOPE144_2", actual.getName());
+ assertEquals("issueSYNCOPE144 Description_2", actual.getDescription());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/UserTest.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/UserTest.java b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/UserTest.java
new file mode 100644
index 0000000..f8c09b6f
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/java/org/apache/syncope/server/persistence/jpa/relationship/UserTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.server.persistence.jpa.relationship;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import org.apache.syncope.server.persistence.api.dao.PlainAttrDAO;
+import org.apache.syncope.server.persistence.api.dao.PlainAttrValueDAO;
+import org.apache.syncope.server.persistence.api.dao.PlainSchemaDAO;
+import org.apache.syncope.server.persistence.api.dao.RoleDAO;
+import org.apache.syncope.server.persistence.api.dao.UserDAO;
+import org.apache.syncope.server.persistence.api.entity.membership.Membership;
+import org.apache.syncope.server.persistence.api.entity.user.UPlainAttr;
+import org.apache.syncope.server.persistence.api.entity.user.UPlainAttrValue;
+import org.apache.syncope.server.persistence.api.entity.user.UPlainSchema;
+import org.apache.syncope.server.persistence.jpa.AbstractTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class UserTest extends AbstractTest {
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private RoleDAO roleDAO;
+
+ @Autowired
+ private PlainSchemaDAO plainSchemaDAO;
+
+ @Autowired
+ private PlainAttrDAO plainAttrDAO;
+
+ @Autowired
+ private PlainAttrValueDAO plainAttrValueDAO;
+
+ @Test
+ public void test() {
+ userDAO.delete(4L);
+
+ userDAO.flush();
+
+ assertNull(userDAO.find(4L));
+ assertNull(plainAttrDAO.find(550L, UPlainAttr.class));
+ assertNull(plainAttrValueDAO.find(22L, UPlainAttrValue.class));
+ assertNotNull(plainSchemaDAO.find("loginDate", UPlainSchema.class));
+
+ List<Membership> memberships = roleDAO.findMemberships(roleDAO.find(7L));
+ assertTrue(memberships.isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/resources/content.xml
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/resources/content.xml b/syncope620/server/persistence-jpa/src/test/resources/content.xml
index 04ee462..1f9c8b8 100644
--- a/syncope620/server/persistence-jpa/src/test/resources/content.xml
+++ b/syncope620/server/persistence-jpa/src/test/resources/content.xml
@@ -214,7 +214,7 @@ under the License.
mandatoryCondition="true" multivalue="0" uniqueConstraint="1" readonly="0"/>
<UPlainSchema name="userId" type="String"
mandatoryCondition="true" multivalue="0" uniqueConstraint="1" readonly="0"
- validatorClass="org.apache.syncope.persistence.jpa.attrvalue.validation.EmailAddressValidator"/>
+ validatorClass="org.apache.syncope.server.persistence.jpa.attrvalue.validation.EmailAddressValidator"/>
<UPlainSchema name="loginDate" type="Date"
mandatoryCondition="false" multivalue="1" uniqueConstraint="0" readonly="0"
conversionPattern="yyyy-MM-dd"/>
@@ -226,7 +226,7 @@ under the License.
mandatoryCondition="false" multivalue="0" uniqueConstraint="0" readonly="0"/>
<UPlainSchema name="email" type="String"
mandatoryCondition="false" multivalue="0" uniqueConstraint="0" readonly="0"
- validatorClass="org.apache.syncope.persistence.jpa.attrvalue.validation.EmailAddressValidator"/>
+ validatorClass="org.apache.syncope.server.persistence.jpa.attrvalue.validation.EmailAddressValidator"/>
<UPlainSchema name="activationDate" type="Date"
mandatoryCondition="false" multivalue="0" uniqueConstraint="0" readonly="0"
conversionPattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ"/>
@@ -605,7 +605,7 @@ under the License.
creator="admin" lastModifier="admin"
creationDate="2010-10-20 11:00:00" lastChangeDate="2010-10-20 11:00:00"/>
<ExternalResource_PropActions externalResource_name="resource-ldap"
- action="org.apache.syncope.provisioning.api.propagation.PropagationActions"/>
+ action="org.apache.syncope.server.provisioning.api.propagation.PropagationActions"/>
<ExternalResource name="ws-target-resource-nopropagation" connector_id="103"
randomPwdIfNotProvided="0" enforceMandatoryCondition="1" propagationMode="TWO_PHASES"
propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL"
@@ -903,91 +903,91 @@ under the License.
xmlAttributes='[{"name":"__PASSWORD__","value":[{"readOnly":false,"disposed":false,"encryptedBytes":"m9nh2US0Sa6m+cXccCq0Xw==","base64SHA1Hash":"GFJ69qfjxEOdrmt+9q+0Cw2uz60="}]},{"name":"__NAME__","value":["userId"],"nameValue":"userId"},{"name":"type","value":["type"]}]'/>
<Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="4" name="CSV (update matching; assign unmatching)" resource_name="resource-csv"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1" fullReconciliation="0"
- jobClassName="org.apache.syncope.provisioning.api.job.SyncJob" unmatchingRule="ASSIGN" matchingRule="UPDATE"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.SyncJob" unmatchingRule="ASSIGN" matchingRule="UPDATE"
userTemplate='{"creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"password":null,"status":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"attributes":[{"schema":"type","readonly":false,"values":["email == 'test8@syncope.apache.org'? 'TYPE_8': 'TYPE_OTHER'"]}],"derivedAttributes":[{"schema":"cn","readonly":false,"values":[null]}],"virtualAttributes":[],"resources":["resource-testdb"],"propagationStatuses":[],"memberships":[{"creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"id":0,"roleId":8,"roleName":null,"attributes":[{"schema":"subscriptionDate","readonly":false,"values":["'2009-08-18T16:33:12.203+0200'"]}],"derivedAttributes":[],"virtualAttributes":[]}]}'
roleTemplate='{"creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"name":null,"parent":0,"userOwner":null,"roleOwner":null,"inheritOwner":false,"inheritTemplates":false,"inheritPlainAttrs":false,"inheritDerAttrs":false,"inheritVirAttrs":false,"inheritPasswordPolicy":false,"inheritAccountPolicy":false,"passwordPolicy":null,"accountPolicy":null,"attributes":[],"derivedAttributes":[],"virtualAttributes":[],"resources":[],"propagationStatuses":[],"entitlements":[],"rAttrTemplates":[],"rDerAttrTemplates":[],"rVirAttrTemplates":[],"mAttrTemplates":[],"mDerAttrTemplates":[],"mVirAttrTemplates":[]}'/>
- <Task DTYPE="SchedTask" type="SCHEDULED" id="5" name="SampleJob Task" jobClassName="org.apache.syncope.core.quartz.SampleJob" cronExpression="0 0 0 1 * ?"/>
+ <Task DTYPE="SchedTask" type="SCHEDULED" id="5" name="SampleJob Task" jobClassName="org.apache.syncope.server.provisioning.java.job.SampleJob" cronExpression="0 0 0 1 * ?"/>
<Task DTYPE="PropagationTask" type="PROPAGATION" id="6" propagationMode="TWO_PHASES" propagationOperation="UPDATE"
objectClassName="__ACCOUNT__" resource_name="ws-target-resource-nopropagation" subjectType="USER" subjectId="1"
xmlAttributes='[{"name":"__PASSWORD__","value":[{"readOnly":false,"disposed":false,"encryptedBytes":"m9nh2US0Sa6m+cXccCq0Xw==","base64SHA1Hash":"GFJ69qfjxEOdrmt+9q+0Cw2uz60="}]},{"name":"__NAME__","value":["userId"],"nameValue":"userId"},{"name":"fullname","value":["fullname"]},{"name":"type","value":["type"]}]'/>
<TaskExec id="6" task_id="6" status="SUCCESS"/>
<Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="7" name="TestDB Task" resource_name="resource-testdb"
performCreate="1" performUpdate="1" performDelete="0" syncStatus="1" fullReconciliation="1"
- jobClassName="org.apache.syncope.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"
userTemplate='{"creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"password":null,"status":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"attributes":[{"schema":"type","readonly":false,"values":["'type a'"]},{"schema":"userId","readonly":false,"values":["'reconciled@syncope.apache.org'"]},{"schema":"fullname","readonly":false,"values":["'reconciled fullname'"]},{"schema":"surname","readonly":false,"values":["'surname'"]}],"derivedAttributes":[],"virtualAttributes":[],"resources":[],"propagationStatuses":[],"memberships":[]}'
roleTemplate='{"creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"name":null,"parent":0,"userOwner":null,"roleOwner":null,"inheritOwner":false,"inheritTemplates":false,"inheritPlainAttrs":false,"inheritDerAttrs":false,"inheritVirAttrs":false,"inheritPasswordPolicy":false,"inheritAccountPolicy":false,"passwordPolicy":null,"accountPolicy":null,"attributes":[],"derivedAttributes":[],"virtualAttributes":[],"resources":[],"propagationStatuses":[],"entitlements":[],"rAttrTemplates":[],"rDerAttrTemplates":[],"rVirAttrTemplates":[],"mAttrTemplates":[],"mDerAttrTemplates":[],"mVirAttrTemplates":[]}'/>
<Task DTYPE="NotificationTask" type="NOTIFICATION" id="8" sender="admin@prova.org" subject="Notification for SYNCOPE-81"
textBody="NOTIFICATION-81" htmlBody="NOTIFICATION-81" traceLevel="ALL"/>
<Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="9" name="TestDB2 Task" resource_name="resource-testdb2"
performCreate="1" performUpdate="1" performDelete="0" syncStatus="1" fullReconciliation="1"
- jobClassName="org.apache.syncope.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"/>
+ jobClassName="org.apache.syncope.server.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"/>
<Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="10" name="TestDB Sync Task" resource_name="resource-db-sync"
fullReconciliation="1" performCreate="1" performDelete="1" performUpdate="1" syncStatus="0"
- jobClassName="org.apache.syncope.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"/>
+ jobClassName="org.apache.syncope.server.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"/>
<Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="11" name="LDAP Sync Task" resource_name="resource-ldap"
fullReconciliation="1" performCreate="1" performDelete="1" performUpdate="1" syncStatus="0"
- jobClassName="org.apache.syncope.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"
userTemplate='{"creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"password":null,"status":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"attributes":[],"derivedAttributes":[],"virtualAttributes":[{"schema":"virtualReadOnly","readonly":false,"values":[""]}],"resources":["resource-ldap"],"propagationStatuses":[],"memberships":[]}'
roleTemplate='{"creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"name":null,"parent":8,"userOwner":null,"roleOwner":null,"inheritOwner":false,"inheritTemplates":false,"inheritPlainAttrs":false,"inheritDerAttrs":false,"inheritVirAttrs":false,"inheritPasswordPolicy":false,"inheritAccountPolicy":false,"passwordPolicy":null,"accountPolicy":null,"attributes":[{"schema":"show","readonly":false,"values":["'true'"]}],"derivedAttributes":[],"virtualAttributes":[],"resources":[],"propagationStatuses":[],"entitlements":[],"rAttrTemplates":["show"],"rDerAttrTemplates":[],"rVirAttrTemplates":[],"mAttrTemplates":[],"mDerAttrTemplates":[],"mVirAttrTemplates":[]}'/>
- <SyncTask_actionsClassNames SyncTask_id="11" actionClassName="org.apache.syncope.core.sync.impl.LDAPMembershipSyncActions"/>
+ <SyncTask_actionsClassNames SyncTask_id="11" actionClassName="org.apache.syncope.server.provisioning.java.sync.LDAPMembershipSyncActions"/>
<Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="12" name="VirAttrCache test" resource_name="resource-csv"
performCreate="0" performUpdate="1" performDelete="0" syncStatus="0" fullReconciliation="1"
- jobClassName="org.apache.syncope.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"/>
+ jobClassName="org.apache.syncope.server.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"/>
<Task DTYPE="PushTask" type="PUSH" id="13" name="Export on resource-testdb2" resource_name="resource-testdb2"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
- jobClassName="org.apache.syncope.provisioning.api.job.PushJob" unmatchingRule="ASSIGN" matchingRule="IGNORE"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.PushJob" unmatchingRule="ASSIGN" matchingRule="IGNORE"
userFilter="surname==Vivaldi" roleFilter="name==_NO_ONE_"/>
<Task DTYPE="PushTask" type="PUSH" id="14" name="Export on resource-testdb2" resource_name="resource-testdb2"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
- jobClassName="org.apache.syncope.provisioning.api.job.PushJob" unmatchingRule="PROVISION" matchingRule="IGNORE"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.PushJob" unmatchingRule="PROVISION" matchingRule="IGNORE"
userFilter="surname==Bellini" roleFilter="name==_NO_ONE_"/>
<Task DTYPE="PushTask" type="PUSH" id="15" name="Export on resource-testdb2" resource_name="resource-testdb2"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
- jobClassName="org.apache.syncope.provisioning.api.job.PushJob" unmatchingRule="UNLINK" matchingRule="IGNORE"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.PushJob" unmatchingRule="UNLINK" matchingRule="IGNORE"
userFilter="surname==Puccini" roleFilter="name==_NO_ONE_"/>
<Task DTYPE="PushTask" type="PUSH" id="16" name="Export on resource-testdb2" resource_name="resource-testdb2"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
- jobClassName="org.apache.syncope.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="IGNORE"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="IGNORE"
userFilter="surname==Verdi" roleFilter="name==_NO_ONE_"/>
<Task DTYPE="PushTask" type="PUSH" id="17" name="Export on resource-testdb2" resource_name="resource-testdb2"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
- jobClassName="org.apache.syncope.provisioning.api.job.PushJob" unmatchingRule="ASSIGN" matchingRule="UPDATE"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.PushJob" unmatchingRule="ASSIGN" matchingRule="UPDATE"
userFilter="username==_NO_ONE_" roleFilter="name==_NO_ONE_"/>
<Task DTYPE="PushTask" type="PUSH" id="18" name="Export on resource-testdb2" resource_name="resource-testdb2"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
- jobClassName="org.apache.syncope.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="DEPROVISION"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="DEPROVISION"
userFilter="surname==Verdi" roleFilter="name==_NO_ONE_"/>
<Task DTYPE="PushTask" type="PUSH" id="19" name="Export on resource-testdb2" resource_name="resource-testdb2"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
- jobClassName="org.apache.syncope.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="UNASSIGN"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="UNASSIGN"
userFilter="surname==Rossini" roleFilter="name==_NO_ONE_"/>
<Task DTYPE="PushTask" type="PUSH" id="20" name="Export on resource-testdb2" resource_name="resource-testdb2"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
- jobClassName="org.apache.syncope.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="LINK"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="LINK"
userFilter="surname==Verdi" roleFilter="name==_NO_ONE_"/>
<Task DTYPE="PushTask" type="PUSH" id="21" name="Export on resource-testdb2" resource_name="resource-testdb2"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
- jobClassName="org.apache.syncope.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="UNLINK"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="UNLINK"
userFilter="surname==Verdi" roleFilter="name==_NO_ONE_"/>
<Task DTYPE="PushTask" type="PUSH" id="22" name="Export on resource-testdb2" resource_name="resource-testdb2"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
- jobClassName="org.apache.syncope.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="UPDATE"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.PushJob" unmatchingRule="IGNORE" matchingRule="UPDATE"
userFilter="surname==Verdi" roleFilter="name==_NO_ONE_"/>
<Task DTYPE="PushTask" type="PUSH" id="23" name="Export on resource-ldap" resource_name="resource-ldap"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
- jobClassName="org.apache.syncope.provisioning.api.job.PushJob" unmatchingRule="ASSIGN" matchingRule="UNLINK"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.PushJob" unmatchingRule="ASSIGN" matchingRule="UNLINK"
userFilter="username==_NO_ONE_" roleFilter="name==citizen"/>
<Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="24" name="CSV Task (update matching; provision unmatching)" resource_name="resource-csv"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1" fullReconciliation="0"
- jobClassName="org.apache.syncope.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"
+ jobClassName="org.apache.syncope.server.provisioning.api.job.SyncJob" unmatchingRule="PROVISION" matchingRule="UPDATE"
userTemplate='{"creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"password":null,"status":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"attributes":[{"schema":"firstname","readonly":false,"values":[""]},{"schema":"userId","readonly":false,"values":["'test'"]},{"schema":"fullname","readonly":false,"values":["'test'"]},{"schema":"surname","readonly":false,"values":["'test'"]}],"derivedAttributes":[],"virtualAttributes":[],"resources":["resource-testdb"],"propagationStatuses":[],"memberships":[]}'
roleTemplate='{"creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"name":null,"parent":0,"userOwner":null,"roleOwner":null,"inheritOwner":false,"inheritTemplates":false,"inheritPlainAttrs":false,"inheritDerAttrs":false,"inheritVirAttrs":false,"inheritPasswordPolicy":false,"inheritAccountPolicy":false,"passwordPolicy":null,"accountPolicy":null,"attributes":[],"derivedAttributes":[],"virtualAttributes":[],"resources":[],"propagationStatuses":[],"entitlements":[],"rAttrTemplates":[],"rDerAttrTemplates":[],"rVirAttrTemplates":[],"mAttrTemplates":[],"mDerAttrTemplates":[],"mVirAttrTemplates":[]}'/>
<Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="25" name="CSV (unlink matching; ignore unmatching)" resource_name="resource-csv"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1" fullReconciliation="0"
- jobClassName="org.apache.syncope.provisioning.api.job.SyncJob" unmatchingRule="IGNORE" matchingRule="UNLINK"/>
+ jobClassName="org.apache.syncope.server.provisioning.api.job.SyncJob" unmatchingRule="IGNORE" matchingRule="UNLINK"/>
<Task DTYPE="SyncTask" type="SYNCHRONIZATION" id="26" name="CSV (ignore matching; assign unmatching)" resource_name="resource-csv"
performCreate="1" performUpdate="1" performDelete="1" syncStatus="1" fullReconciliation="0"
- jobClassName="org.apache.syncope.provisioning.api.job.SyncJob" unmatchingRule="ASSIGN" matchingRule="IGNORE"/>
+ jobClassName="org.apache.syncope.server.provisioning.api.job.SyncJob" unmatchingRule="ASSIGN" matchingRule="IGNORE"/>
<Notification id="1" active="1" recipientAttrName="email" recipientAttrType="UserSchema" selfAsRecipient="1"
sender="admin@syncope.apache.org" subject="Password Reset request" template="requestPasswordReset"
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/resources/persistenceTest.xml
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/resources/persistenceTest.xml b/syncope620/server/persistence-jpa/src/test/resources/persistenceTest.xml
new file mode 100644
index 0000000..6d3de5f
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/test/resources/persistenceTest.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context.xsd">
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="locations">
+ <list>
+ <value>classpath:persistence.properties</value>
+ <value>classpath:security.properties</value>
+ </list>
+ </property>
+ <property name="ignoreResourceNotFound" value="true"/>
+ <property name="ignoreUnresolvablePlaceholders" value="true"/>
+ </bean>
+
+ <bean class="org.apache.syncope.server.misc.spring.ApplicationContextProvider"/>
+
+ <bean id="adminUser" class="java.lang.String">
+ <constructor-arg value="${adminUser}"/>
+ </bean>
+ <bean id="anonymousUser" class="java.lang.String">
+ <constructor-arg value="${anonymousUser}"/>
+ </bean>
+
+ <context:component-scan base-package="org.apache.syncope.server.misc.policy"/>
+ <context:component-scan base-package="org.apache.syncope.server.misc.security"/>
+
+ <import resource="persistenceContext.xml"/>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/resources/persistenceTestEnv.xml
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/resources/persistenceTestEnv.xml b/syncope620/server/persistence-jpa/src/test/resources/persistenceTestEnv.xml
deleted file mode 100644
index 0170569..0000000
--- a/syncope620/server/persistence-jpa/src/test/resources/persistenceTestEnv.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd">
-
- <bean class="org.apache.syncope.server.spring.ApplicationContextProvider"/>
-
- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="locations">
- <list>
- <value>classpath:security.properties</value>
- </list>
- </property>
- <property name="ignoreResourceNotFound" value="true"/>
- <property name="ignoreUnresolvablePlaceholders" value="true"/>
- </bean>
- <bean id="adminUser" class="java.lang.String">
- <constructor-arg value="${adminUser}"/>
- </bean>
- <bean id="anonymousUser" class="java.lang.String">
- <constructor-arg value="${anonymousUser}"/>
- </bean>
-
- <context:component-scan base-package="org.apache.syncope.server.utils"/>
-
- <bean id="virAttrCache" class="org.apache.syncope.provisioning.common.cache.MemoryVirAttrCache" scope="singleton">
- <constructor-arg value="60"/>
- <constructor-arg value="5000"/>
- </bean>
-
- <import resource="persistenceContext.xml"/>
-</beans>
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/persistence-jpa/src/test/resources/simplelogger.properties
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/test/resources/simplelogger.properties b/syncope620/server/persistence-jpa/src/test/resources/simplelogger.properties
index 8abc668..1b21312 100644
--- a/syncope620/server/persistence-jpa/src/test/resources/simplelogger.properties
+++ b/syncope620/server/persistence-jpa/src/test/resources/simplelogger.properties
@@ -14,4 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-org.slf4j.simpleLogger.defaultLogLevel=error
+org.slf4j.simpleLogger.defaultLogLevel=debug
http://git-wip-us.apache.org/repos/asf/syncope/blob/235f60fa/syncope620/server/pom.xml
----------------------------------------------------------------------
diff --git a/syncope620/server/pom.xml b/syncope620/server/pom.xml
index 19a959b..9db6358 100644
--- a/syncope620/server/pom.xml
+++ b/syncope620/server/pom.xml
@@ -36,12 +36,11 @@ under the License.
<modules>
<module>persistence-api</module>
<module>persistence-jpa</module>
- <module>spring</module>
- <module>security</module>
- <module>utils</module>
+ <module>misc</module>
<module>provisioning-api</module>
- <module>provisioning-common</module>
+ <module>provisioning-java</module>
<module>workflow-api</module>
+ <module>workflow-java</module>
<module>logic</module>
</modules>