diff --git a/wfe-app/pom.xml b/wfe-app/pom.xml
index 4d673eb16c..25391afa4a 100644
--- a/wfe-app/pom.xml
+++ b/wfe-app/pom.xml
@@ -96,7 +96,7 @@
commons-beanutils
commons-beanutils
- 1.8.3
+ 1.9.2
javax
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthenticationServiceDelegatePasswordLoginModuleTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthenticationServiceDelegatePasswordLoginModuleTest.java
index 56833a4681..d1d567df7f 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthenticationServiceDelegatePasswordLoginModuleTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthenticationServiceDelegatePasswordLoginModuleTest.java
@@ -27,80 +27,74 @@
import ru.runa.wfe.user.User;
public class AuthenticationServiceDelegatePasswordLoginModuleTest extends ServletTestCase {
-
- private static final String PREFIX = AuthenticationServiceDelegatePasswordLoginModuleTest.class.getName();
-
private static final String ACTOR1_NAME = "actor1";
-
private static final String ACTOR2_NAME = "actor2";
-
private static final String ACTOR_VALID_PWD = "validPWD";
- private ServiceTestHelper th;
+ private final String PREFIX = getClass().getName();
+ private ServiceTestHelper h;
private AuthenticationService authenticationService;
-
private ExecutorService executorService;
private Actor validActor;
- protected void setUp() throws Exception {
- th = new ServiceTestHelper(PREFIX);
- authenticationService = th.getAuthenticationService();
- executorService = th.getExecutorService();
-
- validActor = th.createActorIfNotExist(PREFIX + ACTOR1_NAME, "");
- executorService.setPassword(th.getAdminUser(), validActor, ACTOR_VALID_PWD);
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(PREFIX);
+ authenticationService = h.getAuthenticationService();
+ executorService = h.getExecutorService();
- super.setUp();
+ validActor = h.createActorIfNotExist(PREFIX + ACTOR1_NAME, "");
+ executorService.setPassword(h.getAdminUser(), validActor, ACTOR_VALID_PWD);
}
- protected void tearDown() throws Exception {
- th.releaseResources();
- th = null;
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ h = null;
authenticationService = null;
executorService = null;
validActor = null;
- super.tearDown();
}
- public void testValidPassword() throws Exception {
+ public void testValidPassword() {
User validSubject = authenticationService.authenticateByLoginPassword(validActor.getName(), ACTOR_VALID_PWD);
assertEquals("authenticated subject doesn't contains actor principal", validSubject.getActor(), validActor);
}
- public void testValidPasswordWithAnotherActorWithSamePassword() throws Exception {
- Actor actor2 = th.createActorIfNotExist(PREFIX + ACTOR2_NAME, "");
- executorService.setPassword(th.getAdminUser(), actor2, ACTOR_VALID_PWD);
+ public void testValidPasswordWithAnotherActorWithSamePassword() {
+ Actor actor2 = h.createActorIfNotExist(PREFIX + ACTOR2_NAME, "");
+ executorService.setPassword(h.getAdminUser(), actor2, ACTOR_VALID_PWD);
User validSubject = authenticationService.authenticateByLoginPassword(validActor.getName(), ACTOR_VALID_PWD);
assertEquals("authenticated subject doesn't contains actor principal", validSubject.getActor(), validActor);
}
- public void testLoginFakeActor() throws Exception {
+ public void testLoginFakeActor() {
try {
- authenticationService.authenticateByLoginPassword(th.getFakeActor().getName(), ACTOR_VALID_PWD);
+ authenticationService.authenticateByLoginPassword(h.getFakeActor().getName(), ACTOR_VALID_PWD);
fail("allowing fake actor");
} catch (AuthenticationException e) {
- // expected
+ // Expected.
}
}
- public void testInValidPassword() throws Exception {
+ public void testInValidPassword() {
try {
authenticationService.authenticateByLoginPassword(validActor.getName(), ACTOR_VALID_PWD + "Invalid");
fail("allowing invalid password");
} catch (AuthenticationException e) {
- // expected
+ // Expected.
}
}
- public void testInValidLogin() throws Exception {
+ public void testInValidLogin() {
try {
authenticationService.authenticateByLoginPassword(validActor.getName() + "Invalid", ACTOR_VALID_PWD);
fail("allowing invalid login");
} catch (AuthenticationException e) {
- // expected
+ // Expected.
}
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetExecutorsWithPermissionTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetExecutorsWithPermissionTest.java
index 68d5562dbe..936b2b06a2 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetExecutorsWithPermissionTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetExecutorsWithPermissionTest.java
@@ -17,11 +17,9 @@
*/
package ru.runa.af.delegate;
-import java.util.Collection;
-import java.util.List;
-
+import com.google.common.collect.Lists;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.junit.ArrayAssert;
import ru.runa.wfe.InternalApplicationException;
@@ -29,82 +27,68 @@
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
-import ru.runa.wfe.security.SecuredSingleton;
import ru.runa.wfe.service.AuthorizationService;
import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.Actor;
-import ru.runa.wfe.user.Executor;
-
-import com.google.common.collect.Lists;
/**
- * Created on 20.08.2004
- *
+ * Created on 20.08.2004.
*/
public class AuthorizationServiceDelegateGetExecutorsWithPermissionTest extends ServletTestCase {
- private ServiceTestHelper helper;
-
+ private ServiceTestHelper h;
private AuthorizationService authorizationService;
-
private BatchPresentation batchPresentation;
@Override
- protected void setUp() throws Exception {
- helper = new ServiceTestHelper(AuthorizationServiceDelegateGetExecutorsWithPermissionTest.class.getName());
- helper.createDefaultExecutorsMap();
-
- Collection executorP = Lists.newArrayList(Permission.READ);
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getBaseGroupActor());
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getBaseGroup());
-
+ protected void setUp() {
+ h = new ServiceTestHelper(AuthorizationServiceDelegateGetExecutorsWithPermissionTest.class.getName());
authorizationService = Delegates.getAuthorizationService();
- batchPresentation = helper.getExecutorBatchPresentation();
+ batchPresentation = h.getExecutorBatchPresentation();
- authorizationService.setPermissions(helper.getAdminUser(), helper.getBaseGroupActor().getId(), executorP, helper.getBaseGroupActor());
- authorizationService.setPermissions(helper.getAdminUser(), helper.getAuthorizedPerformerActor().getId(), executorP,
- helper.getAuthorizedPerformerActor());
+ h.createDefaultExecutorsMap();
- super.setUp();
+ val pp = Lists.newArrayList(Permission.READ);
+ h.setPermissionsToAuthorizedActor(pp, h.getBaseGroupActor());
+ h.setPermissionsToAuthorizedActor(pp, h.getBaseGroup());
+ h.setPermissionsToAuthorizedActor(pp, h.getAuthorizedActor());
+ authorizationService.setPermissions(h.getAdminUser(), h.getBaseGroupActor().getId(), pp, h.getBaseGroupActor());
}
@Override
- protected void tearDown() throws Exception {
- helper.releaseResources();
+ protected void tearDown() {
+ h.releaseResources();
authorizationService = null;
- batchPresentation = null;
- super.tearDown();
}
- public void testGetExecutorsWithPermissionFakeSubject() throws Exception {
+ public void testGetExecutorsWithPermissionFakeUser() {
try {
- authorizationService.getExecutorsWithPermission(helper.getFakeUser(), SecuredSingleton.EXECUTORS, batchPresentation, true);
+ authorizationService.getExecutorsWithPermission(h.getFakeUser(), h.getBaseGroupActor(), batchPresentation, true);
fail("AuthorizationDelegate.getExecutorsWithPermission() allows fake subject");
} catch (AuthenticationException e) {
+ // Expected. Although we also can get here because user is not fake but is not allowed to read object's permissions.
}
}
- public void testGetExecutorsWithPermissionFakeSecuredObject() throws Exception {
+ public void testGetExecutorsWithPermissionFakeObject() {
try {
- authorizationService.getExecutorsWithPermission(helper.getAuthorizedPerformerUser(), helper.getFakeActor(), batchPresentation, true);
+ authorizationService.getExecutorsWithPermission(h.getAuthorizedUser(), h.getFakeActor(), batchPresentation, true);
fail("AuthorizationDelegate.getExecutorsWithPermission() allows fake SecuredObject");
} catch (InternalApplicationException e) {
+ // Expected.
}
}
- public void testGetExecutorsWithPermission() throws Exception {
- List expected = Lists.newArrayList(helper.getAuthorizedPerformerActor(), helper.getBaseGroupActor());
- List actual = authorizationService.getExecutorsWithPermission(helper.getAuthorizedPerformerUser(), helper.getBaseGroupActor(),
- batchPresentation, true);
+ public void testGetExecutorsWithPermission() {
+ val expected = Lists.newArrayList(h.getAuthorizedActor(), h.getBaseGroupActor());
+ val actual = authorizationService.getExecutorsWithPermission(h.getAuthorizedUser(), h.getBaseGroupActor(), batchPresentation, true);
ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getExecutorsWithPermission() returns wrong executors", expected, actual);
}
- public void testGetExecutorsWithPermissionUnauthorized() throws Exception {
+ public void testGetExecutorsWithPermissionUnauthorized() {
try {
- authorizationService.getExecutorsWithPermission(helper.getUnauthorizedPerformerUser(), helper.getBaseGroupActor(), batchPresentation,
- true);
+ authorizationService.getExecutorsWithPermission(h.getUnauthorizedUser(), h.getBaseGroupActor(), batchPresentation, true);
fail("AuthorizationDelegate.getExecutorsWithPermission() allows unauthorized operation");
} catch (AuthorizationException e) {
+ // Expected.
}
}
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetExecutorsWithoutPermissionTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetExecutorsWithoutPermissionTest.java
index e9f61fbf8b..c442c10274 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetExecutorsWithoutPermissionTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetExecutorsWithoutPermissionTest.java
@@ -17,88 +17,78 @@
*/
package ru.runa.af.delegate;
-import java.util.Collection;
-import java.util.List;
-
+import com.google.common.collect.Lists;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.junit.ArrayAssert;
import ru.runa.wfe.InternalApplicationException;
-import ru.runa.wfe.audit.SystemLog;
+import ru.runa.wfe.presentation.BatchPresentation;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
-import ru.runa.wfe.security.SecuredSingleton;
import ru.runa.wfe.service.AuthorizationService;
import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.Executor;
-import ru.runa.wfe.user.Group;
-
-import com.google.common.collect.Lists;
-import com.itextpdf.text.log.SysoLogger;
/**
- * Created on 20.08.2004
- *
+ * Created on 20.08.2004.
*/
public class AuthorizationServiceDelegateGetExecutorsWithoutPermissionTest extends ServletTestCase {
- private ServiceTestHelper helper;
-
+ private ServiceTestHelper h;
private AuthorizationService authorizationService;
+ private BatchPresentation batchPresentation;
@Override
- protected void setUp() throws Exception {
- helper = new ServiceTestHelper(AuthorizationServiceDelegateGetExecutorsWithoutPermissionTest.class.getName());
- helper.createDefaultExecutorsMap();
+ protected void setUp() {
+ h = new ServiceTestHelper(AuthorizationServiceDelegateGetExecutorsWithoutPermissionTest.class.getName());
+ authorizationService = Delegates.getAuthorizationService();
- Collection executorP = Lists.newArrayList(Permission.READ);
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getBaseGroupActor());
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getBaseGroup());
+ batchPresentation = h.getExecutorBatchPresentation();
- authorizationService = Delegates.getAuthorizationService();
- authorizationService.setPermissions(helper.getAdminUser(), helper.getBaseGroupActor().getId(), executorP, helper.getBaseGroupActor());
- super.setUp();
+ h.createDefaultExecutorsMap();
+
+ val pp = Lists.newArrayList(Permission.READ);
+ h.setPermissionsToAuthorizedActor(pp, h.getBaseGroupActor());
+ h.setPermissionsToAuthorizedActor(pp, h.getBaseGroup());
+ authorizationService.setPermissions(h.getAdminUser(), h.getBaseGroupActor().getId(), pp, h.getBaseGroupActor());
}
@Override
- protected void tearDown() throws Exception {
- helper.releaseResources();
+ protected void tearDown() {
+ h.releaseResources();
authorizationService = null;
- super.tearDown();
}
- public void testGetExecutorsWithoutPermissionFakeSubject() throws Exception {
+ public void testGetExecutorsWithoutPermissionFakeUser() {
try {
- authorizationService.getExecutorsWithPermission(helper.getFakeUser(), SecuredSingleton.EXECUTORS, helper.getExecutorBatchPresentation(), false);
+ authorizationService.getExecutorsWithPermission(h.getFakeUser(), h.getBaseGroupActor(), batchPresentation, false);
fail("AuthorizationDelegate.getExecutorsWithoutPermission() allows fake subject");
} catch (AuthenticationException e) {
+ // Expected. Although we also can get here because user is not fake but is not allowed to read object's permissions.
}
}
- public void testGetExecutorsWithoutPermissionFakeSecuredObject() throws Exception {
+ public void testGetExecutorsWithoutPermissionFakeObject() {
try {
- authorizationService.getExecutorsWithPermission(helper.getAuthorizedPerformerUser(), helper.getFakeActor(),
- helper.getExecutorBatchPresentation(), false);
+ authorizationService.getExecutorsWithPermission(h.getAuthorizedUser(), h.getFakeActor(), batchPresentation, false);
fail("AuthorizationDelegate.getExecutorsWithoutPermission() allows fake SecuredObject");
} catch (InternalApplicationException e) {
+ // Expected.
}
}
- public void testGetExecutorsWithoutPermission() throws Exception {
- List expected = Lists.newArrayList(helper.getBaseGroup());
- List actual = authorizationService.getExecutorsWithPermission(helper.getAuthorizedPerformerUser(), helper.getBaseGroupActor(),
- helper.getExecutorBatchPresentation(), false);
+ public void testGetExecutorsWithoutPermission() {
+ val expected = Lists.newArrayList(h.getBaseGroup());
+ val actual = authorizationService.getExecutorsWithPermission(h.getAuthorizedUser(), h.getBaseGroupActor(), batchPresentation, false);
ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getExecutorsWithoutPermission() returns wrong executors", expected, actual);
}
- public void testGetExecutorsWithoutPermissionUnauthorized() throws Exception {
+ public void testGetExecutorsWithoutPermissionUnauthorized() {
try {
- authorizationService.getExecutorsWithPermission(helper.getUnauthorizedPerformerUser(), helper.getBaseGroupActor(),
- helper.getExecutorBatchPresentation(), false);
+ authorizationService.getExecutorsWithPermission(h.getUnauthorizedUser(), h.getBaseGroupActor(), batchPresentation, false);
fail("AuthorizationDelegate.getExecutorsWithoutPermission() allows unauthorized operation");
} catch (AuthorizationException e) {
+ // Expected.
}
}
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetOwnPermissionsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetOwnPermissionsTest.java
deleted file mode 100644
index 8986bfa28a..0000000000
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetOwnPermissionsTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * This file is part of the RUNA WFE project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; version 2.1
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-package ru.runa.af.delegate;
-
-import java.util.Collection;
-
-import org.apache.cactus.ServletTestCase;
-
-import ru.runa.af.service.ServiceTestHelper;
-import ru.runa.junit.ArrayAssert;
-import ru.runa.wfe.InternalApplicationException;
-import ru.runa.wfe.security.AuthenticationException;
-import ru.runa.wfe.security.AuthorizationException;
-import ru.runa.wfe.security.Permission;
-import ru.runa.wfe.security.SecuredSingleton;
-import ru.runa.wfe.service.AuthorizationService;
-import ru.runa.wfe.service.delegate.Delegates;
-
-import com.google.common.collect.Lists;
-
-/**
- * Created on 20.08.2004
- */
-public class AuthorizationServiceDelegateGetOwnPermissionsTest extends ServletTestCase {
- private ServiceTestHelper helper;
- private AuthorizationService authorizationService;
-
- @Override
- protected void setUp() throws Exception {
- helper = new ServiceTestHelper(AuthorizationServiceDelegateGetOwnPermissionsTest.class.getName());
- helper.createDefaultExecutorsMap();
- Collection executorP = Lists.newArrayList(Permission.UPDATE);
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getBaseGroupActor());
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getBaseGroup());
- helper.setPermissionsToAuthorizedPerformerOnExecutors(Lists.newArrayList(Permission.LIST));
- authorizationService = Delegates.getAuthorizationService();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- helper.releaseResources();
- authorizationService = null;
- super.tearDown();
- }
-
- public void testGetOwnPermissionsFakeSubject() throws Exception {
- try {
- authorizationService.getIssuedPermissions(helper.getFakeUser(), helper.getBaseGroupActor(), helper.getBaseGroupActor());
- fail("AuthorizationDelegate.getIssuedPermissions() allows fake subject");
- } catch (AuthenticationException e) {
- }
- }
-
- public void testGetOwnPermissions() throws Exception {
- Collection noPermission = Lists.newArrayList();
- Collection expected = Lists.newArrayList(Permission.READ);
-
- Collection actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroupActor(),
- SecuredSingleton.EXECUTORS);
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", noPermission, actual);
-
- authorizationService.setPermissions(helper.getAdminUser(), helper.getBaseGroupActor().getId(), expected, SecuredSingleton.EXECUTORS);
- actual = authorizationService.getIssuedPermissions(helper.getAdminUser(), helper.getBaseGroupActor(), SecuredSingleton.EXECUTORS);
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", expected, actual);
-
- actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroup(), helper.getBaseGroupActor());
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", noPermission, actual);
-
- authorizationService.setPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroup().getId(), expected, helper.getBaseGroupActor());
- actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroup(), helper.getBaseGroupActor());
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", expected, actual);
- }
-
- public void testGetOwnPermissionsGroupPermissions() throws Exception {
- Collection noPermission = Lists.newArrayList();
- Collection expected = Lists.newArrayList(Permission.READ);
-
- authorizationService.setPermissions(helper.getAdminUser(), helper.getBaseGroup().getId(), expected, SecuredSingleton.EXECUTORS);
- Collection actual = authorizationService.getIssuedPermissions(helper.getAdminUser(), helper.getBaseGroupActor(),
- SecuredSingleton.EXECUTORS);
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", noPermission, actual);
-
- }
-
- public void testGetOwnPermissionsUnauthorized() throws Exception {
- try {
- authorizationService.getIssuedPermissions(helper.getUnauthorizedPerformerUser(), helper.getBaseGroupActor(), SecuredSingleton.EXECUTORS);
- fail("AuthorizationDelegate.getIssuedPermissions() allows unauthorized operation");
- } catch (AuthorizationException e) {
- }
-
- try {
- authorizationService.getIssuedPermissions(helper.getUnauthorizedPerformerUser(), helper.getBaseGroupActor(), helper.getBaseGroupActor());
- fail("AuthorizationDelegate.getIssuedPermissions() allows unauthorized operation");
- } catch (AuthorizationException e) {
- }
- }
-}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetPermissionsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetPermissionsTest.java
index 5e32b03505..e5116d26a5 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetPermissionsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateGetPermissionsTest.java
@@ -17,13 +17,13 @@
*/
package ru.runa.af.delegate;
-import java.util.Collection;
-
+import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import lombok.val;
+import lombok.var;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.junit.ArrayAssert;
-import ru.runa.wfe.InternalApplicationException;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
@@ -31,77 +31,85 @@
import ru.runa.wfe.service.AuthorizationService;
import ru.runa.wfe.service.delegate.Delegates;
-import com.google.common.collect.Lists;
-
/**
- * Created on 20.08.2004
- *
+ * Created on 20.08.2004.
*/
public class AuthorizationServiceDelegateGetPermissionsTest extends ServletTestCase {
- private ServiceTestHelper helper;
-
+ private ServiceTestHelper h;
private AuthorizationService authorizationService;
@Override
- protected void setUp() throws Exception {
- helper = new ServiceTestHelper(AuthorizationServiceDelegateGetPermissionsTest.class.getName());
- helper.createDefaultExecutorsMap();
-
- Collection executorP = Lists.newArrayList(Permission.UPDATE);
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getBaseGroupActor());
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getBaseGroup());
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getSubGroupActor());
- helper.setPermissionsToAuthorizedPerformerOnExecutors(Lists.newArrayList(Permission.LIST));
+ protected void setUp() {
+ h = new ServiceTestHelper(AuthorizationServiceDelegateGetPermissionsTest.class.getName());
authorizationService = Delegates.getAuthorizationService();
- super.setUp();
+
+ h.createDefaultExecutorsMap();
+
+ // authorizationService.getIssuedPermissions() requires READ on subject (executors)
+ // and READ_PERMISSIONS (which is hidden and derived from READ) on object (other executors, system).
+ val pp = Lists.newArrayList(Permission.READ);
+
+ h.setPermissionsToAuthorizedActor(pp, h.getBaseGroupActor());
+ h.setPermissionsToAuthorizedActor(pp, h.getBaseGroup());
+ h.setPermissionsToAuthorizedActor(pp, SecuredSingleton.SYSTEM);
}
@Override
- protected void tearDown() throws Exception {
- helper.releaseResources();
+ protected void tearDown() {
+ h.releaseResources();
authorizationService = null;
- super.tearDown();
}
- public void testGetPermissionsFakeSubject() throws Exception {
+ public void testGetPermissionsFakeUser() {
try {
- authorizationService.getIssuedPermissions(helper.getFakeUser(), helper.getBaseGroupActor(), helper.getBaseGroupActor());
+ authorizationService.getIssuedPermissions(h.getFakeUser(), h.getBaseGroupActor(), h.getBaseGroupActor());
fail("AuthorizationDelegate.getIssuedPermissions() allows fake subject");
} catch (AuthenticationException e) {
+ // Expected.
}
}
- public void testGetPermissions() throws Exception {
- Collection noPermission = Lists.newArrayList();
- Collection expected = Lists.newArrayList(Permission.READ);
+ public void testGetPermissions() {
+ val empty = new ArrayList();
+ val expected = Lists.newArrayList(Permission.READ);
- Collection actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroupActor(),
- SecuredSingleton.EXECUTORS);
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", noPermission, actual);
+ var actual = authorizationService.getIssuedPermissions(h.getAuthorizedUser(), h.getBaseGroupActor(), SecuredSingleton.SYSTEM);
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", empty, actual);
- authorizationService.setPermissions(helper.getAdminUser(), helper.getBaseGroupActor().getId(), expected, SecuredSingleton.EXECUTORS);
- actual = authorizationService.getIssuedPermissions(helper.getAdminUser(), helper.getBaseGroupActor(), SecuredSingleton.EXECUTORS);
+ authorizationService.setPermissions(h.getAdminUser(), h.getBaseGroupActor().getId(), expected, SecuredSingleton.SYSTEM);
+ actual = authorizationService.getIssuedPermissions(h.getAuthorizedUser(), h.getBaseGroupActor(), SecuredSingleton.SYSTEM);
ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", expected, actual);
- actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroup(), helper.getBaseGroupActor());
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", noPermission, actual);
+ actual = authorizationService.getIssuedPermissions(h.getAuthorizedUser(), h.getBaseGroup(), h.getBaseGroupActor());
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", empty, actual);
- authorizationService.setPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroup().getId(), expected, helper.getBaseGroupActor());
- actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroup(), helper.getBaseGroupActor());
+ authorizationService.setPermissions(h.getAdminUser(), h.getBaseGroup().getId(), expected, h.getBaseGroupActor());
+ actual = authorizationService.getIssuedPermissions(h.getAuthorizedUser(), h.getBaseGroup(), h.getBaseGroupActor());
ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", expected, actual);
}
- public void testGetPermissionsUnauthorized() throws Exception {
+ public void testGetOwnPermissionsGroupPermissions() {
+ val empty = new ArrayList();
+ val expected = Lists.newArrayList(Permission.READ);
+
+ authorizationService.setPermissions(h.getAdminUser(), h.getBaseGroup().getId(), expected, SecuredSingleton.SYSTEM);
+ val actual = authorizationService.getIssuedPermissions(h.getAdminUser(), h.getBaseGroupActor(), SecuredSingleton.SYSTEM);
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.getIssuedPermissions() returns wrong permissions", empty, actual);
+ }
+
+ public void testGetPermissionsUnauthorized() {
try {
- authorizationService.getIssuedPermissions(helper.getUnauthorizedPerformerUser(), helper.getBaseGroupActor(), SecuredSingleton.EXECUTORS);
+ authorizationService.getIssuedPermissions(h.getUnauthorizedUser(), h.getBaseGroupActor(), SecuredSingleton.SYSTEM);
fail("AuthorizationDelegate.getIssuedPermissions() allows unauthorized operation");
} catch (AuthorizationException e) {
+ // Expected.
}
try {
- authorizationService.getIssuedPermissions(helper.getUnauthorizedPerformerUser(), helper.getBaseGroupActor(), helper.getBaseGroupActor());
+ authorizationService.getIssuedPermissions(h.getUnauthorizedUser(), h.getBaseGroupActor(), h.getBaseGroupActor());
fail("AuthorizationDelegate.getIssuedPermissions() allows unauthorized operation");
} catch (AuthorizationException e) {
+ // Expected.
}
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateIsAllowedReturnsArrayTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateIsAllowedReturnsArrayTest.java
index 32613399d1..a92dfc1369 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateIsAllowedReturnsArrayTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateIsAllowedReturnsArrayTest.java
@@ -18,63 +18,56 @@
package ru.runa.af.delegate;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.cactus.ServletTestCase;
-
import com.google.common.collect.Lists;
-
+import lombok.val;
+import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.junit.ArrayAssert;
import ru.runa.wfe.InternalApplicationException;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.Permission;
-import ru.runa.wfe.security.SecuredObject;
import ru.runa.wfe.security.SecuredSingleton;
import ru.runa.wfe.service.AuthorizationService;
import ru.runa.wfe.service.delegate.Delegates;
public class AuthorizationServiceDelegateIsAllowedReturnsArrayTest extends ServletTestCase {
- private ServiceTestHelper helper;
-
+ private ServiceTestHelper h;
private AuthorizationService authorizationService;
@Override
- protected void setUp() throws Exception {
- helper = new ServiceTestHelper(AuthorizationServiceDelegateIsAllowedTest.class.getName());
- helper.createDefaultExecutorsMap();
+ protected void setUp() {
+ h = new ServiceTestHelper(AuthorizationServiceDelegateIsAllowedTest.class.getName());
+ authorizationService = Delegates.getAuthorizationService();
- Collection executorsP = Lists.newArrayList(Permission.CREATE);
- helper.setPermissionsToAuthorizedPerformerOnExecutors(executorsP);
+ h.createDefaultExecutorsMap();
- Collection executorP = Lists.newArrayList(Permission.READ, Permission.UPDATE_STATUS);
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getBaseGroupActor());
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getSubGroupActor());
+ val ppSystem = Lists.newArrayList(Permission.LOGIN);
+ h.setPermissionsToAuthorizedActor(ppSystem, SecuredSingleton.SYSTEM);
- authorizationService = Delegates.getAuthorizationService();
- super.setUp();
+ val ppExecutors = Lists.newArrayList(Permission.READ, Permission.VIEW_TASKS);
+ h.setPermissionsToAuthorizedActor(ppExecutors, h.getBaseGroupActor());
+ h.setPermissionsToAuthorizedActor(ppExecutors, h.getSubGroupActor());
}
@Override
- protected void tearDown() throws Exception {
- helper.releaseResources();
- helper = null;
+ protected void tearDown() {
+ h.releaseResources();
+ h = null;
authorizationService = null;
- super.tearDown();
}
- public void testIsAllowedFakeSubject() throws Exception {
+ public void testIsAllowedFakeUser() {
try {
- authorizationService.isAllowed(helper.getFakeUser(), Permission.READ, Lists.newArrayList(SecuredSingleton.EXECUTORS));
+ authorizationService.isAllowed(h.getFakeUser(), Permission.READ, Lists.newArrayList(SecuredSingleton.SYSTEM));
fail("AuthorizationDelegate.isAllowed() allows fake subject");
} catch (AuthenticationException e) {
+ // Expected.
}
}
- public void testIsAllowedFakeSecuredObject() throws Exception {
+ public void testIsAllowedFakeObject() {
try {
- authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.READ, Lists.newArrayList(helper.getFakeActor()));
+ authorizationService.isAllowed(h.getAuthorizedUser(), Permission.READ, Lists.newArrayList(h.getFakeActor()));
// TODO
// fail("AuthorizationDelegate.isAllowed() allows fake SecuredObject");
} catch (InternalApplicationException e) {
@@ -82,8 +75,8 @@ public void testIsAllowedFakeSecuredObject() throws Exception {
}
try {
- authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.READ,
- Lists.newArrayList(helper.getBaseGroupActor(), helper.getFakeActor()));
+ authorizationService.isAllowed(h.getAuthorizedUser(), Permission.READ,
+ Lists.newArrayList(h.getBaseGroupActor(), h.getFakeActor()));
// TODO
// fail("AuthorizationDelegate.isAllowed() allows fake SecuredObject");
} catch (InternalApplicationException e) {
@@ -91,43 +84,41 @@ public void testIsAllowedFakeSecuredObject() throws Exception {
}
}
- public void testIsAllowedAASystem() throws Exception {
- boolean[] isAllowed = authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.CREATE,
- Lists.newArrayList(SecuredSingleton.EXECUTORS));
+ public void testIsAllowedSystem() {
+ val ooSystem = Lists.newArrayList(SecuredSingleton.SYSTEM);
+
+ boolean[] isAllowed = authorizationService.isAllowed(h.getAuthorizedUser(), Permission.LOGIN, ooSystem);
boolean[] expected = { true };
ArrayAssert.assertEqualArrays("AuthorizationDelegate.isAllowed() returns wrong info", expected, isAllowed);
- isAllowed = authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.READ,
- Lists.newArrayList(SecuredSingleton.EXECUTORS));
+ isAllowed = authorizationService.isAllowed(h.getAuthorizedUser(), Permission.READ, ooSystem);
expected = new boolean[] { false };
ArrayAssert.assertEqualArrays("AuthorizationDelegate.isAllowed() returns wrong info", expected, isAllowed);
}
- public void testIsAllowedExecutor() throws Exception {
- boolean[] isAllowed = authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.READ,
- Lists.newArrayList(helper.getBaseGroupActor(), helper.getSubGroupActor()));
+ public void testIsAllowedExecutor() {
+ val ooActors = Lists.newArrayList(h.getBaseGroupActor(), h.getSubGroupActor());
+
+ boolean[] isAllowed = authorizationService.isAllowed(h.getAuthorizedUser(), Permission.READ, ooActors);
boolean[] expected = { true, true };
ArrayAssert.assertEqualArrays("AuthorizationDelegate.isAllowed() returns wrong info", expected, isAllowed);
- isAllowed = authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.UPDATE,
- Lists.newArrayList(helper.getBaseGroupActor(), helper.getSubGroupActor()));
+ isAllowed = authorizationService.isAllowed(h.getAuthorizedUser(), Permission.UPDATE, ooActors);
expected = new boolean[] { false, false };
ArrayAssert.assertEqualArrays("AuthorizationDelegate.isAllowed() returns wrong info", expected, isAllowed);
- isAllowed = authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.UPDATE_STATUS,
- Lists.newArrayList(helper.getBaseGroupActor(), helper.getSubGroupActor()));
+ isAllowed = authorizationService.isAllowed(h.getAuthorizedUser(), Permission.VIEW_TASKS, ooActors);
expected = new boolean[] { true, true };
ArrayAssert.assertEqualArrays("AuthorizationDelegate.isAllowed() returns wrong info", expected, isAllowed);
}
- public void testIsAllowedExecutorDifferentObjects() throws Exception {
+ public void testIsAllowedExecutorDifferentObjects() {
try {
- authorizationService.isAllowed(helper.getUnauthorizedPerformerUser(), Permission.READ,
- Lists.newArrayList(SecuredSingleton.EXECUTORS, helper.getBaseGroupActor(), helper.getBaseGroup()));
- fail("No Exception: Secured objects should be of the same secured object type (EXECUTORS)");
+ authorizationService.isAllowed(h.getUnauthorizedUser(), Permission.READ,
+ Lists.newArrayList(SecuredSingleton.SYSTEM, h.getBaseGroupActor(), h.getBaseGroup()));
+ fail("No Exception: Secured objects should be of the same secured object type (SYSTEM)");
} catch (InternalApplicationException e) {
- assertEquals("Secured objects should be of the same secured object type (EXECUTORS)", e.getMessage());
+ assertEquals("Secured objects should be of the same secured object type (SYSTEM)", e.getMessage());
}
}
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateIsAllowedTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateIsAllowedTest.java
index 573746e25a..39e587a6b6 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateIsAllowedTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateIsAllowedTest.java
@@ -17,96 +17,85 @@
*/
package ru.runa.af.delegate;
-import java.util.Collection;
-import java.util.List;
-
+import com.google.common.collect.Lists;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
-import ru.runa.wfe.InternalApplicationException;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.Permission;
-import ru.runa.wfe.security.SecuredObject;
import ru.runa.wfe.security.SecuredSingleton;
import ru.runa.wfe.service.AuthorizationService;
import ru.runa.wfe.service.delegate.Delegates;
-import com.google.common.collect.Lists;
-
/**
- * Created on 20.08.2004
- *
+ * Created on 20.08.2004.
*/
public class AuthorizationServiceDelegateIsAllowedTest extends ServletTestCase {
- private ServiceTestHelper helper;
-
private AuthorizationService authorizationService;
+ private ServiceTestHelper h;
@Override
- protected void setUp() throws Exception {
- helper = new ServiceTestHelper(AuthorizationServiceDelegateIsAllowedTest.class.getName());
- helper.createDefaultExecutorsMap();
-
- Collection executorsP = Lists.newArrayList(Permission.CREATE);
- helper.setPermissionsToAuthorizedPerformerOnExecutors(executorsP);
+ protected void setUp() {
+ authorizationService = Delegates.getAuthorizationService();
+ h = new ServiceTestHelper(AuthorizationServiceDelegateIsAllowedTest.class.getName());
+ h.createDefaultExecutorsMap();
- List executorP = Lists.newArrayList(Permission.READ, Permission.UPDATE_STATUS);
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getBaseGroupActor());
- helper.setPermissionsToAuthorizedPerformer(executorP, helper.getBaseGroup());
+ val ppSystem = Lists.newArrayList(Permission.LOGIN);
+ h.setPermissionsToAuthorizedActor(ppSystem, SecuredSingleton.SYSTEM);
- authorizationService = Delegates.getAuthorizationService();
- super.setUp();
+ val ppExecutors = Lists.newArrayList(Permission.READ, Permission.VIEW_TASKS);
+ h.setPermissionsToAuthorizedActor(ppExecutors, h.getBaseGroupActor());
+ h.setPermissionsToAuthorizedActor(ppExecutors, h.getBaseGroup());
}
@Override
- protected void tearDown() throws Exception {
- helper.releaseResources();
+ protected void tearDown() {
+ h.releaseResources();
authorizationService = null;
- super.tearDown();
}
- public void testIsAllowedFakeSubject() throws Exception {
+ public void testIsAllowedFakeUser() {
try {
- authorizationService.isAllowed(helper.getFakeUser(), Permission.READ, SecuredSingleton.EXECUTORS);
+ authorizationService.isAllowed(h.getFakeUser(), Permission.READ, SecuredSingleton.SYSTEM);
fail("AuthorizationDelegate.isAllowed() allows fake subject");
} catch (AuthenticationException e) {
+ // Expected.
}
}
- public void testIsAllowedAASystem() throws Exception {
+ public void testIsAllowedAASystem() {
assertTrue("AuthorizationDelegate.isAllowed() returns wrong info",
- authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.CREATE, SecuredSingleton.EXECUTORS));
+ authorizationService.isAllowed(h.getAuthorizedUser(), Permission.LOGIN, SecuredSingleton.SYSTEM));
assertFalse("AuthorizationDelegate.isAllowed() returns wrong info",
- authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.READ, SecuredSingleton.EXECUTORS));
+ authorizationService.isAllowed(h.getAuthorizedUser(), Permission.READ, SecuredSingleton.SYSTEM));
}
- public void testIsAllowedExecutor() throws Exception {
+ public void testIsAllowedExecutor() {
assertTrue("AuthorizationDelegate.isAllowed() returns wrong info",
- authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.READ, helper.getBaseGroupActor()));
+ authorizationService.isAllowed(h.getAuthorizedUser(), Permission.READ, h.getBaseGroupActor()));
assertTrue("AuthorizationDelegate.isAllowed() returns wrong info",
- authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.UPDATE_STATUS, helper.getBaseGroupActor()));
+ authorizationService.isAllowed(h.getAuthorizedUser(), Permission.VIEW_TASKS, h.getBaseGroupActor()));
assertFalse("AuthorizationDelegate.isAllowed() returns wrong info",
- authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.UPDATE, helper.getBaseGroupActor()));
+ authorizationService.isAllowed(h.getAuthorizedUser(), Permission.UPDATE, h.getBaseGroupActor()));
assertTrue("AuthorizationDelegate.isAllowed() returns wrong info",
- authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.READ, helper.getBaseGroup()));
+ authorizationService.isAllowed(h.getAuthorizedUser(), Permission.READ, h.getBaseGroup()));
assertTrue("AuthorizationDelegate.isAllowed() returns wrong info",
- authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.UPDATE_STATUS, helper.getBaseGroup()));
+ authorizationService.isAllowed(h.getAuthorizedUser(), Permission.VIEW_TASKS, h.getBaseGroup()));
assertFalse("AuthorizationDelegate.isAllowed() returns wrong info",
- authorizationService.isAllowed(helper.getAuthorizedPerformerUser(), Permission.UPDATE, helper.getBaseGroup()));
+ authorizationService.isAllowed(h.getAuthorizedUser(), Permission.UPDATE, h.getBaseGroup()));
}
- public void testIsAllowedExecutorUnauthorized() throws Exception {
- assertFalse(authorizationService.isAllowed(helper.getUnauthorizedPerformerUser(), Permission.READ, SecuredSingleton.EXECUTORS));
+ public void testIsAllowedExecutorUnauthorized() {
+ assertFalse(authorizationService.isAllowed(h.getUnauthorizedUser(), Permission.READ, SecuredSingleton.SYSTEM));
- assertFalse(authorizationService.isAllowed(helper.getUnauthorizedPerformerUser(), Permission.READ, helper.getBaseGroupActor()));
+ assertFalse(authorizationService.isAllowed(h.getUnauthorizedUser(), Permission.READ, h.getBaseGroupActor()));
- assertFalse(authorizationService.isAllowed(helper.getUnauthorizedPerformerUser(), Permission.READ, helper.getBaseGroup()));
+ assertFalse(authorizationService.isAllowed(h.getUnauthorizedUser(), Permission.READ, h.getBaseGroup()));
}
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetMultiExecutorsPermissionsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetMultiExecutorsPermissionsTest.java
index 21777be5bd..a305479932 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetMultiExecutorsPermissionsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetMultiExecutorsPermissionsTest.java
@@ -17,14 +17,13 @@
*/
package ru.runa.af.delegate;
+import com.google.common.collect.Lists;
import java.util.Collection;
import java.util.List;
-
+import lombok.val;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.junit.ArrayAssert;
-import ru.runa.wfe.InternalApplicationException;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
@@ -32,105 +31,86 @@
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.Actor;
import ru.runa.wfe.user.Executor;
-import ru.runa.wfe.user.ExecutorDoesNotExistException;
import ru.runa.wfe.user.Group;
-import com.google.common.collect.Lists;
-
/**
- * Created on 16.02.2005
+ * Created on 16.02.2005.
*/
public class AuthorizationServiceDelegateSetMultiExecutorsPermissionsTest extends ServletTestCase {
- private ServiceTestHelper th;
+ private ServiceTestHelper h;
private AuthorizationService authorizationService;
- Collection testPermission = Lists.newArrayList(Permission.READ, Permission.UPDATE);
-
- private static String testPrefix = AuthorizationServiceDelegateSetMultiExecutorsPermissionsTest.class.getName();
-
private Group additionalGroup;
private Actor additionalActor;
-
private List additionalActorGroupsMixed;
private List executorIDs;
- @Override
- protected void setUp() throws Exception {
- th = new ServiceTestHelper(testPrefix);
-
- Collection readUpdateExecutorPermission = Lists.newArrayList(Permission.READ, Permission.UPDATE);
+ private Collection expected = Lists.newArrayList(Permission.READ, Permission.UPDATE);
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(AuthorizationServiceDelegateSetMultiExecutorsPermissionsTest.class.getName());
authorizationService = Delegates.getAuthorizationService();
- additionalActor = th.createActorIfNotExist("additionalA", "Additional Actor");
- additionalGroup = th.createGroupIfNotExist("additionalG", "Additional Group");
- additionalActorGroupsMixed = th.createMixedActorsGroupsArray("mixed", "Additional Mixed");
+ // authorizationService.setPermissions() requires READ on subject (mixed executors) and UPDATE_PERMISSIONS on object (additional executors).
+ val ppSubject = Lists.newArrayList(Permission.READ);
+ val ppObject = Lists.newArrayList(Permission.UPDATE_PERMISSIONS);
+
+ additionalActor = h.createActorIfNotExist("additionalA", "Additional Actor");
+ additionalGroup = h.createGroupIfNotExist("additionalG", "Additional Group");
+ additionalActorGroupsMixed = h.createMixedActorsGroupsArray("mixed", "Additional Mixed");
executorIDs = Lists.newArrayList();
for (Executor executor : additionalActorGroupsMixed) {
executorIDs.add(executor.getId());
- th.setPermissionsToAuthorizedPerformer(readUpdateExecutorPermission, executor);
+ h.setPermissionsToAuthorizedActor(ppSubject, executor);
}
- th.setPermissionsToAuthorizedPerformer(readUpdateExecutorPermission, additionalActor);
- th.setPermissionsToAuthorizedPerformer(readUpdateExecutorPermission, additionalGroup);
-
- super.setUp();
+ h.setPermissionsToAuthorizedActor(ppObject, additionalActor);
+ h.setPermissionsToAuthorizedActor(ppObject, additionalGroup);
}
- public void testSetPermissions() throws Exception {
- authorizationService.setPermissions(th.getAuthorizedPerformerUser(), executorIDs, testPermission, additionalActor);
- for (int i = 0; i < executorIDs.size(); i++) {
- additionalActorGroupsMixed.set(i, Delegates.getExecutorService().getExecutor(th.getAuthorizedPerformerUser(), executorIDs.get(i)));
- }
- for (int i = 0; i < executorIDs.size(); i++) {
- Collection expected = authorizationService.getIssuedPermissions(th.getAuthorizedPerformerUser(),
- additionalActorGroupsMixed.get(i), additionalActor);
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", testPermission, expected);
- }
-
- authorizationService.setPermissions(th.getAuthorizedPerformerUser(), executorIDs, testPermission, additionalGroup);
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ authorizationService = null;
+ }
+ public void testSetPermissions() {
+ authorizationService.setPermissions(h.getAuthorizedUser(), executorIDs, expected, additionalActor);
for (int i = 0; i < executorIDs.size(); i++) {
- additionalActorGroupsMixed.set(i, Delegates.getExecutorService().getExecutor(th.getAuthorizedPerformerUser(), executorIDs.get(i)));
+ val actual = authorizationService.getIssuedPermissions(h.getAdminUser(), additionalActorGroupsMixed.get(i), additionalActor);
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", expected, actual);
}
+ authorizationService.setPermissions(h.getAuthorizedUser(), executorIDs, expected, additionalGroup);
for (int i = 0; i < executorIDs.size(); i++) {
- Collection expected = authorizationService.getIssuedPermissions(th.getAuthorizedPerformerUser(),
- additionalActorGroupsMixed.get(i), additionalGroup);
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", testPermission, expected);
+ val actual = authorizationService.getIssuedPermissions(h.getAdminUser(), additionalActorGroupsMixed.get(i), additionalGroup);
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", expected, actual);
}
}
- public void testSetPermissionsFakeSubject() throws Exception {
+ public void testSetPermissionsFakeUser() {
try {
- authorizationService.setPermissions(th.getFakeUser(), executorIDs, testPermission, additionalActor);
+ authorizationService.setPermissions(h.getFakeUser(), executorIDs, expected, additionalActor);
fail("AuthorizationDelegate.setPermissions() allows fake subject");
} catch (AuthenticationException e) {
- // This is what we expect
+ // Expected.
}
}
- public void testSetPermissionsUnauthorized() throws Exception {
+ public void testSetPermissionsUnauthorizedUser() {
try {
- authorizationService.setPermissions(th.getUnauthorizedPerformerUser(), executorIDs, testPermission, additionalActor);
+ authorizationService.setPermissions(h.getUnauthorizedUser(), executorIDs, expected, additionalActor);
fail("AuthorizationDelegate.setPermissions() allows unauthorized operation");
} catch (AuthorizationException e) {
- // This is what we expect
+ // Expected.
}
try {
- authorizationService.setPermissions(th.getUnauthorizedPerformerUser(), executorIDs, testPermission, additionalGroup);
+ authorizationService.setPermissions(h.getUnauthorizedUser(), executorIDs, expected, additionalGroup);
fail("AuthorizationDelegate.setPermissions() allows unauthorized operation");
} catch (AuthorizationException e) {
- // This is what we expect
+ // Expected.
}
}
-
- @Override
- protected void tearDown() throws Exception {
- th.releaseResources();
- authorizationService = null;
- super.tearDown();
- }
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetPermissions2Test.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetPermissions2Test.java
deleted file mode 100644
index 2996953f16..0000000000
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetPermissions2Test.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * This file is part of the RUNA WFE project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; version 2.1
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package ru.runa.af.delegate;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.cactus.ServletTestCase;
-
-import ru.runa.af.service.ServiceTestHelper;
-import ru.runa.junit.ArrayAssert;
-import ru.runa.wfe.security.AuthenticationException;
-import ru.runa.wfe.security.AuthorizationException;
-import ru.runa.wfe.security.Permission;
-import ru.runa.wfe.security.SecuredSingleton;
-import ru.runa.wfe.service.AuthorizationService;
-import ru.runa.wfe.service.ExecutorService;
-import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.Executor;
-import ru.runa.wfe.user.ExecutorDoesNotExistException;
-
-import com.google.common.collect.Lists;
-
-/**
- */
-public class AuthorizationServiceDelegateSetPermissions2Test extends ServletTestCase {
- private ServiceTestHelper helper;
-
- private AuthorizationService authorizationService;
-
- private ExecutorService executorService;
-
- private List> legalPermissions = null;
-
- private List legalActorIds = null;
-
- @Override
- protected void setUp() throws Exception {
- helper = new ServiceTestHelper(AuthorizationServiceDelegateSetPermissionsTest.class.getName());
- helper.createDefaultExecutorsMap();
-
- Collection executorsP = Lists.newArrayList(Permission.UPDATE);
- helper.setPermissionsToAuthorizedPerformerOnExecutors(executorsP);
-
- authorizationService = Delegates.getAuthorizationService();
- executorService = Delegates.getExecutorService();
-
- legalActorIds = Lists.newArrayList(helper.getSubGroupActor().getId(), helper.getBaseGroupActor().getId());
- legalPermissions = Lists.newArrayList();
- legalPermissions.add(Lists.newArrayList(Permission.READ));
- legalPermissions.add(Lists.newArrayList(Permission.READ));
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- helper.releaseResources();
- authorizationService = null;
- executorService = null;
- super.tearDown();
- }
-
- public void testSetPermissionsFakeSubject() throws Exception {
- try {
- authorizationService.setPermissions(helper.getFakeUser(), legalActorIds, legalPermissions, SecuredSingleton.EXECUTORS);
- fail("AuthorizationDelegate.setPermission allows Fake subject");
- } catch (AuthenticationException e) {
- }
- }
-
- public void testSetPermissions() throws Exception {
- authorizationService.setPermissions(helper.getAuthorizedPerformerUser(), legalActorIds, legalPermissions, SecuredSingleton.EXECUTORS);
- for (int i = 0; i < legalActorIds.size(); i++) {
- Executor executor = executorService.getExecutor(helper.getAuthorizedPerformerUser(), legalActorIds.get(i));
- Collection actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), executor,
- SecuredSingleton.EXECUTORS);
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions on system",
- legalPermissions.get(i), actual);
- }
-
- legalPermissions = Lists.newArrayList();
- legalPermissions.add(Lists.newArrayList(Permission.READ, Permission.UPDATE_STATUS));
- legalPermissions.add(Lists.newArrayList(Permission.READ, Permission.UPDATE_STATUS));
- authorizationService.setPermissions(helper.getAuthorizedPerformerUser(), legalActorIds, legalPermissions, helper.getBaseGroupActor());
- for (int i = 0; i < legalActorIds.size(); i++) {
- Executor executor = executorService.getExecutor(helper.getAuthorizedPerformerUser(), legalActorIds.get(i));
- Collection actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), executor,
- helper.getBaseGroupActor());
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions on base group actor",
- legalPermissions.get(i), actual);
- }
-
- legalPermissions = Lists.newArrayList();
- legalPermissions.add(Lists.newArrayList(Permission.READ));
- legalPermissions.add(Lists.newArrayList(Permission.READ));
- authorizationService.setPermissions(helper.getAuthorizedPerformerUser(), legalActorIds, legalPermissions, helper.getBaseGroup());
- for (int i = 0; i < legalActorIds.size(); i++) {
- Executor executor = executorService.getExecutor(helper.getAuthorizedPerformerUser(), legalActorIds.get(i));
- Collection actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), executor,
- helper.getBaseGroup());
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions on base group actor",
- legalPermissions.get(i), actual);
- }
- }
-
- public void testSetPermissionsUnauthorized() throws Exception {
- try {
- authorizationService.setPermissions(helper.getUnauthorizedPerformerUser(), legalActorIds, legalPermissions, SecuredSingleton.EXECUTORS);
- fail("AuthorizationDelegate.setPermission allows unauthorized subject");
- } catch (AuthorizationException e) {
- }
-
- try {
- authorizationService.setPermissions(helper.getUnauthorizedPerformerUser(), legalActorIds, legalPermissions, helper.getBaseGroup());
- fail("AuthorizationDelegate.setPermission allows unauthorized subject");
- } catch (AuthorizationException e) {
- }
- }
-}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetPermissionsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetPermissionsTest.java
index c486791418..8a129f1570 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetPermissionsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetPermissionsTest.java
@@ -17,103 +17,108 @@
*/
package ru.runa.af.delegate;
-import java.util.Collection;
-
+import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import lombok.val;
+import lombok.var;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.junit.ArrayAssert;
-import ru.runa.wfe.InternalApplicationException;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.security.SecuredSingleton;
import ru.runa.wfe.service.AuthorizationService;
import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.ExecutorDoesNotExistException;
-
-import com.google.common.collect.Lists;
/**
- * Created on 20.08.2004
+ * Created on 20.08.2004.
*/
public class AuthorizationServiceDelegateSetPermissionsTest extends ServletTestCase {
- private ServiceTestHelper helper;
-
+ private ServiceTestHelper h;
private AuthorizationService authorizationService;
- private Collection p = Lists.newArrayList(Permission.READ, Permission.UPDATE);
-
@Override
- protected void setUp() throws Exception {
- helper = new ServiceTestHelper(AuthorizationServiceDelegateSetPermissionsTest.class.getName());
- helper.createDefaultExecutorsMap();
+ protected void setUp() {
+ h = new ServiceTestHelper(AuthorizationServiceDelegateSetPermissionsTest.class.getName());
+ authorizationService = Delegates.getAuthorizationService();
- Collection executorsP = Lists.newArrayList(Permission.UPDATE);
- helper.setPermissionsToAuthorizedPerformerOnExecutors(executorsP);
+ h.createDefaultExecutorsMap();
- authorizationService = Delegates.getAuthorizationService();
- super.setUp();
+ // authorizationService.setPermissions() requires READ on subject (executors) and UPDATE_PERMISSIONS on object (other executors, system).
+ // Since subject executors are also used as objects, we set both permissions for them.
+ val ppSubject = Lists.newArrayList(Permission.READ, Permission.UPDATE_PERMISSIONS);
+ val ppObject = Lists.newArrayList(Permission.UPDATE_PERMISSIONS);
+ authorizationService.setPermissions(h.getAdminUser(), h.getAuthorizedActor().getId(), ppSubject, h.getBaseGroup());
+ authorizationService.setPermissions(h.getAdminUser(), h.getAuthorizedActor().getId(), ppSubject, h.getBaseGroupActor());
+ h.setPermissionsToAuthorizedActor(ppObject, SecuredSingleton.SYSTEM);
}
@Override
- protected void tearDown() throws Exception {
- helper.releaseResources();
+ protected void tearDown() {
+ h.releaseResources();
authorizationService = null;
- super.tearDown();
}
- public void testSetPermissionsFakeSubject() throws Exception {
+ public void testSetPermissionsFakeUser() {
try {
- authorizationService.setPermissions(helper.getFakeUser(), helper.getBaseGroupActor().getId(), p, SecuredSingleton.EXECUTORS);
+ val expected = Lists.newArrayList(Permission.READ, Permission.LOGIN);
+ authorizationService.setPermissions(h.getFakeUser(), h.getBaseGroupActor().getId(), expected, SecuredSingleton.SYSTEM);
fail("AuthorizationDelegate.setPermissions() allows fake subject");
} catch (AuthenticationException e) {
+ // Expected.
}
}
- public void testSetPermissions() throws Exception {
- authorizationService.setPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroupActor().getId(), p, helper.getBaseGroup());
- Collection actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroupActor(),
- helper.getBaseGroup());
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", p, actual);
+ public void testSetPermissions() {
+ {
+ val expected = Lists.newArrayList(Permission.READ, Permission.UPDATE);
+
+ authorizationService.setPermissions(h.getAuthorizedUser(), h.getBaseGroupActor().getId(), expected, h.getBaseGroup());
+ var actual = authorizationService.getIssuedPermissions(h.getAdminUser(), h.getBaseGroupActor(), h.getBaseGroup());
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", expected, actual);
- authorizationService.setPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroup().getId(), p, helper.getBaseGroupActor());
- actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroup(), helper.getBaseGroupActor());
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", p, actual);
+ authorizationService.setPermissions(h.getAuthorizedUser(), h.getBaseGroup().getId(), expected, h.getBaseGroupActor());
+ actual = authorizationService.getIssuedPermissions(h.getAdminUser(), h.getBaseGroup(), h.getBaseGroupActor());
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", expected, actual);
+ }
+ {
+ val expected = Lists.newArrayList(Permission.READ, Permission.VIEW_LOGS);
- authorizationService.setPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroupActor().getId(), p, SecuredSingleton.EXECUTORS);
- actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroupActor(),
- SecuredSingleton.EXECUTORS);
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", p, actual);
+ authorizationService.setPermissions(h.getAuthorizedUser(), h.getBaseGroupActor().getId(), expected, SecuredSingleton.SYSTEM);
+ val actual = authorizationService.getIssuedPermissions(h.getAdminUser(), h.getBaseGroupActor(), SecuredSingleton.SYSTEM);
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", expected, actual);
+ }
}
- public void testSetNoPermission() throws Exception {
- p = Lists.newArrayList();
- authorizationService.setPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroupActor().getId(), p, helper.getBaseGroup());
- Collection actual = authorizationService.getIssuedPermissions(helper.getAuthorizedPerformerUser(), helper.getBaseGroupActor(),
- helper.getBaseGroup());
- ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", p, actual);
+ public void testSetNoPermission() {
+ val expected = new ArrayList();
+ authorizationService.setPermissions(h.getAuthorizedUser(), h.getBaseGroupActor().getId(), expected, h.getBaseGroup());
+ val actual = authorizationService.getIssuedPermissions(h.getAdminUser(), h.getBaseGroupActor(), h.getBaseGroup());
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions", expected, actual);
}
- public void testSetPermissionsUnauthorized() throws Exception {
+ public void testSetPermissionsUnauthorized() {
+ val expected = new ArrayList();
try {
- authorizationService.setPermissions(helper.getUnauthorizedPerformerUser(), helper.getBaseGroupActor().getId(), p, helper.getBaseGroup());
+ authorizationService.setPermissions(h.getUnauthorizedUser(), h.getBaseGroupActor().getId(), expected, h.getBaseGroup());
fail("AuthorizationDelegate.setPermissions() allows unauthorized operation");
} catch (AuthorizationException e) {
+ // Expected.
}
try {
- authorizationService.setPermissions(helper.getUnauthorizedPerformerUser(), helper.getBaseGroup().getId(), p, helper.getBaseGroupActor());
+ authorizationService.setPermissions(h.getUnauthorizedUser(), h.getBaseGroup().getId(), expected, h.getBaseGroupActor());
fail("AuthorizationDelegate.setPermissions() allows unauthorized operation");
} catch (AuthorizationException e) {
+ // Expected.
}
try {
- authorizationService.setPermissions(helper.getUnauthorizedPerformerUser(), helper.getBaseGroupActor().getId(), p,
- SecuredSingleton.EXECUTORS);
+ authorizationService.setPermissions(h.getUnauthorizedUser(), h.getBaseGroupActor().getId(), expected, SecuredSingleton.SYSTEM);
fail("AuthorizationDelegate.setPermissions() allows unauthorized operation");
} catch (AuthorizationException e) {
+ // Expected.
}
}
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetPermissionsToListTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetPermissionsToListTest.java
new file mode 100644
index 0000000000..e0f0192446
--- /dev/null
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AuthorizationServiceDelegateSetPermissionsToListTest.java
@@ -0,0 +1,130 @@
+/*
+ * This file is part of the RUNA WFE project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package ru.runa.af.delegate;
+
+import com.google.common.collect.Lists;
+import java.util.Collection;
+import java.util.List;
+import lombok.val;
+import lombok.var;
+import org.apache.cactus.ServletTestCase;
+import ru.runa.af.service.ServiceTestHelper;
+import ru.runa.junit.ArrayAssert;
+import ru.runa.wfe.security.AuthenticationException;
+import ru.runa.wfe.security.AuthorizationException;
+import ru.runa.wfe.security.Permission;
+import ru.runa.wfe.security.SecuredSingleton;
+import ru.runa.wfe.service.AuthorizationService;
+import ru.runa.wfe.service.ExecutorService;
+import ru.runa.wfe.service.delegate.Delegates;
+import ru.runa.wfe.user.Executor;
+
+public class AuthorizationServiceDelegateSetPermissionsToListTest extends ServletTestCase {
+ private ServiceTestHelper h;
+ private AuthorizationService authorizationService;
+ private ExecutorService executorService;
+
+ private List> legalPermissions = null;
+ private List legalActorIds = null;
+
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
+ h.createDefaultExecutorsMap();
+ authorizationService = Delegates.getAuthorizationService();
+ executorService = Delegates.getExecutorService();
+
+ // setPermissions() requires READ for subject and UPDATE_PERMISSIONS for object:
+ val ppR = Lists.newArrayList(Permission.READ);
+ var ppU = Lists.newArrayList(Permission.UPDATE_PERMISSIONS);
+ // For executors who act as both subject and object:
+ var ppRU = Lists.newArrayList(Permission.READ, Permission.UPDATE_PERMISSIONS);
+
+ h.setPermissionsToAuthorizedActor(ppU, h.getBaseGroup());
+ h.setPermissionsToAuthorizedActor(ppRU, h.getBaseGroupActor());
+ h.setPermissionsToAuthorizedActor(ppR, h.getSubGroup());
+ h.setPermissionsToAuthorizedActor(ppR, h.getSubGroupActor());
+ h.setPermissionsToAuthorizedActor(ppU, SecuredSingleton.SYSTEM);
+
+ legalActorIds = Lists.newArrayList(h.getBaseGroupActor().getId(), h.getSubGroupActor().getId());
+ legalPermissions = Lists.newArrayList(ppR, ppR);
+ }
+
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ authorizationService = null;
+ executorService = null;
+ }
+
+ public void testSetPermissionsFakeUser() {
+ try {
+ authorizationService.setPermissions(h.getFakeUser(), legalActorIds, legalPermissions, SecuredSingleton.SYSTEM);
+ fail();
+ } catch (AuthenticationException e) {
+ // Expected.
+ }
+ }
+
+ public void testSetPermissions() {
+ authorizationService.setPermissions(h.getAuthorizedUser(), legalActorIds, legalPermissions, SecuredSingleton.SYSTEM);
+ for (int i = 0; i < legalActorIds.size(); i++) {
+ Executor executor = executorService.getExecutor(h.getAdminUser(), legalActorIds.get(i));
+ Collection actual = authorizationService.getIssuedPermissions(h.getAdminUser(), executor, SecuredSingleton.SYSTEM);
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions on SYSTEM",
+ legalPermissions.get(i), actual);
+ }
+
+ authorizationService.setPermissions(h.getAuthorizedUser(), legalActorIds, legalPermissions, h.getBaseGroup());
+ for (int i = 0; i < legalActorIds.size(); i++) {
+ Executor executor = executorService.getExecutor(h.getAdminUser(), legalActorIds.get(i));
+ Collection actual = authorizationService.getIssuedPermissions(h.getAdminUser(), executor, h.getBaseGroup());
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions on base group actor",
+ legalPermissions.get(i), actual);
+ }
+
+ legalPermissions = Lists.newArrayList(
+ Lists.newArrayList(Permission.READ, Permission.UPDATE_ACTOR_STATUS),
+ Lists.newArrayList(Permission.READ, Permission.UPDATE_ACTOR_STATUS)
+ );
+ authorizationService.setPermissions(h.getAuthorizedUser(), legalActorIds, legalPermissions, h.getBaseGroupActor());
+ for (int i = 0; i < legalActorIds.size(); i++) {
+ Executor executor = executorService.getExecutor(h.getAdminUser(), legalActorIds.get(i));
+ Collection actual = authorizationService.getIssuedPermissions(h.getAdminUser(), executor, h.getBaseGroupActor());
+ ArrayAssert.assertWeakEqualArrays("AuthorizationDelegate.setPermissions() does not set right permissions on base group actor",
+ legalPermissions.get(i), actual);
+ }
+ }
+
+ public void testSetPermissionsUnauthorized() {
+ try {
+ authorizationService.setPermissions(h.getUnauthorizedUser(), legalActorIds, legalPermissions, SecuredSingleton.SYSTEM);
+ fail("AuthorizationDelegate.setPermission allows unauthorized subject");
+ } catch (AuthorizationException e) {
+ // Expected.
+ }
+
+ try {
+ authorizationService.setPermissions(h.getUnauthorizedUser(), legalActorIds, legalPermissions, h.getBaseGroup());
+ fail("AuthorizationDelegate.setPermission allows unauthorized subject");
+ } catch (AuthorizationException e) {
+ // Expected.
+ }
+ }
+}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateAddExecutorsToGroupTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateAddExecutorsToGroupTest.java
index 572ecc7ccf..e2ebe3e08b 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateAddExecutorsToGroupTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateAddExecutorsToGroupTest.java
@@ -19,85 +19,88 @@
package ru.runa.af.delegate;
import com.google.common.collect.Lists;
+import java.util.Collection;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.*;
-
-import java.util.Collection;
+import ru.runa.wfe.user.Actor;
+import ru.runa.wfe.user.ExecutorDoesNotExistException;
+import ru.runa.wfe.user.Group;
/*
*/
public class ExecutorServiceDelegateAddExecutorsToGroupTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateAddExecutorsToGroupTest.class.getName();
-
private Actor actor;
-
private Group additionalGroup;
-
private Actor additionalActor;
private final Collection updatePermissions = Lists.newArrayList(Permission.UPDATE);
-
private final Collection readPermissions = Lists.newArrayList(Permission.READ);
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() {
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
+ h = new ServiceTestHelper(getClass().getName());
+ h.createDefaultExecutorsMap();
- actor = th.getBaseGroupActor();
- th.setPermissionsToAuthorizedPerformer(readPermissions, actor);
+ actor = h.getBaseGroupActor();
+ h.setPermissionsToAuthorizedActor(readPermissions, actor);
- additionalGroup = th.createGroupIfNotExist("additionalG", "Additional Group");
- additionalActor = th.createActorIfNotExist("additionalA", "Additional Actor");
- th.setPermissionsToAuthorizedPerformer(readPermissions, additionalActor);
- th.setPermissionsToAuthorizedPerformer(readPermissions, additionalGroup);
+ additionalGroup = h.createGroupIfNotExist("additionalG", "Additional Group");
+ additionalActor = h.createActorIfNotExist("additionalA", "Additional Actor");
+ h.setPermissionsToAuthorizedActor(readPermissions, additionalActor);
+ h.setPermissionsToAuthorizedActor(readPermissions, additionalGroup);
+ }
- super.setUp();
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
+ actor = null;
+ additionalActor = null;
+ additionalGroup = null;
}
- public void testAddExecutorByAuthorizedPerformer() throws Exception {
- assertFalse("Executor not added to group ", th.isExecutorInGroup(additionalActor, additionalGroup));
+ public void testAddExecutorByAuthorizedUser() {
+ assertFalse("Executor not added to group ", h.isExecutorInGroup(additionalActor, additionalGroup));
try {
- executorService.addExecutorsToGroup(th.getAuthorizedPerformerUser(), Lists.newArrayList(additionalActor.getId()),
+ executorService.addExecutorsToGroup(h.getAuthorizedUser(), Lists.newArrayList(additionalActor.getId()),
additionalGroup.getId());
fail("Executor added to group without corresponding permissions");
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
- th.setPermissionsToAuthorizedPerformer(updatePermissions, additionalActor);
- th.setPermissionsToAuthorizedPerformer(updatePermissions, additionalGroup);
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalActor);
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalGroup);
- executorService.addExecutorsToGroup(th.getAuthorizedPerformerUser(), Lists.newArrayList(additionalActor.getId()), additionalGroup.getId());
+ executorService.addExecutorsToGroup(h.getAuthorizedUser(), Lists.newArrayList(additionalActor.getId()), additionalGroup.getId());
- additionalActor = executorService.getExecutor(th.getAuthorizedPerformerUser(), additionalActor.getId());
- additionalGroup = executorService.getExecutor(th.getAuthorizedPerformerUser(), additionalGroup.getId());
+ additionalActor = executorService.getExecutor(h.getAuthorizedUser(), additionalActor.getId());
+ additionalGroup = executorService.getExecutor(h.getAuthorizedUser(), additionalGroup.getId());
- assertTrue("Executor not added to group ", th.isExecutorInGroup(additionalActor, additionalGroup));
+ assertTrue("Executor not added to group ", h.isExecutorInGroup(additionalActor, additionalGroup));
}
- public void testAddExecutorByUnAuthorizedPerformer() throws Exception {
+ public void testAddExecutorByUnAuthorizedUser() {
try {
- executorService.addExecutorsToGroup(th.getUnauthorizedPerformerUser(), Lists.newArrayList(actor.getId()), additionalGroup.getId());
- assertTrue("Executor not added to group ", th.isExecutorInGroup(additionalActor, additionalGroup));
+ executorService.addExecutorsToGroup(h.getUnauthorizedUser(), Lists.newArrayList(actor.getId()), additionalGroup.getId());
+ assertTrue("Executor not added to group ", h.isExecutorInGroup(additionalActor, additionalGroup));
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
}
- public void testAddFakeExecutor() throws Exception {
- th.setPermissionsToAuthorizedPerformer(updatePermissions, additionalGroup);
+ public void testAddFakeExecutor() {
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalGroup);
try {
- executorService.addExecutorsToGroup(th.getAuthorizedPerformerUser(), Lists.newArrayList(th.getFakeActor().getId()),
+ executorService.addExecutorsToGroup(h.getAuthorizedUser(), Lists.newArrayList(h.getFakeActor().getId()),
additionalGroup.getId());
fail("Executor added to group ");
} catch (AuthorizationException e) {
@@ -107,14 +110,4 @@ public void testAddFakeExecutor() throws Exception {
fail("TODO trap");
}
}
-
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- actor = null;
- additionalActor = null;
- additionalGroup = null;
- super.tearDown();
- }
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateAddManyExecutorsToGroupsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateAddManyExecutorsToGroupsTest.java
index 668ebbb357..ec2d2942f3 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateAddManyExecutorsToGroupsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateAddManyExecutorsToGroupsTest.java
@@ -18,225 +18,203 @@
package ru.runa.af.delegate;
+import com.google.common.collect.Lists;
import java.util.Collection;
import java.util.List;
-
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
-import ru.runa.wfe.InternalApplicationException;
-import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.Actor;
import ru.runa.wfe.user.Executor;
-import ru.runa.wfe.user.ExecutorDoesNotExistException;
import ru.runa.wfe.user.Group;
-import com.google.common.collect.Lists;
-
/*
*/
public class ExecutorServiceDelegateAddManyExecutorsToGroupsTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateAddManyExecutorsToGroupsTest.class.getName();
-
private Group additionalGroup;
private List additionalGroups;
-
private Actor additionalActor;
private List additionalActors;
-
private List additionalActorGroupsMixed;
private final Collection updatePermissions = Lists.newArrayList(Permission.UPDATE);
-
private final Collection readPermissions = Lists.newArrayList(Permission.READ);
- private List getAdditionalActors() throws InternalApplicationException {
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
+ executorService = Delegates.getExecutorService();
+
+ additionalGroup = h.createGroupIfNotExist("additionalG", "Additional Group");
+ additionalGroups = h.createGroupArray("additionalG", "Additional Group");
+
+ additionalActor = h.createActorIfNotExist("additionalA", "Additional Actor");
+ additionalActors = h.createActorArray("additionalA", "Additional Actor");
+
+ additionalActorGroupsMixed = h.createMixedActorsGroupsArray("additionalMixed", "Additional Mixed");
+
+ h.setPermissionsToAuthorizedActor(readPermissions, additionalActor);
+ h.setPermissionsToAuthorizedActor(readPermissions, additionalActors);
+
+ h.setPermissionsToAuthorizedActor(readPermissions, additionalGroup);
+ h.setPermissionsToAuthorizedActor(readPermissions, additionalGroups);
+
+ h.setPermissionsToAuthorizedActor(readPermissions, additionalActorGroupsMixed);
+ }
+
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
+ additionalActor = null;
+ additionalGroup = null;
+ additionalGroups = null;
+ additionalActors = null;
+ additionalActorGroupsMixed = null;
+ }
+
+ private List getAdditionalActors() {
List ids = Lists.newArrayList();
for (Actor actor : additionalActors) {
ids.add(actor.getId());
}
- List executors = th.getExecutors(th.getAdminUser(), ids);
- return executors;
+ return h.getExecutors(h.getAdminUser(), ids);
}
- private List getAdditionalGroups()
- throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
+ private List getAdditionalGroups() {
List ids = Lists.newArrayList();
for (Group group : additionalGroups) {
ids.add(group.getId());
}
- return th.getExecutors(th.getAdminUser(), ids);
+ return h.getExecutors(h.getAdminUser(), ids);
}
- private List getAdditionalGroupsMixed()
- throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
+ private List getAdditionalGroupsMixed() {
List ids = Lists.newArrayList();
for (Executor executor : additionalActorGroupsMixed) {
ids.add(executor.getId());
}
- return th.getExecutors(th.getAdminUser(), ids);
+ return h.getExecutors(h.getAdminUser(), ids);
}
- private Group getAdditionalGroup()
- throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return executorService.getExecutor(th.getAdminUser(), additionalGroup.getId());
+ private Group getAdditionalGroup() {
+ return executorService.getExecutor(h.getAdminUser(), additionalGroup.getId());
}
- private Actor getAdditionalActor()
- throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return executorService.getExecutor(th.getAdminUser(), additionalActor.getId());
+ private Actor getAdditionalActor() {
+ return executorService.getExecutor(h.getAdminUser(), additionalActor.getId());
}
- @Override
- protected void setUp() throws Exception {
- executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
-
- additionalGroup = th.createGroupIfNotExist("additionalG", "Additional Group");
- additionalGroups = th.createGroupArray("additionalG", "Additional Group");
-
- additionalActor = th.createActorIfNotExist("additionalA", "Additional Actor");
- additionalActors = th.createActorArray("additionalA", "Additional Actor");
-
- additionalActorGroupsMixed = th.createMixedActorsGroupsArray("additionalMixed", "Additional Mixed");
-
- th.setPermissionsToAuthorizedPerformer(readPermissions, additionalActor);
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(readPermissions, additionalActors);
-
- th.setPermissionsToAuthorizedPerformer(readPermissions, additionalGroup);
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(readPermissions, additionalGroups);
-
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(readPermissions, additionalActorGroupsMixed);
-
- super.setUp();
- }
-
- public void testAddActorsToGroupByAuthorizedPerformer() throws Exception {
- assertFalse("Executors not added to group ", th.isExecutorsInGroup(additionalActors, additionalGroup));
+ public void testAddActorsToGroupByAuthorizedUser() {
+ assertFalse("Executors not added to group ", h.isExecutorsInGroup(additionalActors, additionalGroup));
try {
- executorService.addExecutorsToGroup(th.getAuthorizedPerformerUser(), th.toIds(additionalActors), additionalGroup.getId());
+ executorService.addExecutorsToGroup(h.getAuthorizedUser(), h.toIds(additionalActors), additionalGroup.getId());
fail("Executors added to group without corresponding permissions");
} catch (AuthorizationException e) {
// this is supposed result
}
- th.setPermissionsToAuthorizedPerformer(updatePermissions, additionalGroup);
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(updatePermissions, additionalActors);
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalGroup);
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalActors);
- executorService.addExecutorsToGroup(th.getAuthorizedPerformerUser(), th.toIds(additionalActors), additionalGroup.getId());
+ executorService.addExecutorsToGroup(h.getAuthorizedUser(), h.toIds(additionalActors), additionalGroup.getId());
- assertTrue("Executors not added to group ", th.isExecutorsInGroup(getAdditionalActors(), getAdditionalGroup()));
+ assertTrue("Executors not added to group ", h.isExecutorsInGroup(getAdditionalActors(), getAdditionalGroup()));
}
- public void testAddGroupsToGroupByAuthorizedPerformer() throws Exception {
- assertFalse("Executors not added to group ", th.isExecutorsInGroup(additionalGroups, additionalGroup));
+ public void testAddGroupsToGroupByAuthorizedUser() {
+ assertFalse("Executors not added to group ", h.isExecutorsInGroup(additionalGroups, additionalGroup));
try {
- executorService.addExecutorsToGroup(th.getAuthorizedPerformerUser(), th.toIds(additionalGroups), additionalGroup.getId());
+ executorService.addExecutorsToGroup(h.getAuthorizedUser(), h.toIds(additionalGroups), additionalGroup.getId());
fail("Executors added to group without corresponding permissions");
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
- th.setPermissionsToAuthorizedPerformer(updatePermissions, additionalGroup);
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(updatePermissions, additionalGroups);
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalGroup);
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalGroups);
- executorService.addExecutorsToGroup(th.getAuthorizedPerformerUser(), th.toIds(additionalGroups), getAdditionalGroup().getId());
+ executorService.addExecutorsToGroup(h.getAuthorizedUser(), h.toIds(additionalGroups), getAdditionalGroup().getId());
- assertTrue("Executors not added to group ", th.isExecutorsInGroup(getAdditionalGroups(), getAdditionalGroup()));
+ assertTrue("Executors not added to group ", h.isExecutorsInGroup(getAdditionalGroups(), getAdditionalGroup()));
}
- public void testAddMixedActorsGroupsToGroupByAuthorizedPerformer() throws Exception {
- assertFalse("Executors not added to group ", th.isExecutorsInGroup(additionalActorGroupsMixed, additionalGroup));
+ public void testAddMixedActorsGroupsToGroupByAuthorizedUser() {
+ assertFalse("Executors not added to group ", h.isExecutorsInGroup(additionalActorGroupsMixed, additionalGroup));
try {
- executorService.addExecutorsToGroup(th.getAuthorizedPerformerUser(), th.toIds(additionalActorGroupsMixed), additionalGroup.getId());
+ executorService.addExecutorsToGroup(h.getAuthorizedUser(), h.toIds(additionalActorGroupsMixed), additionalGroup.getId());
fail("Executors added to group without corresponding permissions");
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
- th.setPermissionsToAuthorizedPerformer(updatePermissions, additionalGroup);
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(updatePermissions, additionalActorGroupsMixed);
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalGroup);
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalActorGroupsMixed);
try {
- executorService.addExecutorsToGroup(th.getAuthorizedPerformerUser(), th.toIds(additionalActorGroupsMixed), getAdditionalGroup().getId());
+ executorService.addExecutorsToGroup(h.getAuthorizedUser(), h.toIds(additionalActorGroupsMixed), getAdditionalGroup().getId());
} catch (AuthorizationException e) {
+ // Expected.
}
- assertTrue("Executors not added to group ", th.isExecutorsInGroup(getAdditionalGroupsMixed(), getAdditionalGroup()));
+ assertTrue("Executors not added to group ", h.isExecutorsInGroup(getAdditionalGroupsMixed(), getAdditionalGroup()));
}
- public void testAddActorToGroupsByAuthorizedPerformer() throws Exception {
- assertFalse("Executor not added to groups ", th.isExecutorInGroups(getAdditionalActor(), getAdditionalGroups()));
+ public void testAddActorToGroupsByAuthorizedUser() {
+ assertFalse("Executor not added to groups ", h.isExecutorInGroups(getAdditionalActor(), getAdditionalGroups()));
Executor executor = getAdditionalActor();
try {
- executorService.addExecutorToGroups(th.getAuthorizedPerformerUser(), executor.getId(), th.toIds(getAdditionalGroups()));
+ executorService.addExecutorToGroups(h.getAuthorizedUser(), executor.getId(), h.toIds(getAdditionalGroups()));
fail("Executor added to groups without corresponding permissions");
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
- th.setPermissionsToAuthorizedPerformer(updatePermissions, executor);
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(updatePermissions, getAdditionalGroups());
+ h.setPermissionsToAuthorizedActor(updatePermissions, executor);
+ h.setPermissionsToAuthorizedActor(updatePermissions, getAdditionalGroups());
- executorService.addExecutorToGroups(th.getAuthorizedPerformerUser(), executor.getId(), th.toIds(getAdditionalGroups()));
- assertTrue("Executor not added to groups ", th.isExecutorInGroups(getAdditionalActor(), getAdditionalGroups()));
+ executorService.addExecutorToGroups(h.getAuthorizedUser(), executor.getId(), h.toIds(getAdditionalGroups()));
+ assertTrue("Executor not added to groups ", h.isExecutorInGroups(getAdditionalActor(), getAdditionalGroups()));
}
- public void testAddGroupToGroupsByAuthorizedPerformer() throws Exception {
+ public void testAddGroupToGroupsByAuthorizedUser() {
- assertFalse("Executor not added to groups ", th.isExecutorInGroups(additionalGroup, additionalGroups));
+ assertFalse("Executor not added to groups ", h.isExecutorInGroups(additionalGroup, additionalGroups));
Executor executor = additionalGroup;
try {
- executorService.addExecutorToGroups(th.getAuthorizedPerformerUser(), executor.getId(), th.toIds(additionalGroups));
+ executorService.addExecutorToGroups(h.getAuthorizedUser(), executor.getId(), h.toIds(additionalGroups));
fail("Executor added to groups without corresponding permissions");
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(updatePermissions, additionalGroups);
- th.setPermissionsToAuthorizedPerformer(updatePermissions, executor);
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalGroups);
+ h.setPermissionsToAuthorizedActor(updatePermissions, executor);
- executorService.addExecutorToGroups(th.getAuthorizedPerformerUser(), executor.getId(), th.toIds(getAdditionalGroups()));
+ executorService.addExecutorToGroups(h.getAuthorizedUser(), executor.getId(), h.toIds(getAdditionalGroups()));
- assertTrue("Executor not added to groups ", th.isExecutorInGroups(getAdditionalGroup(), getAdditionalGroups()));
+ assertTrue("Executor not added to groups ", h.isExecutorInGroups(getAdditionalGroup(), getAdditionalGroups()));
}
- public void testAddExecutorsToGroupByUnAuthorizedPerformer() throws Exception {
+ public void testAddExecutorsToGroupByUnAuthorizedUser() {
try {
- executorService.addExecutorsToGroup(th.getUnauthorizedPerformerUser(), th.toIds(additionalActorGroupsMixed), additionalGroup.getId());
- assertTrue("Executors not added to group ", th.isExecutorsInGroup(additionalActorGroupsMixed, additionalGroup));
+ executorService.addExecutorsToGroup(h.getUnauthorizedUser(), h.toIds(additionalActorGroupsMixed), additionalGroup.getId());
+ assertTrue("Executors not added to group ", h.isExecutorsInGroup(additionalActorGroupsMixed, additionalGroup));
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
}
- public void testAddExecutorToGroupsByUnAuthorizedPerformer() throws Exception {
+ public void testAddExecutorToGroupsByUnAuthorizedUser() {
Executor executor = additionalActor;
try {
- executorService.addExecutorToGroups(th.getUnauthorizedPerformerUser(), executor.getId(), th.toIds(additionalGroups));
- assertTrue("Executor not added to groups ", th.isExecutorInGroups(additionalActor, additionalGroups));
+ executorService.addExecutorToGroups(h.getUnauthorizedUser(), executor.getId(), h.toIds(additionalGroups));
+ assertTrue("Executor not added to groups ", h.isExecutorInGroups(additionalActor, additionalGroups));
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
}
-
- @Override
- protected void tearDown() throws Exception {
-
- th.releaseResources();
- executorService = null;
-
- additionalActor = null;
- additionalGroup = null;
- additionalGroups = null;
- additionalActors = null;
- additionalActorGroupsMixed = null;
- super.tearDown();
- }
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateCreateActorTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateCreateActorTest.java
index c592338434..426a0a3014 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateCreateActorTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateCreateActorTest.java
@@ -18,95 +18,78 @@
package ru.runa.af.delegate;
-import java.util.Collection;
-
+import com.google.common.collect.Lists;
import org.apache.cactus.ServletTestCase;
-
-import ru.runa.wfe.security.SecuredSingleton;
-import ru.runa.wfe.security.SecuredObjectType;
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
+import ru.runa.wfe.security.SecuredSingleton;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.Actor;
import ru.runa.wfe.user.ExecutorAlreadyExistsException;
-import com.google.common.collect.Lists;
-
public class ExecutorServiceDelegateCreateActorTest extends ServletTestCase {
- private final static String testPrefix = ExecutorServiceDelegateCreateActorTest.class.getName();
-
- private final static String NAME = "Name" + testPrefix;
-
- private final static String DESC = "Desc" + testPrefix;
-
- private final static String FULL_NAME = "FullName" + testPrefix;
-
- private final static long CODE = System.currentTimeMillis();
-
- private ServiceTestHelper th;
+ private final String PREFIX = getClass().getName();
+ private ServiceTestHelper h;
private ExecutorService executorService;
private Actor actor;
@Override
- protected void setUp() throws Exception {
+ protected void setUp() {
+ h = new ServiceTestHelper(PREFIX);
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- Collection createPermissions = Lists.newArrayList(Permission.CREATE);
- th.setPermissionsToAuthorizedPerformerOnExecutors(createPermissions);
- actor = new Actor(NAME, DESC, FULL_NAME, CODE);
- super.setUp();
+
+ h.setPermissionsToAuthorizedActor(Lists.newArrayList(Permission.CREATE_EXECUTOR), SecuredSingleton.SYSTEM);
+ actor = new Actor(PREFIX + "_Name", PREFIX + "_Desc", PREFIX + "_FullName", System.currentTimeMillis());
}
@Override
- protected void tearDown() throws Exception {
- th.removeExecutorIfExists(actor);
+ protected void tearDown() {
+ h.removeExecutorIfExists(actor);
actor = null;
- th.releaseResources();
+ h.releaseResources();
executorService = null;
-
- super.tearDown();
}
- public void testCreateActorByAuthorizedPerformer() throws Exception {
- actor = executorService.create(th.getAuthorizedPerformerUser(), actor);
- assertTrue("Executor does not exists ", th.isExecutorExist(actor));
- Actor returnedActor = executorService.getExecutorByName(th.getAuthorizedPerformerUser(), actor.getName());
+ public void testCreateActorByAuthorizedUser() {
+ actor = executorService.create(h.getAuthorizedUser(), actor);
+ assertTrue("Executor does not exists ", h.isExecutorExist(actor));
+ Actor returnedActor = executorService.getExecutorByName(h.getAdminUser(), actor.getName());
assertEquals("Returned actor differes with created one", actor, returnedActor);
}
- public void testCreateExecutorByUnAuthorizedPerformer() throws Exception {
+ public void testCreateExecutorByUnAuthorizedUser() {
try {
- executorService.create(th.getUnauthorizedPerformerUser(), actor);
+ executorService.create(h.getUnauthorizedUser(), actor);
fail("ExecutorServiceDelegate allow unauthorized create");
} catch (AuthorizationException e) {
- // This is supposed result of operation
+ // Expected.
}
}
- public void testCreateAlreadyExistedExecutor() throws Exception {
- Actor actor2 = executorService.create(th.getAuthorizedPerformerUser(), actor);
- assertTrue("Executor does not exists ", th.isExecutorExist(actor));
+ public void testCreateAlreadyExistedExecutor() {
+ Actor actor2 = executorService.create(h.getAuthorizedUser(), actor);
+ assertTrue("Executor does not exists ", h.isExecutorExist(actor));
try {
- executorService.create(th.getAuthorizedPerformerUser(), actor);
+ executorService.create(h.getAuthorizedUser(), actor);
fail("ExecutorServiceDelegate allow create actor with same name");
} catch (ExecutorAlreadyExistsException e) {
// This is supposed result of operation
}
- Actor returnedActor = executorService.getExecutor(th.getAuthorizedPerformerUser(), actor2.getId());
+ Actor returnedActor = executorService.getExecutor(h.getAuthorizedUser(), actor2.getId());
assertEquals("Returned actor differes with created one", actor, returnedActor);
}
- public void testCreateExecutorWithFakeSubject() throws Exception {
+ public void testCreateExecutorWithFakeUser() {
try {
- executorService.create(th.getFakeUser(), actor);
+ executorService.create(h.getFakeUser(), actor);
fail("executor with fake subject created");
} catch (AuthenticationException e) {
+ // Expected.
}
}
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateCreateGroupTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateCreateGroupTest.java
index e707a9b987..cac31cf664 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateCreateGroupTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateCreateGroupTest.java
@@ -18,106 +18,94 @@
package ru.runa.af.delegate;
-import java.util.List;
-
+import com.google.common.collect.Lists;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
+import ru.runa.wfe.security.SecuredSingleton;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.Actor;
import ru.runa.wfe.user.ExecutorAlreadyExistsException;
import ru.runa.wfe.user.Group;
-import com.google.common.collect.Lists;
-
public class ExecutorServiceDelegateCreateGroupTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private final String PREFIX = getClass().getName();
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateCreateGroupTest.class.getName();
-
- private final List createPermissions = Lists.newArrayList(Permission.CREATE);
-
private Group group;
@Override
- protected void setUp() throws Exception {
+ protected void setUp() {
+ h = new ServiceTestHelper(PREFIX);
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.setPermissionsToAuthorizedPerformerOnExecutors(createPermissions);
- super.setUp();
+
+ h.setPermissionsToAuthorizedActor(Lists.newArrayList(Permission.CREATE_EXECUTOR), SecuredSingleton.SYSTEM);
}
- public void testCreateGroupByAuthorizedPerformer() throws Exception {
- group = new Group("ExecutorServiceDelegateCreateGroupTest_Group", "description");
- group = executorService.create(th.getAuthorizedPerformerUser(), group);
- assertTrue("Executor (group) does not exists ", th.isExecutorExist(group));
- Group returnedGroup = executorService.getExecutor(th.getAuthorizedPerformerUser(), group.getId());
- assertEquals("Returned group differes with created one", group, returnedGroup);
+ @Override
+ protected void tearDown() {
+ h.removeExecutorIfExists(group);
+ h.releaseResources();
+ executorService = null;
+ group = null;
}
- public void testCreateExecutorByUnAuthorizedPerformer() throws Exception {
+ public void testCreateGroupByAuthorizedUser() {
+ group = new Group(PREFIX + "_Group", "description");
+ group = executorService.create(h.getAuthorizedUser(), group);
+ assertTrue("Executor (group) does not exists ", h.isExecutorExist(group));
+ Group returnedGroup = executorService.getExecutor(h.getAuthorizedUser(), group.getId());
+ assertEquals("Returned group differes with created one", group, returnedGroup);
+ }
- group = new Group("ExecutorServiceDelegateCreateGroupTest_Group", "description");
+ public void testCreateExecutorByUnAuthorizedUser() {
+ group = new Group(PREFIX + "_Group", "description");
try {
- group = executorService.create(th.getUnauthorizedPerformerUser(), group);
+ group = executorService.create(h.getUnauthorizedUser(), group);
fail("ExecutorServiceDelegate.create(group) creates executor without permissions");
} catch (AuthorizationException e) {
- // This is supposed result of operation
+ // Expected.
}
- assertFalse("Executor exists ", th.isExecutorExist(group));
+ assertFalse("Executor exists ", h.isExecutorExist(group));
}
- public void testCreateAlreadyExistedGroup() throws Exception {
- Group group2 = new Group("ExecutorServiceDelegateCreateGroupTest_Group", "description");
- group = executorService.create(th.getAuthorizedPerformerUser(), group2);
- assertTrue("Executor does not exists ", th.isExecutorExist(group));
+ public void testCreateAlreadyExistedGroup() {
+ Group group2 = new Group(PREFIX + "_Group", "description");
+ group = executorService.create(h.getAuthorizedUser(), group2);
+ assertTrue("Executor does not exists ", h.isExecutorExist(group));
try {
- executorService.create(th.getAuthorizedPerformerUser(), group2);
+ executorService.create(h.getAuthorizedUser(), group2);
fail("ExecutorServiceDelegate.create(group) creates already existed group");
} catch (ExecutorAlreadyExistsException e) {
- // This is supposed result of operation
+ // Expected.
}
- Group returnedGroup = executorService.getExecutor(th.getAuthorizedPerformerUser(), group.getId());
+ Group returnedGroup = executorService.getExecutor(h.getAuthorizedUser(), group.getId());
assertEquals("Returned actor differes with created one", group, returnedGroup);
}
- public void testCreateAlreadyExistedActor() throws Exception {
- Actor actor = th.createActorIfNotExist("ExecutorServiceDelegateCreateGroupTest_Group", "description");
+ public void testCreateAlreadyExistedActor() {
+ Actor actor = h.createActorIfNotExist(PREFIX + "_Group", "description");
group = new Group(actor.getName(), actor.getDescription());
try {
- executorService.create(th.getAuthorizedPerformerUser(), group);
+ executorService.create(h.getAuthorizedUser(), group);
fail("ExecutorServiceDelegate.create(group) creates already existed actor");
} catch (ExecutorAlreadyExistsException e) {
- // This is supposed result of operation
+ // Expected.
}
}
- public void testCreateExecutorWithFakeSubject() throws Exception {
- group = new Group("ExecutorServiceDelegateCreateGroupTest_Group", "description");
+ public void testCreateExecutorWithFakeUser() {
+ group = new Group(PREFIX + "_Group", "description");
try {
- group = executorService.create(th.getFakeUser(), group);
+ group = executorService.create(h.getFakeUser(), group);
fail("executor with fake subject created");
} catch (AuthenticationException e) {
- // This is supposed result of operation
+ // Expected.
}
- assertFalse("Executor does not exists ", th.isExecutorExist(group));
+ assertFalse("Executor does not exists ", h.isExecutorExist(group));
}
-
- @Override
- protected void tearDown() throws Exception {
- th.removeExecutorIfExists(group);
- group = null;
-
- th.releaseResources();
- executorService = null;
- group = null;
- super.tearDown();
- }
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetActorByIdTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetActorByIdTest.java
index 6cbbfde929..ed7d273559 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetActorByIdTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetActorByIdTest.java
@@ -18,89 +18,92 @@
package ru.runa.af.delegate;
import com.google.common.collect.Lists;
+import java.util.Map;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.*;
-
-import java.util.List;
-import java.util.Map;
+import ru.runa.wfe.user.Actor;
+import ru.runa.wfe.user.Executor;
+import ru.runa.wfe.user.ExecutorDoesNotExistException;
+import ru.runa.wfe.user.Group;
/**
- * Created on 01.11.2004
+ * Created on 01.11.2004.
*/
public class ExecutorServiceDelegateGetActorByIdTest extends ServletTestCase {
- private ServiceTestHelper th;
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateGetActorByIdTest.class.getName();
+
private Group group;
private Actor actor;
private Map executorsMap;
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- List readPermissions = Lists.newArrayList(Permission.READ);
- executorsMap = th.getDefaultExecutorsMap();
+ h.createDefaultExecutorsMap();
+ executorsMap = h.getDefaultExecutorsMap();
actor = (Actor) executorsMap.get(ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, actor);
group = (Group) executorsMap.get(ServiceTestHelper.BASE_GROUP_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, group);
- th.setPermissionsToAuthorizedPerformer(readPermissions, (Actor) executorsMap.get(ServiceTestHelper.SUB_GROUP_ACTOR_NAME));
- super.setUp();
+
+ val readPermissions = Lists.newArrayList(Permission.READ);
+ h.setPermissionsToAuthorizedActor(readPermissions, actor);
+ h.setPermissionsToAuthorizedActor(readPermissions, group);
+ h.setPermissionsToAuthorizedActor(readPermissions, executorsMap.get(ServiceTestHelper.SUB_GROUP_ACTOR_NAME));
}
- public void testGetActorByAuthorizedPerformer() throws Exception {
- Actor returnedBaseGroupActor = executorService.getExecutor(th.getAuthorizedPerformerUser(), actor.getId());
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
+ actor = null;
+ group = null;
+ }
+
+ public void testGetActorByAuthorizedUser() {
+ Actor returnedBaseGroupActor = executorService.getExecutor(h.getAuthorizedUser(), actor.getId());
assertEquals("actor retuned by businessDelegate differes with expected", actor, returnedBaseGroupActor);
Actor subGroupActor = (Actor) executorsMap.get(ServiceTestHelper.SUB_GROUP_ACTOR_NAME);
- Actor returnedSubGroupActor = executorService.getExecutor(th.getAuthorizedPerformerUser(), subGroupActor.getId());
+ Actor returnedSubGroupActor = executorService.getExecutor(h.getAuthorizedUser(), subGroupActor.getId());
assertEquals("actor retuned by businessDelegate differes with expected", subGroupActor, returnedSubGroupActor);
}
- public void testGetActorByUnauthorizedPerformer() throws Exception {
+ public void testGetActorByUnauthorizedUser() {
try {
- executorService.getExecutor(th.getUnauthorizedPerformerUser(), actor.getId());
- fail("businessDelegate allow to getActor() to performer with UnauthorizedPerformerSubject");
+ executorService.getExecutor(h.getUnauthorizedUser(), actor.getId());
+ fail();
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
try {
- executorService.getExecutor(th.getUnauthorizedPerformerUser(), th.getSubGroupActor().getId());
- fail("businessDelegate allow to getActor() to performer with UnauthorizedPerformerSubject");
+ executorService.getExecutor(h.getUnauthorizedUser(), h.getSubGroupActor().getId());
+ fail();
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetUnexistedActorByAuthorizedPerformer() throws Exception {
+ public void testGetUnexistedActorByAuthorizedUser() {
try {
- executorService.getExecutor(th.getAuthorizedPerformerUser(), -1l);
- fail("businessDelegate does not throw Exception to getActor()");
+ executorService.getExecutor(h.getAuthorizedUser(), -1L);
+ fail();
} catch (ExecutorDoesNotExistException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetActorInsteadOfGroup() throws Exception {
+ public void testGetActorInsteadOfGroup() {
try {
- Actor actor = executorService.getExecutor(th.getAuthorizedPerformerUser(), group.getId());
+ Actor actor = executorService.getExecutor(h.getAuthorizedUser(), group.getId());
fail("businessDelegete allow to getActor() where the group really is returned.");
} catch (ClassCastException e) {
- // That's what we expect
+ // Expected.
}
}
-
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- actor = null;
- group = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetActorTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetActorTest.java
index d7b6f18a01..04856e2539 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetActorTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetActorTest.java
@@ -19,93 +19,92 @@
package ru.runa.af.delegate;
import com.google.common.collect.Lists;
+import java.util.Map;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.*;
-
-import java.util.List;
-import java.util.Map;
+import ru.runa.wfe.user.Actor;
+import ru.runa.wfe.user.Executor;
+import ru.runa.wfe.user.ExecutorDoesNotExistException;
+import ru.runa.wfe.user.Group;
public class ExecutorServiceDelegateGetActorTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private final String PREFIX = getClass().getName();
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateGetActorTest.class.getName();
-
private Group group;
-
private Actor actor;
-
private Map executorsMap;
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(PREFIX);
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- List readPermissions = Lists.newArrayList(Permission.READ);
- executorsMap = th.getDefaultExecutorsMap();
+ h.createDefaultExecutorsMap();
+ executorsMap = h.getDefaultExecutorsMap();
actor = (Actor) executorsMap.get(ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, actor);
group = (Group) executorsMap.get(ServiceTestHelper.BASE_GROUP_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, group);
- th.setPermissionsToAuthorizedPerformer(readPermissions, (Actor) executorsMap.get(ServiceTestHelper.SUB_GROUP_ACTOR_NAME));
- super.setUp();
+
+ val readPermissions = Lists.newArrayList(Permission.READ);
+ h.setPermissionsToAuthorizedActor(readPermissions, actor);
+ h.setPermissionsToAuthorizedActor(readPermissions, group);
+ h.setPermissionsToAuthorizedActor(readPermissions, executorsMap.get(ServiceTestHelper.SUB_GROUP_ACTOR_NAME));
+ }
+
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
+ actor = null;
+ group = null;
}
- public void testGetExecutorByNameByAuthorizedPerformer() throws Exception {
- Actor returnedBaseGroupActor = executorService.getExecutorByName(th.getAuthorizedPerformerUser(),
- testPrefix + ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
+ public void testGetExecutorByNameByAuthorizedUser() {
+ Actor returnedBaseGroupActor = executorService.getExecutorByName(h.getAuthorizedUser(),
+ PREFIX + ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
assertEquals("actor retuned by businessDelegate differes with expected", actor, returnedBaseGroupActor);
- Actor returnedSubGroupActor = executorService.getExecutorByName(th.getAuthorizedPerformerUser(),
- testPrefix + ServiceTestHelper.SUB_GROUP_ACTOR_NAME);
+ Actor returnedSubGroupActor = executorService.getExecutorByName(h.getAuthorizedUser(),
+ PREFIX + ServiceTestHelper.SUB_GROUP_ACTOR_NAME);
Actor subGroupActor = (Actor) executorsMap.get(ServiceTestHelper.SUB_GROUP_ACTOR_NAME);
assertEquals("actor retuned by businessDelegate differes with expected", subGroupActor, returnedSubGroupActor);
}
- public void testGetExecutorByNameByUnauthorizedPerformer() throws Exception {
+ public void testGetExecutorByNameByUnauthorizedUser() {
try {
- executorService.getExecutorByName(th.getUnauthorizedPerformerUser(), testPrefix + ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
+ executorService.getExecutorByName(h.getUnauthorizedUser(), PREFIX + ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
fail("businessDelegate allow to getExecutorByName() to performer without Permission.READ.");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
try {
- executorService.getExecutorByName(th.getUnauthorizedPerformerUser(), testPrefix + ServiceTestHelper.SUB_GROUP_ACTOR_NAME);
+ executorService.getExecutorByName(h.getUnauthorizedUser(), PREFIX + ServiceTestHelper.SUB_GROUP_ACTOR_NAME);
fail("businessDelegate allow to getExecutorByName() to performer without Permission.READ.");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetUnexistedActorByAuthorizedPerformer() throws Exception {
+ public void testGetUnexistedActorByAuthorizedUser() {
try {
- executorService.getExecutorByName(th.getAuthorizedPerformerUser(), testPrefix + "unexistent actor name");
+ executorService.getExecutorByName(h.getAuthorizedUser(), PREFIX + "unexistent actor name");
fail("businessDelegate does not throw Exception to getExecutorByName() to performer without Permission.READ");
} catch (ExecutorDoesNotExistException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetExecutorByNameInsteadOfGroup() throws Exception {
+ public void testGetExecutorByNameInsteadOfGroup() {
try {
- Actor actor = executorService.getExecutorByName(th.getAuthorizedPerformerUser(), testPrefix + ServiceTestHelper.BASE_GROUP_NAME);
+ Actor actor = executorService.getExecutorByName(h.getAuthorizedUser(), PREFIX + ServiceTestHelper.BASE_GROUP_NAME);
fail("businessDelegate allow to getExecutorByName() where the group really is returned.");
} catch (ClassCastException e) {
- // That's what we expect
+ // Expected.
}
}
-
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- actor = null;
- group = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetAllTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetAllTest.java
index aad68ac5a5..d93b9451a8 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetAllTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetAllTest.java
@@ -18,82 +18,66 @@
package ru.runa.af.delegate;
+import com.google.common.collect.Lists;
import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
+import lombok.val;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.junit.ArrayAssert;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.Actor;
import ru.runa.wfe.user.Executor;
-import ru.runa.wfe.user.Group;
import ru.runa.wfe.user.User;
-import com.google.common.collect.Lists;
-
public class ExecutorServiceDelegateGetAllTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateGetAllTest.class.getName();
-
- private Group group;
+ @Override
+ protected void setUp() {
+ executorService = Delegates.getExecutorService();
+ h = new ServiceTestHelper(getClass().getName());
- private Actor actor;
+ h.createDefaultExecutorsMap();
- private Map executorsMap;
+ val ee = h.getDefaultExecutorsMap();
+ h.setPermissionsToAuthorizedActor(Lists.newArrayList(Permission.READ), Lists.newArrayList(
+ ee.get(ServiceTestHelper.BASE_GROUP_ACTOR_NAME),
+ ee.get(ServiceTestHelper.BASE_GROUP_NAME),
+ ee.get(ServiceTestHelper.SUB_GROUP_ACTOR_NAME),
+ ee.get(ServiceTestHelper.SUB_GROUP_NAME)
+ ));
+ }
@Override
- protected void setUp() throws Exception {
- executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- List readPermissions = Lists.newArrayList(Permission.READ);
- executorsMap = th.getDefaultExecutorsMap();
-
- actor = (Actor) executorsMap.get(ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, actor);
- group = (Group) executorsMap.get(ServiceTestHelper.BASE_GROUP_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, group);
- th.setPermissionsToAuthorizedPerformer(readPermissions, executorsMap.get(ServiceTestHelper.SUB_GROUP_ACTOR_NAME));
- th.setPermissionsToAuthorizedPerformer(readPermissions, executorsMap.get(ServiceTestHelper.SUB_GROUP_NAME));
- super.setUp();
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
}
- final public void testgetExecutorsByAuthorizedPerformer() throws Exception {
- List extends Executor> executors = executorService.getExecutors(th.getAuthorizedPerformerUser(), th.getExecutorBatchPresentation());
- LinkedList realExecutors = new LinkedList(executorsMap.values());
- ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutors() returns wrong executor set", realExecutors, executors);
+ final public void testGetExecutorsByAuthorizedUser() {
+ val actual = executorService.getExecutors(h.getAuthorizedUser(), h.getExecutorBatchPresentation()); // includes AuthorizedActor
+ val expected = new LinkedList(h.getDefaultExecutorsMap().values());
+ // ExecutorLogic.create(User, Executor) adds READ permission on executor to itself:
+ expected.add(h.getAuthorizedActor());
+ ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutors() returns wrong executor set", expected, actual);
}
- public void testgetExecutorsByUnauthorizedPerformer() throws Exception {
- List extends Executor> executors = executorService.getExecutors(th.getUnauthorizedPerformerUser(), th.getExecutorBatchPresentation());
- assertTrue("businessDelegate.getExecutors() returns executors", executors.isEmpty());
+ public void testGetExecutorsByUnauthorizedUser() {
+ val actual = executorService.getExecutors(h.getUnauthorizedUser(), h.getExecutorBatchPresentation());
+ val expected = Lists.newArrayList(h.getUnauthorizedActor());
+ ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutors() must return only unauthorizedActor itself", expected, actual);
}
- public void testgetExecutorsWithFakeSubject() throws Exception {
+ public void testGetExecutorsWithFakeUser() {
try {
- User fakeUser = th.getFakeUser();
- executorService.getExecutors(fakeUser, th.getExecutorBatchPresentation());
+ User fakeUser = h.getFakeUser();
+ executorService.getExecutors(fakeUser, h.getExecutorBatchPresentation());
fail("businessDelegate.getExecutors() with fake subject throws no AuthenticationException");
} catch (AuthenticationException e) {
- // That's what we expect
+ // Expected.
}
}
-
- @Override
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- actor = null;
- group = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorGroupsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorGroupsTest.java
index 7f219927bd..a6369042fc 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorGroupsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorGroupsTest.java
@@ -18,134 +18,122 @@
package ru.runa.af.delegate;
+import com.google.common.collect.Lists;
import java.util.List;
-
+import lombok.val;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.junit.ArrayAssert;
-import ru.runa.wfe.InternalApplicationException;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.Actor;
-import ru.runa.wfe.user.ExecutorDoesNotExistException;
import ru.runa.wfe.user.Group;
-import ru.runa.wfe.user.User;
-
-import com.google.common.collect.Lists;
public class ExecutorServiceDelegateGetExecutorGroupsTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateGetExecutorGroupsTest.class.getName();
-
private Group group;
-
private Group subGroup;
-
private Actor actor;
@Override
- protected void setUp() throws Exception {
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- List readPermissions = Lists.newArrayList(Permission.READ);
-
- actor = th.getSubGroupActor();
- th.setPermissionsToAuthorizedPerformer(readPermissions, actor);
- group = th.getBaseGroup();
- subGroup = th.getSubGroup();
- th.setPermissionsToAuthorizedPerformer(readPermissions, group);
- th.setPermissionsToAuthorizedPerformer(readPermissions, subGroup);
- super.setUp();
+
+ h.createDefaultExecutorsMap();
+ actor = h.getSubGroupActor();
+ group = h.getBaseGroup();
+ subGroup = h.getSubGroup();
+
+ val pp = Lists.newArrayList(Permission.READ);
+ h.setPermissionsToAuthorizedActor(pp, actor);
+ h.setPermissionsToAuthorizedActor(pp, group);
+ h.setPermissionsToAuthorizedActor(pp, subGroup);
}
- final public void testGetExecutorGroupsByAuthorizedPerformer1() throws Exception {
- List calculatedGroups = executorService.getExecutorGroups(th.getAuthorizedPerformerUser(), actor, th.getExecutorBatchPresentation(),
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ h = null;
+ executorService = null;
+ actor = null;
+ group = null;
+ subGroup = null;
+ }
+
+ final public void testGetExecutorGroupsByAuthorizedUser1() {
+ List calculatedGroups = executorService.getExecutorGroups(h.getAuthorizedUser(), actor, h.getExecutorBatchPresentation(),
false);
List realGroups = Lists.newArrayList(subGroup);
ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutorGroups( actor ) returns wrong group set", realGroups, calculatedGroups);
}
- final public void testGetExecutorGroupsByAuthorizedPerformer2() throws Exception {
- List calculatedGroups = executorService.getExecutorGroups(th.getAuthorizedPerformerUser(), subGroup, th.getExecutorBatchPresentation(),
+ final public void testGetExecutorGroupsByAuthorizedUser2() {
+ List calculatedGroups = executorService.getExecutorGroups(h.getAuthorizedUser(), subGroup, h.getExecutorBatchPresentation(),
false);
List realGroups = Lists.newArrayList(group);
ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutorGroups( group ) returns wrong group set", realGroups, calculatedGroups);
}
- final public void testGetExecutorGroupsByAuthorizedPerformer3() throws Exception {
+ final public void testGetExecutorGroupsByAuthorizedUser3() {
List updatePermission = Lists.newArrayList(Permission.UPDATE);
- th.setPermissionsToAuthorizedPerformer(updatePermission, group);
- th.addExecutorToGroup(getActor(), getGroup());
- List calculatedGroups = executorService.getExecutorGroups(th.getAuthorizedPerformerUser(), getActor(),
- th.getExecutorBatchPresentation(), false);
+ h.setPermissionsToAuthorizedActor(updatePermission, group);
+ h.addExecutorToGroup(getActor(), getGroup());
+ List calculatedGroups = executorService.getExecutorGroups(h.getAuthorizedUser(), getActor(),
+ h.getExecutorBatchPresentation(), false);
List realGroups = Lists.newArrayList(subGroup, getGroup());
ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutorGroups() returns wrong group set", realGroups, calculatedGroups);
}
- private Group getGroup() throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return executorService.getExecutor(th.getAdminUser(), group.getId());
+ private Group getGroup() {
+ return executorService.getExecutor(h.getAdminUser(), group.getId());
}
- private Actor getActor() throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return executorService.getExecutor(th.getAdminUser(), actor.getId());
+ private Actor getActor() {
+ return executorService.getExecutor(h.getAdminUser(), actor.getId());
}
- final public void testGetExecutorGroupsByAuthorizedPerformer4() throws Exception {
+ final public void testGetExecutorGroupsByAuthorizedUser4() {
List updatePermission = Lists.newArrayList(Permission.UPDATE);
List noPermissionArray = Lists.newArrayList();
- th.setPermissionsToAuthorizedPerformer(updatePermission, group);
- th.addExecutorToGroup(getActor(), getGroup());
- th.setPermissionsToAuthorizedPerformer(noPermissionArray, subGroup);
- List calculatedGroups = executorService.getExecutorGroups(th.getAuthorizedPerformerUser(), getActor(),
- th.getExecutorBatchPresentation(), false);
+ h.setPermissionsToAuthorizedActor(updatePermission, group);
+ h.addExecutorToGroup(getActor(), getGroup());
+ h.setPermissionsToAuthorizedActor(noPermissionArray, subGroup);
+ List calculatedGroups = executorService.getExecutorGroups(h.getAuthorizedUser(), getActor(),
+ h.getExecutorBatchPresentation(), false);
List realGroups = Lists.newArrayList(getGroup());
ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutorGroups() returns wrong group set", realGroups, calculatedGroups);
}
- public void testGetExecutorGroupsByUnauthorizedPerformer1() throws Exception {
+ public void testGetExecutorGroupsByUnauthorizedUser1() {
try {
- executorService.getExecutorGroups(th.getUnauthorizedPerformerUser(), actor, th.getExecutorBatchPresentation(), false);
- fail("businessDelegate.getExecutorGroupsByUnauthorizedPerformer(actor) no AuthorizationFailedException");
+ executorService.getExecutorGroups(h.getUnauthorizedUser(), actor, h.getExecutorBatchPresentation(), false);
+ fail();
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetExecutorGroupsByUnauthorizedPerformer2() throws Exception {
+ public void testGetExecutorGroupsByUnauthorizedUser2() {
try {
- executorService.getExecutorGroups(th.getUnauthorizedPerformerUser(), subGroup, th.getExecutorBatchPresentation(), false);
- fail("businessDelegate.getExecutorGroupsByUnauthorizedPerformer(subGroup) no AuthorizationFailedException");
+ executorService.getExecutorGroups(h.getUnauthorizedUser(), subGroup, h.getExecutorBatchPresentation(), false);
+ fail();
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetExecutorGroupsWithFakeSubject() throws Exception {
+ public void testGetExecutorGroupsWithFakeUser() {
try {
- User fakeUser = th.getFakeUser();
- executorService.getExecutorGroups(fakeUser, actor, th.getExecutorBatchPresentation(), false);
- fail("testGetExecutorGroupsWithFakeSubject no Exception");
+ executorService.getExecutorGroups(h.getFakeUser(), actor, h.getExecutorBatchPresentation(), false);
+ fail();
} catch (AuthenticationException e) {
- // That's what we expect
+ // Expected.
}
}
-
- @Override
- protected void tearDown() throws Exception {
- th.releaseResources();
- th = null;
- executorService = null;
- actor = null;
- group = null;
- subGroup = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorTest.java
index 3c4e40338d..5207bbde11 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorTest.java
@@ -19,83 +19,80 @@
package ru.runa.af.delegate;
import com.google.common.collect.Lists;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.*;
-
-import java.util.List;
-import java.util.Map;
+import ru.runa.wfe.user.Actor;
+import ru.runa.wfe.user.ExecutorDoesNotExistException;
+import ru.runa.wfe.user.Group;
+import ru.runa.wfe.user.User;
public class ExecutorServiceDelegateGetExecutorTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private final String PREFIX = getClass().getName();
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateGetExecutorTest.class.getName();
-
private Group group;
-
private Actor actor;
- private Map executorsMap;
-
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(PREFIX);
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- List readPermissions = Lists.newArrayList(Permission.READ);
- executorsMap = th.getDefaultExecutorsMap();
+ h.createDefaultExecutorsMap();
+ val executorsMap = h.getDefaultExecutorsMap();
actor = (Actor) executorsMap.get(ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, actor);
group = (Group) executorsMap.get(ServiceTestHelper.BASE_GROUP_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, group);
- super.setUp();
+
+ val pp = Lists.newArrayList(Permission.READ);
+ h.setPermissionsToAuthorizedActor(pp, actor);
+ h.setPermissionsToAuthorizedActor(pp, group);
+ }
+
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
+ actor = null;
+ group = null;
}
- public void testGetActorByAuthorizedPerformer() throws Exception {
- Actor returnedBaseGroupActor = executorService.getExecutorByName(th.getAuthorizedPerformerUser(),
- testPrefix + ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
+ public void testGetActorByAuthorizedUser() {
+ Actor returnedBaseGroupActor = executorService.getExecutorByName(h.getAuthorizedUser(),
+ PREFIX + ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
assertEquals("actor retuned by businessDelegate differes with expected", actor, returnedBaseGroupActor);
- Group returnedBaseGroup = executorService.getExecutorByName(th.getAuthorizedPerformerUser(), testPrefix + ServiceTestHelper.BASE_GROUP_NAME);
+ Group returnedBaseGroup = executorService.getExecutorByName(h.getAuthorizedUser(), PREFIX + ServiceTestHelper.BASE_GROUP_NAME);
assertEquals("actor retuned by businessDelegate differes with expected", group, returnedBaseGroup);
}
- public void testGetExecutorByUnauthorizedPerformer() throws Exception {
- User unauthorizedPerformerUser = th.getUnauthorizedPerformerUser();
+ public void testGetExecutorByUnauthorizedUser() {
+ User unauthorizedUser = h.getUnauthorizedUser();
try {
- executorService.getExecutorByName(unauthorizedPerformerUser, testPrefix + ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
+ executorService.getExecutorByName(unauthorizedUser, PREFIX + ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
fail("businessDelegate allow to getExecutor() to performer without Permission.READ.");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
try {
- executorService.getExecutorByName(unauthorizedPerformerUser, testPrefix + ServiceTestHelper.BASE_GROUP_NAME);
+ executorService.getExecutorByName(unauthorizedUser, PREFIX + ServiceTestHelper.BASE_GROUP_NAME);
fail("businessDelegate allow to getExecutor() to performer without Permission.READ.");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetUnexistentExecutorByAuthorizedPerformer() throws Exception {
- User authorizedPerformerUser = th.getAuthorizedPerformerUser();
+ public void testGetUnexistentExecutorByAuthorizedUser() {
+ User authorizedUser = h.getAuthorizedUser();
try {
- executorService.getExecutorByName(authorizedPerformerUser, testPrefix + "unexistent actor name");
+ executorService.getExecutorByName(authorizedUser, PREFIX + "unexistent actor name");
fail("businessDelegate does not throw Exception to getExecutor() to performer without Permission.READ");
} catch (ExecutorDoesNotExistException e) {
- // That's what we expect
+ // Expected.
}
}
-
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- actor = null;
- group = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorsCanBeAddedToGroupTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorsCanBeAddedToGroupTest.java
index 1292911277..e742914501 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorsCanBeAddedToGroupTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorsCanBeAddedToGroupTest.java
@@ -20,12 +20,11 @@
import com.google.common.collect.Lists;
import java.util.Collection;
-import java.util.List;
import java.util.Map;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.junit.ArrayAssert;
-import ru.runa.wfe.InternalApplicationException;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
@@ -33,101 +32,90 @@
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.Actor;
import ru.runa.wfe.user.Executor;
-import ru.runa.wfe.user.ExecutorDoesNotExistException;
import ru.runa.wfe.user.Group;
import ru.runa.wfe.user.User;
public class ExecutorServiceDelegateGetExecutorsCanBeAddedToGroupTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateGetExecutorsCanBeAddedToGroupTest.class.getName();
-
private Group group;
-
private Group subGroup;
-
private Actor actor;
-
private Map executorsMap;
@Override
- protected void setUp() throws Exception {
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- Collection updatePermission = Lists.newArrayList(Permission.UPDATE);
- executorsMap = th.getDefaultExecutorsMap();
+ h.createDefaultExecutorsMap();
+ executorsMap = h.getDefaultExecutorsMap();
actor = (Actor) executorsMap.get(ServiceTestHelper.SUB_GROUP_ACTOR_NAME);
- th.setPermissionsToAuthorizedPerformer(updatePermission, actor);
group = (Group) executorsMap.get(ServiceTestHelper.BASE_GROUP_NAME);
subGroup = (Group) executorsMap.get(ServiceTestHelper.SUB_GROUP_NAME);
- th.setPermissionsToAuthorizedPerformer(updatePermission, group);
- th.setPermissionsToAuthorizedPerformer(updatePermission, subGroup);
- super.setUp();
+
+ val pp = Lists.newArrayList(Permission.UPDATE);
+ h.setPermissionsToAuthorizedActor(pp, actor);
+ h.setPermissionsToAuthorizedActor(pp, group);
+ h.setPermissionsToAuthorizedActor(pp, subGroup);
+ }
+
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ h = null;
+ executorsMap = null;
+ executorService = null;
+ actor = null;
+ group = null;
+ subGroup = null;
}
- private Group getSubGroup() throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return executorService.getExecutor(th.getAdminUser(), subGroup.getId());
+ private Group getSubGroup() {
+ return executorService.getExecutor(h.getAdminUser(), subGroup.getId());
}
- final public void testGetExecutorsByAuthorizedPerformer1() throws Exception {
- List calculatedExecutors = executorService.getGroupChildren(th.getAuthorizedPerformerUser(), getSubGroup(),
- th.getExecutorBatchPresentation(), true);
- List realExecutors = Lists.newArrayList((Executor) group);
- ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutorGroups() returns wrong group set", realExecutors, calculatedExecutors);
+ final public void testGetExecutorsByAuthorizedUser1() {
+ val actual = executorService.getGroupChildren(h.getAuthorizedUser(), getSubGroup(), h.getExecutorBatchPresentation(), true);
+ val expected = Lists.newArrayList((Executor) group);
+ ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutorGroups() returns wrong group set", expected, actual);
}
- final public void testGetExecutorsByAuthorizedPerformer2() throws Exception {
- Collection readPermissions = Lists.newArrayList(Permission.READ);
- th.setPermissionsToAuthorizedPerformer(readPermissions, th.getBaseGroupActor());
- List calculatedExecutors = executorService.getGroupChildren(th.getAuthorizedPerformerUser(), getSubGroup(),
- th.getExecutorBatchPresentation(), true);
- List realExecutors = Lists.newArrayList(group, th.getBaseGroupActor());
- ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutors ...() returns wrong group set", realExecutors, calculatedExecutors);
+ final public void testGetExecutorsByAuthorizedUser2() {
+ h.setPermissionsToAuthorizedActor(Lists.newArrayList(Permission.UPDATE), h.getBaseGroupActor());
+ val actual = executorService.getGroupChildren(h.getAuthorizedUser(), getSubGroup(), h.getExecutorBatchPresentation(), true);
+ val expected = Lists.newArrayList(group, h.getBaseGroupActor());
+ ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutors ...() returns wrong group set", expected, actual);
}
- public void testGetExecutorGroupsByUnauthorizedPerformer() throws Exception {
+ public void testGetExecutorGroupsByUnauthorizedUser() {
try {
- executorService.getGroupChildren(th.getUnauthorizedPerformerUser(), getSubGroup(), th.getExecutorBatchPresentation(), true);
- fail("businessDelegate.getExecutorsByUnauthorizedPerformer() no AuthorizationFailedException");
+ executorService.getGroupChildren(h.getUnauthorizedUser(), getSubGroup(), h.getExecutorBatchPresentation(), true);
+ fail();
} catch (AuthorizationException e) {
// That's what we expect
}
}
- public void testGetExecutorGroupswithoutPermission() throws Exception {
+ public void testGetExecutorGroupswithoutPermission() {
try {
Collection readPermissions = Lists.newArrayList(Permission.READ);
- th.setPermissionsToAuthorizedPerformer(readPermissions, getSubGroup());
- executorService.getGroupChildren(th.getAuthorizedPerformerUser(), getSubGroup(), th.getExecutorBatchPresentation(), true);
+ h.setPermissionsToAuthorizedActor(readPermissions, getSubGroup());
+ executorService.getGroupChildren(h.getAuthorizedUser(), getSubGroup(), h.getExecutorBatchPresentation(), true);
fail("testGetExecutorswithoutPermission no Exception");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetExecutorGroupswithFakeSubject() throws Exception {
+ public void testGetExecutorGroupswithFakeUser() {
try {
- User fakeUser = th.getFakeUser();
- executorService.getGroupChildren(fakeUser, getSubGroup(), th.getExecutorBatchPresentation(), true);
+ User fakeUser = h.getFakeUser();
+ executorService.getGroupChildren(fakeUser, getSubGroup(), h.getExecutorBatchPresentation(), true);
fail("testGetExecutorswithoutPermission no Exception");
} catch (AuthenticationException e) {
- // That's what we expect
+ // Expected.
}
}
-
- @Override
- protected void tearDown() throws Exception {
- th.releaseResources();
- th = null;
- executorsMap = null;
- executorService = null;
- actor = null;
- group = null;
- subGroup = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorsTest.java
index feedfc3649..885a8eadf4 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetExecutorsTest.java
@@ -18,79 +18,70 @@
package ru.runa.af.delegate;
import com.google.common.collect.Lists;
+import java.util.List;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.junit.ArrayAssert;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
-import ru.runa.wfe.service.ExecutorService;
-import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.Executor;
import ru.runa.wfe.user.ExecutorDoesNotExistException;
import ru.runa.wfe.user.User;
-import java.util.List;
-
/**
* Created on 16.05.2005
*/
// TODO executionService.getExecutorsByIds
public class ExecutorServiceDelegateGetExecutorsTest extends ServletTestCase {
- private ServiceTestHelper th;
- private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateGetExecutorsTest.class.getName();
+ private ServiceTestHelper h;
private List additionalActorGroupsMixed;
private final List readPermissions = Lists.newArrayList(Permission.READ);
private List executorsIDs;
- protected void setUp() throws Exception {
- executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
- additionalActorGroupsMixed = th.createMixedActorsGroupsArray("additionalMixed", "Additional Mixed");
-
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(readPermissions, additionalActorGroupsMixed);
+ additionalActorGroupsMixed = h.createMixedActorsGroupsArray("additionalMixed", "Additional Mixed");
+ h.setPermissionsToAuthorizedActor(readPermissions, additionalActorGroupsMixed);
executorsIDs = Lists.newArrayList();
for (Executor executor : additionalActorGroupsMixed) {
executorsIDs.add(executor.getId());
}
+ }
- super.setUp();
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorsIDs = null;
+ additionalActorGroupsMixed = null;
}
- public void testGetExecutorsByAuthorizedPerformer() throws Exception {
- List returnedExecutors = th.getExecutors(th.getAuthorizedPerformerUser(), executorsIDs);
+ public void testGetExecutorsByAuthorizedUser() {
+ List returnedExecutors = h.getExecutors(h.getAuthorizedUser(), executorsIDs);
ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutors() returns wrong executor set", additionalActorGroupsMixed,
returnedExecutors);
}
- public void testGetExecutorsByUnauthorizedPerformer() throws Exception {
- User unauthorizedPerformerUser = th.getUnauthorizedPerformerUser();
+ public void testGetExecutorsByUnauthorizedUser() {
+ User unauthorizedUser = h.getUnauthorizedUser();
try {
- th.getExecutors(unauthorizedPerformerUser, executorsIDs);
+ h.getExecutors(unauthorizedUser, executorsIDs);
fail("businessDelegate allow to getExecutor() to performer without Permission.READ.");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetUnexistedExecutorByAuthorizedPerformer() throws Exception {
+ public void testGetUnexistedExecutorByAuthorizedUser() {
executorsIDs = Lists.newArrayList(-1L, -2L, -3L);
try {
- th.getExecutors(th.getAuthorizedPerformerUser(), executorsIDs);
+ h.getExecutors(h.getAuthorizedUser(), executorsIDs);
fail("businessDelegate does not throw Exception to getExecutor() for UnexistedExecutor");
} catch (ExecutorDoesNotExistException e) {
- // That's what we expect
+ // Expected.
}
}
-
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- executorsIDs = null;
- additionalActorGroupsMixed = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupByIdTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupByIdTest.java
index a9b9a315b9..7fa724e0a5 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupByIdTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupByIdTest.java
@@ -19,6 +19,8 @@
package ru.runa.af.delegate;
import com.google.common.collect.Lists;
+import java.util.Map;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.security.AuthorizationException;
@@ -29,81 +31,74 @@
import ru.runa.wfe.user.ExecutorDoesNotExistException;
import ru.runa.wfe.user.Group;
-import java.util.List;
-import java.util.Map;
-
public class ExecutorServiceDelegateGetGroupByIdTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateGetGroupByIdTest.class.getName();
-
private Group group;
-
private Map executorsMap;
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- List readPermissions = Lists.newArrayList(Permission.READ);
- executorsMap = th.getDefaultExecutorsMap();
+ h.createDefaultExecutorsMap();
+ executorsMap = h.getDefaultExecutorsMap();
group = (Group) executorsMap.get(ServiceTestHelper.BASE_GROUP_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, group);
- th.setPermissionsToAuthorizedPerformer(readPermissions, th.getSubGroup());
- th.setPermissionsToAuthorizedPerformer(readPermissions, th.getBaseGroupActor());
- super.setUp();
+ val pp = Lists.newArrayList(Permission.READ);
+ h.setPermissionsToAuthorizedActor(pp, group);
+ h.setPermissionsToAuthorizedActor(pp, h.getSubGroup());
+ h.setPermissionsToAuthorizedActor(pp, h.getBaseGroupActor());
+ }
+
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
+ group = null;
+ executorsMap = null;
}
- public void testGetExecutorByAuthorizedPerformer() throws Exception {
- Group returnedBaseGroup = executorService.getExecutor(th.getAuthorizedPerformerUser(), group.getId());
+ public void testGetExecutorByAuthorizedUser() {
+ Group returnedBaseGroup = executorService.getExecutor(h.getAuthorizedUser(), group.getId());
assertEquals("actor retuned by businessDelegate differes with expected", group, returnedBaseGroup);
Group subGroup = (Group) executorsMap.get(ServiceTestHelper.SUB_GROUP_NAME);
- Group returnedSubGroup = executorService.getExecutor(th.getAuthorizedPerformerUser(), subGroup.getId());
+ Group returnedSubGroup = executorService.getExecutor(h.getAuthorizedUser(), subGroup.getId());
assertEquals("actor retuned by businessDelegate differes with expected", subGroup, returnedSubGroup);
}
- public void testGetExecutorByUnauthorizedPerformer() throws Exception {
+ public void testGetExecutorByUnauthorizedUser() {
try {
- executorService.getExecutor(th.getUnauthorizedPerformerUser(), group.getId());
+ executorService.getExecutor(h.getUnauthorizedUser(), group.getId());
fail("businessDelegate allow to getExecutor()");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
try {
- executorService.getExecutor(th.getUnauthorizedPerformerUser(), th.getSubGroup().getId());
+ executorService.getExecutor(h.getUnauthorizedUser(), h.getSubGroup().getId());
fail("businessDelegate allow to getSubGroup()");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetUnexistedGroupByAuthorizedPerformer() throws Exception {
+ public void testGetUnexistedGroupByAuthorizedUser() {
try {
- executorService.getExecutor(th.getAuthorizedPerformerUser(), -1l);
- fail("businessDelegate does not throw Exception to getExecutor() in testGetUnexistedGroupByAuthorizedPerformer");
+ executorService.getExecutor(h.getAuthorizedUser(), -1L);
+ fail();
} catch (ExecutorDoesNotExistException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetActorInsteadOfGroup() throws Exception {
+ public void testGetActorInsteadOfGroup() {
try {
- Group actor = executorService.getExecutor(th.getAuthorizedPerformerUser(), th.getBaseGroupActor().getId());
+ Group actor = executorService.getExecutor(h.getAuthorizedUser(), h.getBaseGroupActor().getId());
fail("businessDelegate allow to getExecutor() where the actor really is returned.");
} catch (ClassCastException e) {
- // That's what we expect
+ // Expected.
}
}
-
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- group = null;
- executorsMap = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupChildrenTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupChildrenTest.java
index f0435f9660..f58f781aa5 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupChildrenTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupChildrenTest.java
@@ -18,12 +18,11 @@
package ru.runa.af.delegate;
-import java.util.Collection;
+import com.google.common.collect.Lists;
import java.util.List;
import java.util.Map;
-
+import lombok.val;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.junit.ArrayAssert;
import ru.runa.wfe.security.AuthenticationException;
@@ -34,92 +33,82 @@
import ru.runa.wfe.user.Actor;
import ru.runa.wfe.user.Executor;
import ru.runa.wfe.user.Group;
-import ru.runa.wfe.user.User;
-
-import com.google.common.collect.Lists;
public class ExecutorServiceDelegateGetGroupChildrenTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateGetGroupChildrenTest.class.getName();
-
private Group group;
-
private Group subGroup;
-
private Actor actor;
private Map executorsMap;
@Override
- protected void setUp() throws Exception {
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- Collection readPermissions = Lists.newArrayList(Permission.READ);
- executorsMap = th.getDefaultExecutorsMap();
+
+ h.createDefaultExecutorsMap();
+ executorsMap = h.getDefaultExecutorsMap();
actor = (Actor) executorsMap.get(ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, actor);
group = (Group) executorsMap.get(ServiceTestHelper.BASE_GROUP_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, group);
subGroup = (Group) executorsMap.get(ServiceTestHelper.SUB_GROUP_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, subGroup);
- actor = executorService.getExecutor(th.getAdminUser(), actor.getId());
- group = executorService.getExecutor(th.getAdminUser(), group.getId());
- subGroup = executorService.getExecutor(th.getAdminUser(), subGroup.getId());
+ val pp = Lists.newArrayList(Permission.READ);
+ h.setPermissionsToAuthorizedActor(pp, actor);
+ h.setPermissionsToAuthorizedActor(pp, group);
+ h.setPermissionsToAuthorizedActor(pp, subGroup);
- super.setUp();
+ actor = executorService.getExecutor(h.getAdminUser(), actor.getId());
+ group = executorService.getExecutor(h.getAdminUser(), group.getId());
+ subGroup = executorService.getExecutor(h.getAdminUser(), subGroup.getId());
}
- final public void testGetGroupChildrenByAuthorizedPerformer() throws Exception {
- List calculatedGroupChildren = executorService.getGroupChildren(th.getAuthorizedPerformerUser(), group,
- th.getExecutorBatchPresentation(), false);
- List realGroupChildren = Lists.newArrayList(th.getBaseGroupActor(), th.getSubGroup());
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ h = null;
+ executorsMap = null;
+ executorService = null;
+ actor = null;
+ group = null;
+ subGroup = null;
+ }
+
+ final public void testGetGroupChildrenByAuthorizedUser() {
+ List calculatedGroupChildren = executorService.getGroupChildren(h.getAuthorizedUser(), group,
+ h.getExecutorBatchPresentation(), false);
+ List realGroupChildren = Lists.newArrayList(h.getBaseGroupActor(), h.getSubGroup());
ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutorGroups() returns wrong group set", realGroupChildren, calculatedGroupChildren);
}
- public void testGetExecutorGroupsByUnauthorizedPerformer() throws Exception {
+ public void testGetExecutorGroupsByUnauthorizedUser() {
try {
- executorService.getGroupChildren(th.getUnauthorizedPerformerUser(), group, th.getExecutorBatchPresentation(), false);
- fail("businessDelegate.getGroupChildrenByUnauthorizedPerformer() no AuthorizationFailedException");
+ executorService.getGroupChildren(h.getUnauthorizedUser(), group, h.getExecutorBatchPresentation(), false);
+ fail();
} catch (AuthorizationException e) {
// That's what we expect
}
}
- public void testGetExecutorGroupsWithoutPermission() throws Exception {
+ public void testGetExecutorGroupsWithoutPermission() {
try {
- th.setPermissionsToAuthorizedPerformer(Lists.newArrayList(), group);
- executorService.getGroupChildren(th.getAuthorizedPerformerUser(), group, th.getExecutorBatchPresentation(), false);
+ h.setPermissionsToAuthorizedActor(Lists.newArrayList(), group);
+ executorService.getGroupChildren(h.getAuthorizedUser(), group, h.getExecutorBatchPresentation(), false);
fail("testGetGroupChildrenwithoutPermission no Exception");
} catch (AuthorizationException e) {
// That's what we expect
}
}
- public void testGetExecutorGroupsWithFakeSubject() throws Exception {
+ public void testGetExecutorGroupsWithFakeUser() {
try {
- User fakeUser = th.getFakeUser();
- executorService.getGroupChildren(fakeUser, group, th.getExecutorBatchPresentation(), false);
- fail("testGetExecutorGroupsWithFakeSubject no Exception");
+ executorService.getGroupChildren(h.getFakeUser(), group, h.getExecutorBatchPresentation(), false);
+ fail();
} catch (AuthenticationException e) {
// That's what we expect
}
}
-
- @Override
- protected void tearDown() throws Exception {
- th.releaseResources();
- th = null;
- executorsMap = null;
- executorService = null;
- actor = null;
- group = null;
- subGroup = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupTest.java
index 6e7b2cd2bb..328308b9cf 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupTest.java
@@ -19,6 +19,8 @@
package ru.runa.af.delegate;
import com.google.common.collect.Lists;
+import java.util.Map;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.security.AuthorizationException;
@@ -29,82 +31,76 @@
import ru.runa.wfe.user.ExecutorDoesNotExistException;
import ru.runa.wfe.user.Group;
-import java.util.List;
-import java.util.Map;
-
public class ExecutorServiceDelegateGetGroupTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private final String PREFIX = getClass().getName();
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateGetGroupTest.class.getName();
-
private Group group;
-
private Map executorsMap;
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(PREFIX);
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- List readPermissions = Lists.newArrayList(Permission.READ);
- executorsMap = th.getDefaultExecutorsMap();
+ h.createDefaultExecutorsMap();
+ executorsMap = h.getDefaultExecutorsMap();
group = (Group) executorsMap.get(ServiceTestHelper.BASE_GROUP_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, group);
- th.setPermissionsToAuthorizedPerformer(readPermissions, th.getSubGroup());
- th.setPermissionsToAuthorizedPerformer(readPermissions, th.getBaseGroupActor());
- super.setUp();
+ val pp = Lists.newArrayList(Permission.READ);
+ h.setPermissionsToAuthorizedActor(pp, group);
+ h.setPermissionsToAuthorizedActor(pp, h.getSubGroup());
+ h.setPermissionsToAuthorizedActor(pp, h.getBaseGroupActor());
+ }
+
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
+ group = null;
+ executorsMap = null;
}
- public void testGetExecutorByNameByAuthorizedPerformer() throws Exception {
- Group returnedBaseGroup = executorService.getExecutorByName(th.getAuthorizedPerformerUser(), testPrefix + ServiceTestHelper.BASE_GROUP_NAME);
+ public void testGetExecutorByNameByAuthorizedUser() {
+ Group returnedBaseGroup = executorService.getExecutorByName(h.getAuthorizedUser(), PREFIX + ServiceTestHelper.BASE_GROUP_NAME);
assertEquals("actor retuned by businessDelegate differes with expected", group, returnedBaseGroup);
- Group returnedSubGroup = executorService.getExecutorByName(th.getAuthorizedPerformerUser(), testPrefix + ServiceTestHelper.SUB_GROUP_NAME);
+ Group returnedSubGroup = executorService.getExecutorByName(h.getAuthorizedUser(), PREFIX + ServiceTestHelper.SUB_GROUP_NAME);
Group subGroup = (Group) executorsMap.get(ServiceTestHelper.SUB_GROUP_NAME);
assertEquals("actor retuned by businessDelegate differes with expected", subGroup, returnedSubGroup);
}
- public void testGetExecutorByNameByUnauthorizedPerformer() throws Exception {
+ public void testGetExecutorByNameByUnauthorizedUser() {
try {
- executorService.getExecutorByName(th.getUnauthorizedPerformerUser(), testPrefix + ServiceTestHelper.BASE_GROUP_NAME);
+ executorService.getExecutorByName(h.getUnauthorizedUser(), PREFIX + ServiceTestHelper.BASE_GROUP_NAME);
fail("businessDelegate allow to getExecutorByName()");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
try {
- executorService.getExecutorByName(th.getUnauthorizedPerformerUser(), testPrefix + ServiceTestHelper.SUB_GROUP_NAME);
+ executorService.getExecutorByName(h.getUnauthorizedUser(), PREFIX + ServiceTestHelper.SUB_GROUP_NAME);
fail("businessDelegate allow to getExecutorByName()");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetUnexistedGroupByAuthorizedPerformer() throws Exception {
+ public void testGetUnexistedGroupByAuthorizedUser() {
try {
- executorService.getExecutorByName(th.getAuthorizedPerformerUser(), testPrefix + "unexistent group name");
- fail("businessDelegate does not throw Exception to getExecutorByName() in testGetUnexistedGroupByAuthorizedPerformer");
+ executorService.getExecutorByName(h.getAuthorizedUser(), PREFIX + "unexistent group name");
+ fail();
} catch (ExecutorDoesNotExistException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetActorInsteadOfGroup() throws Exception {
+ public void testGetActorInsteadOfGroup() {
try {
- Group group = executorService.getExecutorByName(th.getAuthorizedPerformerUser(),
- testPrefix + ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
+ Group group = executorService.getExecutorByName(h.getAuthorizedUser(),
+ PREFIX + ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
fail("businessDelegate allow to getExecutorByName() where the actor really is returned.");
} catch (ClassCastException e) {
- // That's what we expect
+ // Expected.
}
}
-
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- group = null;
- executorsMap = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupsByIDsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupsByIDsTest.java
index 856af855a3..94fa53e24b 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupsByIDsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupsByIDsTest.java
@@ -23,8 +23,6 @@
import ru.runa.junit.ArrayAssert;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
-import ru.runa.wfe.service.ExecutorService;
-import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.*;
import java.util.List;
@@ -33,76 +31,69 @@
* Created on 16.02.2005
*/
public class ExecutorServiceDelegateGetGroupsByIDsTest extends ServletTestCase {
- private ServiceTestHelper th;
-
- private ExecutorService executorService;
-
- private static String testPrefix = ExecutorServiceDelegateAddManyExecutorsToGroupsTest.class.getName();
-
+ private ServiceTestHelper h;
private List additionalGroups;
private List additionalGroupsIDs;
private final List readPermissions = Lists.newArrayList(Permission.READ);
- protected void setUp() throws Exception {
- executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- additionalGroups = th.createGroupArray("additionalG", "Additional Group");
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(readPermissions, additionalGroups);
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
+ additionalGroups = h.createGroupArray("additionalG", "Additional Group");
+ h.setPermissionsToAuthorizedActor(readPermissions, additionalGroups);
additionalGroupsIDs = Lists.newArrayList();
for (Group group : additionalGroups) {
additionalGroupsIDs.add(group.getId());
}
- super.setUp();
}
- public void testGetGroupsByAuthorizedPerformer() throws Exception {
- List returnedGroups = th.getExecutors(th.getAuthorizedPerformerUser(), additionalGroupsIDs);
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ additionalGroupsIDs = null;
+ additionalGroups = null;
+ }
+
+ public void testGetGroupsByAuthorizedUser() {
+ List returnedGroups = h.getExecutors(h.getAuthorizedUser(), additionalGroupsIDs);
ArrayAssert.assertWeakEqualArrays("Groups retuned by businessDelegate differes with expected", returnedGroups, additionalGroups);
}
- public void testGetGroupsByUnauthorizedPerformer() throws Exception {
+ public void testGetGroupsByUnauthorizedUser() {
try {
- th.getExecutors(th.getUnauthorizedPerformerUser(), additionalGroupsIDs);
- assertTrue("businessDelegate allow to getGroups() with UnauthorizedPerformerSubject", false);
+ h.getExecutors(h.getUnauthorizedUser(), additionalGroupsIDs);
+ fail();
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetUnexistedGroupByAuthorizedPerformer() throws Exception {
+ public void testGetUnexistedGroupByAuthorizedUser() {
additionalGroupsIDs = Lists.newArrayList(-1L, -2L, -3L);
try {
- th.getExecutors(th.getAuthorizedPerformerUser(), additionalGroupsIDs);
- assertTrue("businessDelegate does not throw Exception to getGroups() for unexisting groups", false);
+ h.getExecutors(h.getAuthorizedUser(), additionalGroupsIDs);
+ fail("businessDelegate does not throw Exception to getGroups() for unexisting groups");
} catch (ExecutorDoesNotExistException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetActorsInsteadOfGroups() throws Exception {
- List additional = th.createMixedActorsGroupsArray("mixed", "Additional mixed");
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(readPermissions, additional);
+ public void testGetActorsInsteadOfGroups() {
+ List additional = h.createMixedActorsGroupsArray("mixed", "Additional mixed");
+ h.setPermissionsToAuthorizedActor(readPermissions, additional);
additionalGroupsIDs = Lists.newArrayList();
for (Executor executor : additional) {
additionalGroupsIDs.add(executor.getId());
}
try {
- List actors = th.getExecutors(th.getAuthorizedPerformerUser(), additionalGroupsIDs);
+ List actors = h.getExecutors(h.getAuthorizedUser(), additionalGroupsIDs);
// TODO assertTrue("businessDelegate allow to getGroup() where the actor really is returned.", false);
} catch (ExecutorDoesNotExistException e) {
- // That's what we expect
+ // Expected.
fail("TODO trap");
}
}
-
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- additionalGroupsIDs = null;
- additionalGroups = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupsInThatExecutorNotPresentTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupsInThatExecutorNotPresentTest.java
index bc908f4ba9..fe45abc75b 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupsInThatExecutorNotPresentTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateGetGroupsInThatExecutorNotPresentTest.java
@@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
@@ -38,98 +39,92 @@
import com.google.common.collect.Lists;
public class ExecutorServiceDelegateGetGroupsInThatExecutorNotPresentTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateGetGroupsInThatExecutorNotPresentTest.class.getName();
-
private Group group;
-
private Group subGroup;
-
private Actor actor;
private Map executorsMap;
@Override
- protected void setUp() throws Exception {
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- List readPermissions = Lists.newArrayList(Permission.READ);
- executorsMap = th.getDefaultExecutorsMap();
+
+ h.createDefaultExecutorsMap();
+ executorsMap = h.getDefaultExecutorsMap();
actor = (Actor) executorsMap.get(ServiceTestHelper.SUB_GROUP_ACTOR_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, actor);
group = (Group) executorsMap.get(ServiceTestHelper.BASE_GROUP_NAME);
subGroup = (Group) executorsMap.get(ServiceTestHelper.SUB_GROUP_NAME);
- th.setPermissionsToAuthorizedPerformer(readPermissions, group);
- th.setPermissionsToAuthorizedPerformer(readPermissions, subGroup);
- actor = executorService.getExecutor(th.getAdminUser(), actor.getId());
- group = executorService.getExecutor(th.getAdminUser(), group.getId());
- subGroup = executorService.getExecutor(th.getAdminUser(), subGroup.getId());
+ val pp = Lists.newArrayList(Permission.READ);
+ h.setPermissionsToAuthorizedActor(pp, actor);
+ h.setPermissionsToAuthorizedActor(pp, group);
+ h.setPermissionsToAuthorizedActor(pp, subGroup);
- super.setUp();
+ actor = executorService.getExecutor(h.getAdminUser(), actor.getId());
+ group = executorService.getExecutor(h.getAdminUser(), group.getId());
+ subGroup = executorService.getExecutor(h.getAdminUser(), subGroup.getId());
}
- final public void testgetExecutorsInThatExecutorNotPresentByAuthorizedPerformer1() throws Exception {
- List calculatedGroups = executorService.getExecutorGroups(th.getAuthorizedPerformerUser(), actor, th.getExecutorBatchPresentation(),
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ h = null;
+ executorsMap = null;
+ executorService = null;
+ actor = null;
+ group = null;
+ subGroup = null;
+ }
+
+ public void testgetExecutorsInThatExecutorNotPresentByAuthorizedUser1() {
+ List calculatedGroups = executorService.getExecutorGroups(h.getAuthorizedUser(), actor, h.getExecutorBatchPresentation(),
true);
List realGroups = Lists.newArrayList(group);
ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutorsInThatExecutorNotPresent() returns wrong group set", realGroups,
calculatedGroups);
}
- final public void testgetExecutorsInThatExecutorNotPresentByAuthorizedPerformer2() throws Exception {
- List calculatedGroups = executorService.getExecutorGroups(th.getAuthorizedPerformerUser(), group, th.getExecutorBatchPresentation(),
+ public void testgetExecutorsInThatExecutorNotPresentByAuthorizedUser2() {
+ List calculatedGroups = executorService.getExecutorGroups(h.getAuthorizedUser(), group, h.getExecutorBatchPresentation(),
true);
List realGroups = Lists.newArrayList(subGroup);
ArrayAssert.assertWeakEqualArrays("businessDelegate.getExecutorsInThatExecutorNotPresent() returns wrong group set", realGroups,
calculatedGroups);
}
- public void testGetExecutorGroupsByUnauthorizedPerformer() throws Exception {
+ public void testGetExecutorGroupsByUnauthorizedUser() {
try {
- executorService.getExecutorGroups(th.getUnauthorizedPerformerUser(), actor, th.getExecutorBatchPresentation(), true);
- assertTrue("businessDelegate.getExecutorsInThatExecutorNotPresent() no AuthorizationFailedException", false);
+ executorService.getExecutorGroups(h.getUnauthorizedUser(), actor, h.getExecutorBatchPresentation(), true);
+ fail("businessDelegate.getExecutorsInThatExecutorNotPresent() no AuthorizationFailedException");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetExecutorGroupsWithoutPermission() throws Exception {
+ public void testGetExecutorGroupsWithoutPermission() {
try {
List noPermissions = Lists.newArrayList();
- th.setPermissionsToAuthorizedPerformer(noPermissions, actor);
- actor = executorService.getExecutor(th.getAdminUser(), actor.getId());
- executorService.getExecutorGroups(th.getAuthorizedPerformerUser(), actor, th.getExecutorBatchPresentation(), true);
- assertTrue("testgetExecutorsInThatExecutorNotPresentwithoutPermission no Exception", false);
+ h.setPermissionsToAuthorizedActor(noPermissions, actor);
+ actor = executorService.getExecutor(h.getAdminUser(), actor.getId());
+ executorService.getExecutorGroups(h.getAuthorizedUser(), actor, h.getExecutorBatchPresentation(), true);
+ fail("testgetExecutorsInThatExecutorNotPresentwithoutPermission no Exception");
} catch (AuthorizationException e) {
- // That's what we expect
+ // Expected.
}
}
- public void testGetExecutorGroupsWithFakeSubject() throws Exception {
+ public void testGetExecutorGroupsWithFakeUser() {
try {
- User fakeUser = th.getFakeUser();
- executorService.getExecutorGroups(fakeUser, actor, th.getExecutorBatchPresentation(), true);
- assertTrue("testGetExecutorGroupsWithFakeSubject no Exception", false);
+ User fakeUser = h.getFakeUser();
+ executorService.getExecutorGroups(fakeUser, actor, h.getExecutorBatchPresentation(), true);
+ fail();
} catch (AuthenticationException e) {
- // That's what we expect
+ // Expected.
}
}
-
- @Override
- protected void tearDown() throws Exception {
- th.releaseResources();
- th = null;
- executorsMap = null;
- executorService = null;
- actor = null;
- group = null;
- subGroup = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateHierarchyPermissionsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateHierarchyPermissionsTest.java
index db51d82177..9730cb0ab5 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateHierarchyPermissionsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateHierarchyPermissionsTest.java
@@ -26,69 +26,52 @@
import ru.runa.wfe.service.AuthorizationService;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.*;
-
-import java.util.Collection;
-import java.util.Map;
+import ru.runa.wfe.user.Actor;
+import ru.runa.wfe.user.Group;
+import ru.runa.wfe.user.User;
+/**
+ * Sets some permission on Group and tests Group's member is allowed.
+ */
public class ExecutorServiceDelegateHierarchyPermissionsTest extends ServletTestCase {
-
private static final String ACTOR_PWD = "ActorPWD";
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
-
private AuthorizationService authorizationService;
- private static String testPrefix = ExecutorServiceDelegateHierarchyPermissionsTest.class.getName();
-
private Actor actor;
-
private Group group;
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(ExecutorServiceDelegateHierarchyPermissionsTest.class.getName());
executorService = Delegates.getExecutorService();
authorizationService = Delegates.getAuthorizationService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- Collection updatePermission = Lists.newArrayList(Permission.UPDATE);
- Collection loginPermissions = Lists.newArrayList(Permission.LOGIN);
- Collection createExecutorPermissions = Lists.newArrayList(Permission.CREATE);
- Map executorsMap = th.getDefaultExecutorsMap();
+ h.createDefaultExecutorsMap();
+ actor = h.getBaseGroupActor();
+ group = h.getBaseGroup();
- actor = (Actor) executorsMap.get(ServiceTestHelper.BASE_GROUP_ACTOR_NAME);
- group = (Group) executorsMap.get(ServiceTestHelper.BASE_GROUP_NAME);
+ executorService.setPassword(h.getAdminUser(), actor, ACTOR_PWD);
- th.setPermissionsToAuthorizedPerformerOnExecutors(updatePermission);
-
- actor = executorService.getExecutor(th.getAdminUser(), actor.getId());
- authorizationService.setPermissions(th.getAuthorizedPerformerUser(), actor.getId(), loginPermissions, SecuredSingleton.EXECUTORS);
- group = executorService.getExecutor(th.getAdminUser(), group.getId());
- authorizationService.setPermissions(th.getAuthorizedPerformerUser(), group.getId(), createExecutorPermissions, SecuredSingleton.EXECUTORS);
- actor = executorService.getExecutor(th.getAdminUser(), actor.getId());
- executorService.setPassword(th.getAuthorizedPerformerUser(), actor, ACTOR_PWD);
-
- super.setUp();
+ authorizationService.setPermissions(h.getAdminUser(), group.getId(), Lists.newArrayList(Permission.CREATE_EXECUTOR),
+ SecuredSingleton.SYSTEM);
+ authorizationService.setPermissions(h.getAdminUser(), actor.getId(), Lists.newArrayList(Permission.LOGIN),
+ SecuredSingleton.SYSTEM);
}
- public void testPermissionsInheritance() throws Exception {
- User additionalUser = Delegates.getAuthenticationService().authenticateByLoginPassword(actor.getName(), ACTOR_PWD);
-
- if (!authorizationService.isAllowed(additionalUser, Permission.CREATE, SecuredSingleton.EXECUTORS)) {
- assertTrue("unproper createExecutor permission ", false);
- }
- }
-
- protected void tearDown() throws Exception {
- th.releaseResources();
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
executorService = null;
authorizationService = null;
actor = null;
group = null;
-
- super.tearDown();
}
+ public void testPermissionsInheritance() {
+ User user = Delegates.getAuthenticationService().authenticateByLoginPassword(actor.getName(), ACTOR_PWD);
+ assertTrue(authorizationService.isAllowed(user, Permission.CREATE_EXECUTOR, SecuredSingleton.SYSTEM));
+ }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRelationsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRelationsTest.java
index 9b501e6233..e5b4897115 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRelationsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRelationsTest.java
@@ -18,11 +18,8 @@
package ru.runa.af.delegate;
import java.util.List;
-
import junit.framework.Assert;
-
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.presentation.BatchPresentationFactory;
import ru.runa.wfe.relation.Relation;
@@ -32,81 +29,78 @@
import ru.runa.wfe.user.Actor;
public class ExecutorServiceDelegateRelationsTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private RelationService relationService;
@Override
- protected void setUp() throws Exception {
+ protected void setUp() {
relationService = Delegates.getRelationService();
- th = new ServiceTestHelper(ExecutorServiceDelegateRelationsTest.class.getName());
- th.createDefaultExecutorsMap();
- super.setUp();
+ h = new ServiceTestHelper(getClass().getName());
+ h.createDefaultExecutorsMap();
}
@Override
- protected void tearDown() throws Exception {
- th.releaseResources();
- super.tearDown();
+ protected void tearDown() {
+ h.releaseResources();
}
/**
* Test for adding and removing relation groups. No relation pairs added; no relation pairs testing. Loading relations with
- * {@link ru.runa.wfe.presentation.BatchPresentations} test.
+ * {@link ru.runa.wfe.presentation.BatchPresentation} test.
*/
- public void testAddRemoveRelationGroup() throws Exception {
+ public void testAddRemoveRelationGroup() {
String groupName = "Relation1";
String groupName2 = "Relation2";
- Relation relationGroup = relationService.createRelation(th.getAdminUser(), new Relation(groupName, groupName));
+ Relation relationGroup = relationService.createRelation(h.getAdminUser(), new Relation(groupName, groupName));
Assert.assertEquals(groupName, relationGroup.getName());
- List groups = relationService.getRelations(th.getAdminUser(), BatchPresentationFactory.RELATIONS.createDefault());
+ List groups = relationService.getRelations(h.getAdminUser(), BatchPresentationFactory.RELATIONS.createDefault());
Assert.assertEquals(1, groups.size());
Assert.assertEquals(groups.get(0).getName(), groupName);
- Relation relationGroup2 = relationService.createRelation(th.getAdminUser(), new Relation(groupName2, groupName2));
- groups = relationService.getRelations(th.getAdminUser(), BatchPresentationFactory.RELATIONS.createDefault());
+ Relation relationGroup2 = relationService.createRelation(h.getAdminUser(), new Relation(groupName2, groupName2));
+ groups = relationService.getRelations(h.getAdminUser(), BatchPresentationFactory.RELATIONS.createDefault());
Assert.assertEquals(2, groups.size());
Assert.assertTrue((groups.get(0).getName().equals(groupName) && groups.get(1).getName().equals(groupName2))
|| (groups.get(0).getName().equals(groupName2) && groups.get(1).getName().equals(groupName)));
- relationService.removeRelation(th.getAdminUser(), relationGroup.getId());
- groups = relationService.getRelations(th.getAdminUser(), BatchPresentationFactory.RELATIONS.createDefault());
+ relationService.removeRelation(h.getAdminUser(), relationGroup.getId());
+ groups = relationService.getRelations(h.getAdminUser(), BatchPresentationFactory.RELATIONS.createDefault());
Assert.assertEquals(1, groups.size());
Assert.assertEquals(groups.get(0).getName(), groupName2);
- relationService.removeRelation(th.getAdminUser(), relationGroup2.getId());
- groups = relationService.getRelations(th.getAdminUser(), BatchPresentationFactory.RELATIONS.createDefault());
+ relationService.removeRelation(h.getAdminUser(), relationGroup2.getId());
+ groups = relationService.getRelations(h.getAdminUser(), BatchPresentationFactory.RELATIONS.createDefault());
Assert.assertEquals(0, groups.size());
}
/**
* Add/remove relation pairs test. Simple test for relation pair loading.
*/
- public void testAddRemoveRelation() throws Exception {
+ public void testAddRemoveRelation() {
String groupName = "Relation1";
String groupName2 = "Relation2";
- Relation relationGroup = relationService.createRelation(th.getAdminUser(), new Relation(groupName, groupName));
- Relation relationGroup2 = relationService.createRelation(th.getAdminUser(), new Relation(groupName2, groupName2));
- Actor a1 = th.createActorIfNotExist("1", "1");
- Actor a2 = th.createActorIfNotExist("2", "2");
- Actor a3 = th.createActorIfNotExist("3", "3");
- relationService.addRelationPair(th.getAdminUser(), relationGroup.getId(), a1, a3);
- relationService.addRelationPair(th.getAdminUser(), relationGroup2.getId(), a2, a3);
- relationService.addRelationPair(th.getAdminUser(), relationGroup.getId(), a1, a3);
- relationService.addRelationPair(th.getAdminUser(), relationGroup2.getId(), a1, a3);
- List relations = relationService.getRelationPairs(th.getAdminUser(), groupName,
+ Relation relationGroup = relationService.createRelation(h.getAdminUser(), new Relation(groupName, groupName));
+ Relation relationGroup2 = relationService.createRelation(h.getAdminUser(), new Relation(groupName2, groupName2));
+ Actor a1 = h.createActorIfNotExist("1", "1");
+ Actor a2 = h.createActorIfNotExist("2", "2");
+ Actor a3 = h.createActorIfNotExist("3", "3");
+ relationService.addRelationPair(h.getAdminUser(), relationGroup.getId(), a1, a3);
+ relationService.addRelationPair(h.getAdminUser(), relationGroup2.getId(), a2, a3);
+ relationService.addRelationPair(h.getAdminUser(), relationGroup.getId(), a1, a3);
+ relationService.addRelationPair(h.getAdminUser(), relationGroup2.getId(), a1, a3);
+ List relations = relationService.getRelationPairs(h.getAdminUser(), groupName,
BatchPresentationFactory.RELATION_PAIRS.createDefault());
assertEquals(1, relations.size());
assertEquals(a1, relations.get(0).getLeft());
assertEquals(a3, relations.get(0).getRight());
RelationPair toRemove = relations.get(0);
- relations = relationService.getRelationPairs(th.getAdminUser(), groupName2, BatchPresentationFactory.RELATION_PAIRS.createDefault());
+ relations = relationService.getRelationPairs(h.getAdminUser(), groupName2, BatchPresentationFactory.RELATION_PAIRS.createDefault());
assertEquals(2, relations.size());
assertTrue(((relations.get(0).getLeft().equals(a2) && relations.get(0).getRight().equals(a3))
&& (relations.get(1).getLeft().equals(a1) && relations.get(1).getRight().equals(a3)))
|| ((relations.get(1).getLeft().equals(a2) && relations.get(1).getRight().equals(a3))
&& (relations.get(0).getLeft().equals(a1) && relations.get(0).getRight().equals(a3))));
- relationService.removeRelationPair(th.getAdminUser(), toRemove.getId());
+ relationService.removeRelationPair(h.getAdminUser(), toRemove.getId());
assertEquals(0,
- relationService.getRelationPairs(th.getAdminUser(), groupName, BatchPresentationFactory.RELATION_PAIRS.createDefault()).size());
- relationService.removeRelation(th.getAdminUser(), relationGroup.getId());
- relationService.removeRelation(th.getAdminUser(), relationGroup2.getId());
+ relationService.getRelationPairs(h.getAdminUser(), groupName, BatchPresentationFactory.RELATION_PAIRS.createDefault()).size());
+ relationService.removeRelation(h.getAdminUser(), relationGroup.getId());
+ relationService.removeRelation(h.getAdminUser(), relationGroup2.getId());
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveExecutorFromManyGroupsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveExecutorFromManyGroupsTest.java
index ea5dde31e5..31ab97639c 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveExecutorFromManyGroupsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveExecutorFromManyGroupsTest.java
@@ -18,28 +18,25 @@
package ru.runa.af.delegate;
import com.google.common.collect.Lists;
+import java.util.Collection;
+import java.util.List;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
-import ru.runa.wfe.InternalApplicationException;
-import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.*;
-
-import java.util.Collection;
-import java.util.List;
+import ru.runa.wfe.user.Actor;
+import ru.runa.wfe.user.Executor;
+import ru.runa.wfe.user.ExecutorDoesNotExistException;
+import ru.runa.wfe.user.Group;
/*
*/
public class ExecutorServiceDelegateRemoveExecutorFromManyGroupsTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateRemoveExecutorFromManyGroupsTest.class.getName();
-
private long additionalGroupId;
private long additionalActorId;
@@ -48,13 +45,14 @@ public class ExecutorServiceDelegateRemoveExecutorFromManyGroupsTest extends Ser
private final Collection updatePermissions = Lists.newArrayList(Permission.UPDATE);
private final Collection readPermissions = Lists.newArrayList(Permission.READ);
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- Actor additionalActor = th.createActorIfNotExist("additionalA", "Additional Actor");
- Group additionalGroup = th.createGroupIfNotExist("additionalG", "Additional Group");
- List additionalGroups = th.createGroupArray("additionalGroups", "Additional Groups");
+ Actor additionalActor = h.createActorIfNotExist("additionalA", "Additional Actor");
+ Group additionalGroup = h.createGroupIfNotExist("additionalG", "Additional Group");
+ List additionalGroups = h.createGroupArray("additionalGroups", "Additional Groups");
additionalActorId = additionalActor.getId();
additionalGroupId = additionalGroup.getId();
@@ -63,105 +61,100 @@ protected void setUp() throws Exception {
additionalGroupsIds.add(group.getId());
}
- th.setPermissionsToAuthorizedPerformer(updatePermissions, getAdditionalActor());
- th.setPermissionsToAuthorizedPerformer(updatePermissions, getAdditionalGroup());
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(updatePermissions, getAdditionalGroups());
+ h.setPermissionsToAuthorizedActor(updatePermissions, getAdditionalActor());
+ h.setPermissionsToAuthorizedActor(updatePermissions, getAdditionalGroup());
+ h.setPermissionsToAuthorizedActor(updatePermissions, getAdditionalGroups());
- executorService.addExecutorToGroups(th.getAuthorizedPerformerUser(), getAdditionalActor().getId(), th.toIds(getAdditionalGroups()));
- executorService.addExecutorToGroups(th.getAuthorizedPerformerUser(), getAdditionalGroup().getId(), th.toIds(getAdditionalGroups()));
+ executorService.addExecutorToGroups(h.getAuthorizedUser(), getAdditionalActor().getId(), h.toIds(getAdditionalGroups()));
+ executorService.addExecutorToGroups(h.getAuthorizedUser(), getAdditionalGroup().getId(), h.toIds(getAdditionalGroups()));
+ }
- super.setUp();
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
}
- private List getAdditionalGroups()
- throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return th.getExecutors(th.getAdminUser(), additionalGroupsIds);
+ private List getAdditionalGroups() {
+ return h.getExecutors(h.getAdminUser(), additionalGroupsIds);
}
- private Actor getAdditionalActor()
- throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return executorService.getExecutor(th.getAdminUser(), additionalActorId);
+ private Actor getAdditionalActor() {
+ return executorService.getExecutor(h.getAdminUser(), additionalActorId);
}
- private Group getAdditionalGroup()
- throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return executorService.getExecutor(th.getAdminUser(), additionalGroupId);
+ private Group getAdditionalGroup() {
+ return executorService.getExecutor(h.getAdminUser(), additionalGroupId);
}
- public void testRemoveActorFromGroupsByAuthorizedPerformer() throws Exception {
+ public void testRemoveActorFromGroupsByAuthorizedUser() {
- assertTrue("Executor is not in groups before removing", th.isExecutorInGroups(getAdditionalActor(), getAdditionalGroups()));
+ assertTrue("Executor is not in groups before removing", h.isExecutorInGroups(getAdditionalActor(), getAdditionalGroups()));
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(readPermissions, getAdditionalGroups());
+ h.setPermissionsToAuthorizedActor(readPermissions, getAdditionalGroups());
Executor executor = getAdditionalActor();
try {
- executorService.removeExecutorFromGroups(th.getAuthorizedPerformerUser(), executor.getId(), th.toIds(getAdditionalGroups()));
+ executorService.removeExecutorFromGroups(h.getAuthorizedUser(), executor.getId(), h.toIds(getAdditionalGroups()));
fail("Executors removed from group without corresponding permissions");
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(updatePermissions, getAdditionalGroups());
- executorService.removeExecutorFromGroups(th.getAuthorizedPerformerUser(), executor.getId(), th.toIds(getAdditionalGroups()));
+ h.setPermissionsToAuthorizedActor(updatePermissions, getAdditionalGroups());
+ executorService.removeExecutorFromGroups(h.getAuthorizedUser(), executor.getId(), h.toIds(getAdditionalGroups()));
- assertFalse("Executor not removed from group ", th.isExecutorInGroups(getAdditionalActor(), getAdditionalGroups()));
+ assertFalse("Executor not removed from group ", h.isExecutorInGroups(getAdditionalActor(), getAdditionalGroups()));
}
- public void testRemoveGrouprFromGroupsByAuthorizedPerformer() throws Exception {
+ public void testRemoveGrouprFromGroupsByAuthorizedUser() {
- assertTrue("Executor is not in groups before removing", th.isExecutorInGroups(getAdditionalActor(), getAdditionalGroups()));
+ assertTrue("Executor is not in groups before removing", h.isExecutorInGroups(getAdditionalActor(), getAdditionalGroups()));
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(readPermissions, getAdditionalGroups());
+ h.setPermissionsToAuthorizedActor(readPermissions, getAdditionalGroups());
Executor executor = getAdditionalGroup();
try {
- executorService.removeExecutorFromGroups(th.getAuthorizedPerformerUser(), executor.getId(), th.toIds(getAdditionalGroups()));
+ executorService.removeExecutorFromGroups(h.getAuthorizedUser(), executor.getId(), h.toIds(getAdditionalGroups()));
fail("Executors removed from group without corresponding permissions");
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(updatePermissions, getAdditionalGroups());
- executorService.removeExecutorFromGroups(th.getAuthorizedPerformerUser(), executor.getId(), th.toIds(getAdditionalGroups()));
+ h.setPermissionsToAuthorizedActor(updatePermissions, getAdditionalGroups());
+ executorService.removeExecutorFromGroups(h.getAuthorizedUser(), executor.getId(), h.toIds(getAdditionalGroups()));
- assertFalse("Executor not removed from group ", th.isExecutorInGroups(getAdditionalGroup(), getAdditionalGroups()));
+ assertFalse("Executor not removed from group ", h.isExecutorInGroups(getAdditionalGroup(), getAdditionalGroups()));
}
- public void testRemoveActorFromGroupsByUnAuthorizedPerformer() throws Exception {
+ public void testRemoveActorFromGroupsByUnAuthorizedUser() {
Executor executor = getAdditionalActor();
try {
- executorService.removeExecutorFromGroups(th.getUnauthorizedPerformerUser(), executor.getId(), th.toIds(getAdditionalGroups()));
- fail("Executor is removed from groups ByUnAuthorizedPerformer");
+ executorService.removeExecutorFromGroups(h.getUnauthorizedUser(), executor.getId(), h.toIds(getAdditionalGroups()));
+ fail();
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
}
- public void testRemoveGroupFromGroupsByUnAuthorizedPerformer() throws Exception {
+ public void testRemoveGroupFromGroupsByUnAuthorizedUser() {
Executor executor = getAdditionalGroup();
try {
- executorService.removeExecutorFromGroups(th.getUnauthorizedPerformerUser(), executor.getId(), th.toIds(getAdditionalGroups()));
- fail("Executor is removed from groups ByUnAuthorizedPerformer");
+ executorService.removeExecutorFromGroups(h.getUnauthorizedUser(), executor.getId(), h.toIds(getAdditionalGroups()));
+ fail();
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
}
- public void testRemoveFakeActorFromGroups() throws Exception {
- Executor executor = th.getFakeActor();
+ public void testRemoveFakeActorFromGroups() {
+ Executor executor = h.getFakeActor();
try {
- executorService.removeExecutorFromGroups(th.getAuthorizedPerformerUser(), executor.getId(), th.toIds(getAdditionalGroups()));
+ executorService.removeExecutorFromGroups(h.getAuthorizedUser(), executor.getId(), h.toIds(getAdditionalGroups()));
fail("FakeExecutor removed from groups ");
} catch (AuthorizationException e) {
// TODO
} catch (ExecutorDoesNotExistException e) {
- // this is supposed result
+ // Expected.
fail("TODO trap");
}
}
-
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveExecutorsFromGroupTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveExecutorsFromGroupTest.java
index 7badaad2a7..55a59ede90 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveExecutorsFromGroupTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveExecutorsFromGroupTest.java
@@ -19,126 +19,109 @@
package ru.runa.af.delegate;
import com.google.common.collect.Lists;
+import java.util.Collection;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
-import ru.runa.wfe.InternalApplicationException;
-import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.Actor;
-import ru.runa.wfe.user.ExecutorDoesNotExistException;
import ru.runa.wfe.user.Group;
-import java.util.Collection;
-
public class ExecutorServiceDelegateRemoveExecutorsFromGroupTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateRemoveExecutorsFromGroupTest.class.getName();
-
private Actor actor;
-
private Group group;
-
private Group subGroup;
private final Collection updatePermissions = Lists.newArrayList(Permission.UPDATE);
-
private final Collection readPermissions = Lists.newArrayList(Permission.READ);
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() {
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
+ h = new ServiceTestHelper(getClass().getName());
+ h.createDefaultExecutorsMap();
- actor = th.getBaseGroupActor();
- th.setPermissionsToAuthorizedPerformer(readPermissions, actor);
- group = th.getBaseGroup();
- th.setPermissionsToAuthorizedPerformer(updatePermissions, group);
- subGroup = th.getSubGroup();
- th.setPermissionsToAuthorizedPerformer(readPermissions, subGroup);
+ actor = h.getBaseGroupActor();
+ group = h.getBaseGroup();
+ subGroup = h.getSubGroup();
- super.setUp();
+ h.setPermissionsToAuthorizedActor(readPermissions, actor);
+ h.setPermissionsToAuthorizedActor(updatePermissions, group);
+ h.setPermissionsToAuthorizedActor(readPermissions, subGroup);
}
- private Actor getActor() throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return executorService.getExecutor(th.getAdminUser(), actor.getId());
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
+ actor = null;
+ group = null;
}
- private Group getGroup() throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return executorService.getExecutor(th.getAdminUser(), group.getId());
+ private Actor getActor() {
+ return executorService.getExecutor(h.getAdminUser(), actor.getId());
}
- private Group getSubGroup() throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return executorService.getExecutor(th.getAdminUser(), subGroup.getId());
+ private Group getGroup() {
+ return executorService.getExecutor(h.getAdminUser(), group.getId());
}
- public void testRemoveActorFromGroupByAuthorizedPerformer() throws Exception {
+ private Group getSubGroup() {
+ return executorService.getExecutor(h.getAdminUser(), subGroup.getId());
+ }
- assertTrue("Executor is not in group before removing", th.isExecutorInGroup(actor, group));
+ public void testRemoveActorFromGroupByAuthorizedUser() {
+ assertTrue("Executor is not in group before removing", h.isExecutorInGroup(actor, group));
- th.setPermissionsToAuthorizedPerformer(readPermissions, group);
+ h.setPermissionsToAuthorizedActor(readPermissions, group);
try {
- executorService.removeExecutorsFromGroup(th.getAuthorizedPerformerUser(), Lists.newArrayList(actor.getId()), group.getId());
+ executorService.removeExecutorsFromGroup(h.getAuthorizedUser(), Lists.newArrayList(actor.getId()), group.getId());
fail("Actor removed from group without corresponding permissions");
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
- th.setPermissionsToAuthorizedPerformer(updatePermissions, group);
-
- executorService.removeExecutorsFromGroup(th.getAuthorizedPerformerUser(), Lists.newArrayList(actor.getId()), group.getId());
-
- assertFalse("Executor not removed from group ", th.isExecutorInGroup(getActor(), getGroup()));
+ h.setPermissionsToAuthorizedActor(updatePermissions, group);
+ executorService.removeExecutorsFromGroup(h.getAuthorizedUser(), Lists.newArrayList(actor.getId()), group.getId());
+ assertFalse("Executor not removed from group ", h.isExecutorInGroup(getActor(), getGroup()));
}
- public void testRemoveSubGroupFromGroupByAuthorizedPerformerWithReadPermissionOnGroup() throws Exception {
-
- assertTrue("Executor is not in group before removing", th.isExecutorInGroup(subGroup, group));
+ public void testRemoveSubGroupFromGroupByAuthorizedUserWithReadPermissionOnGroup() {
+ assertTrue("Executor is not in group before removing", h.isExecutorInGroup(subGroup, group));
- th.setPermissionsToAuthorizedPerformer(readPermissions, group);
+ h.setPermissionsToAuthorizedActor(readPermissions, group);
try {
- executorService.removeExecutorsFromGroup(th.getAuthorizedPerformerUser(), Lists.newArrayList(subGroup.getId()), group.getId());
+ executorService.removeExecutorsFromGroup(h.getAuthorizedUser(), Lists.newArrayList(subGroup.getId()), group.getId());
fail("Subgroup removed from group without corresponding permissions");
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
- th.setPermissionsToAuthorizedPerformer(updatePermissions, group);
-
- executorService.removeExecutorsFromGroup(th.getAuthorizedPerformerUser(), Lists.newArrayList(subGroup.getId()), group.getId());
-
- assertFalse("Executor not removed from group ", th.isExecutorInGroup(getSubGroup(), getGroup()));
+ h.setPermissionsToAuthorizedActor(updatePermissions, group);
+ executorService.removeExecutorsFromGroup(h.getAuthorizedUser(), Lists.newArrayList(subGroup.getId()), group.getId());
+ assertFalse("Executor not removed from group ", h.isExecutorInGroup(getSubGroup(), getGroup()));
}
- public void testRemoveActorFromGroupByUnAuthorizedPerformer() throws Exception {
+ public void testRemoveActorFromGroupByUnAuthorizedUser() {
try {
- executorService.removeExecutorsFromGroup(th.getUnauthorizedPerformerUser(), Lists.newArrayList(actor.getId()), group.getId());
- fail("Actor is removed from group ByUnAuthorizedPerformer");
+ executorService.removeExecutorsFromGroup(h.getUnauthorizedUser(), Lists.newArrayList(actor.getId()), group.getId());
+ fail();
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
}
- public void testRemoveSubGroupFromGroupByUnAuthorizedPerformer() throws Exception {
+ public void testRemoveSubGroupFromGroupByUnAuthorizedUser() {
try {
- executorService.removeExecutorsFromGroup(th.getUnauthorizedPerformerUser(), Lists.newArrayList(subGroup.getId()), group.getId());
- fail("SubGroup is removed from group ByUnAuthorizedPerformer");
+ executorService.removeExecutorsFromGroup(h.getUnauthorizedUser(), Lists.newArrayList(subGroup.getId()), group.getId());
+ fail();
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
}
-
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- actor = null;
- group = null;
-
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveManyExecutorsFromGroupTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveManyExecutorsFromGroupTest.java
index b10d756300..d2373d617c 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveManyExecutorsFromGroupTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveManyExecutorsFromGroupTest.java
@@ -19,98 +19,87 @@
package ru.runa.af.delegate;
import com.google.common.collect.Lists;
+import java.util.Collection;
+import java.util.List;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
-import ru.runa.wfe.InternalApplicationException;
-import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
-import ru.runa.wfe.user.*;
-
-import java.util.Collection;
-import java.util.List;
+import ru.runa.wfe.user.Actor;
+import ru.runa.wfe.user.Executor;
+import ru.runa.wfe.user.Group;
public class ExecutorServiceDelegateRemoveManyExecutorsFromGroupTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateRemoveManyExecutorsFromGroupTest.class.getName();
-
private Group additionalGroup;
-
private List additionalActors;
private final Collection updatePermissions = Lists.newArrayList(Permission.UPDATE);
-
private final Collection readPermissions = Lists.newArrayList(Permission.READ);
- private List getAdditionalActors()
- throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- List ids = Lists.newArrayList();
- for (Executor executor : additionalActors) {
- ids.add(executor.getId());
- }
- return th.getExecutors(th.getAdminUser(), ids);
- }
+ @Override
+ protected void setUp() {
+ executorService = Delegates.getExecutorService();
+ h = new ServiceTestHelper(getClass().getName());
- private Group getAdditionalGroup()
- throws InternalApplicationException, AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
- return executorService.getExecutor(th.getAuthorizedPerformerUser(), additionalGroup.getId());
- }
+ additionalGroup = h.createGroupIfNotExist("additionalG", "Additional Group");
+ additionalActors = h.createActorArray("additionalMixed", "Additional Mixed");
- protected void setUp() throws Exception {
- executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalGroup);
+ h.setPermissionsToAuthorizedActor(updatePermissions, additionalActors);
- additionalGroup = th.createGroupIfNotExist("additionalG", "Additional Group");
- additionalActors = th.createActorArray("additionalMixed", "Additional Mixed");
+ executorService.addExecutorsToGroup(h.getAuthorizedUser(), h.toIds(additionalActors), additionalGroup.getId());
+ }
- th.setPermissionsToAuthorizedPerformer(updatePermissions, additionalGroup);
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(updatePermissions, additionalActors);
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
+ additionalGroup = null;
+ additionalActors = null;
+ }
- executorService.addExecutorsToGroup(th.getAuthorizedPerformerUser(), th.toIds(additionalActors), additionalGroup.getId());
- super.setUp();
+ private List getAdditionalActors() {
+ List ids = Lists.newArrayList();
+ for (Executor executor : additionalActors) {
+ ids.add(executor.getId());
+ }
+ return h.getExecutors(h.getAdminUser(), ids);
}
- public void testRemoveExecutorsFromGroupByAuthorizedPerformer() throws Exception {
+ private Group getAdditionalGroup() {
+ return executorService.getExecutor(h.getAuthorizedUser(), additionalGroup.getId());
+ }
- assertTrue("Executor is not in group before removing", th.isExecutorsInGroup(getAdditionalActors(), getAdditionalGroup()));
+ public void testRemoveExecutorsFromGroupByAuthorizedUser() {
+ assertTrue("Executor is not in group before removing", h.isExecutorsInGroup(getAdditionalActors(), getAdditionalGroup()));
- th.setPermissionsToAuthorizedPerformer(readPermissions, getAdditionalGroup());
+ h.setPermissionsToAuthorizedActor(readPermissions, getAdditionalGroup());
List executors = getAdditionalActors();
try {
- executorService.removeExecutorsFromGroup(th.getAuthorizedPerformerUser(), th.toIds(executors), getAdditionalGroup().getId());
+ executorService.removeExecutorsFromGroup(h.getAuthorizedUser(), h.toIds(executors), getAdditionalGroup().getId());
fail("Executors removed from group without corresponding permissions");
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
- th.setPermissionsToAuthorizedPerformer(updatePermissions, getAdditionalGroup());
-
- executorService.removeExecutorsFromGroup(th.getAuthorizedPerformerUser(), th.toIds(getAdditionalActors()), getAdditionalGroup().getId());
-
- assertFalse("Executor not removed from group ", th.isExecutorsInGroup(getAdditionalActors(), getAdditionalGroup()));
+ h.setPermissionsToAuthorizedActor(updatePermissions, getAdditionalGroup());
+ executorService.removeExecutorsFromGroup(h.getAuthorizedUser(), h.toIds(getAdditionalActors()), getAdditionalGroup().getId());
+ assertFalse("Executor not removed from group ", h.isExecutorsInGroup(getAdditionalActors(), getAdditionalGroup()));
}
- public void testRemoveExecutorsFromGroupByUnAuthorizedPerformer() throws Exception {
+ public void testRemoveExecutorsFromGroupByUnauthorizedUser() {
List executors = getAdditionalActors();
try {
- executorService.removeExecutorsFromGroup(th.getUnauthorizedPerformerUser(), th.toIds(executors), getAdditionalGroup().getId());
- fail("Executors is removed from group ByUnAuthorizedPerformer");
+ executorService.removeExecutorsFromGroup(h.getUnauthorizedUser(), h.toIds(executors), getAdditionalGroup().getId());
+ fail();
} catch (AuthorizationException e) {
- // this is supposed result
+ // Expected.
}
}
-
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- additionalGroup = null;
- additionalActors = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveManyExecutorsTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveManyExecutorsTest.java
index 0d7ef26411..63ffc02578 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveManyExecutorsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateRemoveManyExecutorsTest.java
@@ -18,63 +18,54 @@
package ru.runa.af.delegate;
+import com.google.common.collect.Lists;
import java.util.List;
-
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.Executor;
-import ru.runa.wfe.user.ExecutorDoesNotExistException;
-
-import com.google.common.collect.Lists;
public class ExecutorServiceDelegateRemoveManyExecutorsTest extends ServletTestCase {
- private ServiceTestHelper th;
-
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static String testPrefix = ExecutorServiceDelegateRemoveManyExecutorsTest.class.getName();
-
- private List additionalActorsGroupsMixed;
-
- private final List deletePermissions = Lists.newArrayList(Permission.DELETE);
+ private List maxedActorsGroups;
@Override
- protected void setUp() throws Exception {
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- additionalActorsGroupsMixed = th.createMixedActorsGroupsArray("additionalMixed", "Additional Mixed");
- th.setPermissionsToAuthorizedPerformerOnExecutorsList(deletePermissions, additionalActorsGroupsMixed);
+
+ maxedActorsGroups = h.createMixedActorsGroupsArray("additionalMixed", "Additional Mixed");
+ h.setPermissionsToAuthorizedActor(Lists.newArrayList(Permission.UPDATE), maxedActorsGroups);
}
- public void testRemoveExecutorsByAuthorizedPerformer() throws Exception {
- executorService.remove(th.getAuthorizedPerformerUser(), th.toIds(additionalActorsGroupsMixed));
- for (Executor executor : additionalActorsGroupsMixed) {
- assertFalse("Executor was not deleted.", th.isExecutorExist(executor));
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
+ executorService = null;
+ maxedActorsGroups = null;
+ }
+
+ public void testRemoveExecutorsByAuthorizedUser() {
+ executorService.remove(h.getAuthorizedUser(), h.toIds(maxedActorsGroups));
+ for (Executor executor : maxedActorsGroups) {
+ assertFalse("Executor was not deleted.", h.isExecutorExist(executor));
}
}
- public void testRemoveExecutorsByUnauthorizedPerformer() throws Exception {
+ public void testRemoveExecutorsByUnauthorizedUser() {
try {
- executorService.remove(th.getUnauthorizedPerformerUser(), th.toIds(additionalActorsGroupsMixed));
+ executorService.remove(h.getUnauthorizedUser(), h.toIds(maxedActorsGroups));
fail("Executors were deleted by unauthorize performer.");
} catch (AuthorizationException e) {
- // that's what we expect to see
+ // Expected.
}
- for (Executor executor : additionalActorsGroupsMixed) {
- assertTrue("Executor was deleted.", th.isExecutorExist(executor));
+ for (Executor executor : maxedActorsGroups) {
+ assertTrue("Executor was deleted.", h.isExecutorExist(executor));
}
}
-
- @Override
- protected void tearDown() throws Exception {
- th.releaseResources();
- executorService = null;
- additionalActorsGroupsMixed = null;
- super.tearDown();
- }
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateSetPasswordTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateSetPasswordTest.java
index 8f38fc056a..7860d3ce34 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateSetPasswordTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/ExecutorServiceDelegateSetPasswordTest.java
@@ -18,8 +18,7 @@
package ru.runa.af.delegate;
import com.google.common.collect.Lists;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.security.AuthorizationException;
@@ -27,62 +26,54 @@
import ru.runa.wfe.service.ExecutorService;
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.Actor;
-import ru.runa.wfe.user.ExecutorDoesNotExistException;
import ru.runa.wfe.user.Group;
-import java.util.List;
-
/**
* Created on 27.08.2004
*/
public class ExecutorServiceDelegateSetPasswordTest extends ServletTestCase {
- private ServiceTestHelper th;
+ private static final String NEW_PASSWD = "new passwd";
+ private ServiceTestHelper h;
private ExecutorService executorService;
- private static final String testPrefix = ExecutorServiceDelegateSetPasswordTest.class.getName();
-
- private static final String NEW_PASSWD = "new passwd";
-
private Actor actor;
-
private Group group;
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() {
+ h = new ServiceTestHelper(getClass().getName());
executorService = Delegates.getExecutorService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- List updatePermissions = Lists.newArrayList(Permission.UPDATE);
- actor = th.getBaseGroupActor();
- th.setPermissionsToAuthorizedPerformer(updatePermissions, actor);
- group = th.getBaseGroup();
- th.setPermissionsToAuthorizedPerformer(updatePermissions, group);
- super.setUp();
+ h.createDefaultExecutorsMap();
+ actor = h.getBaseGroupActor();
+ group = h.getBaseGroup();
+
+ val pp = Lists.newArrayList(Permission.UPDATE);
+ h.setPermissionsToAuthorizedActor(pp, actor);
+ h.setPermissionsToAuthorizedActor(pp, group);
}
- protected void tearDown() throws Exception {
- th.releaseResources();
+ @Override
+ protected void tearDown() {
+ h.releaseResources();
executorService = null;
actor = null;
group = null;
- super.tearDown();
}
- public void testSetPasswordByAuthorizedPerformer() throws Exception {
- executorService.setPassword(th.getAuthorizedPerformerUser(), actor, NEW_PASSWD);
-
- assertTrue("Password is not correct.", th.isPasswordCorrect(actor.getName(), NEW_PASSWD));
+ public void testSetPasswordByAuthorizedUser() {
+ executorService.setPassword(h.getAuthorizedUser(), actor, NEW_PASSWD);
+ assertTrue("Password is not correct.", h.isPasswordCorrect(actor.getName(), NEW_PASSWD));
}
- public void testSetPasswordByUnauthorizedPerformer() throws Exception {
-
+ public void testSetPasswordByUnauthorizedUser() {
try {
- executorService.setPassword(th.getUnauthorizedPerformerUser(), actor, NEW_PASSWD);
+ executorService.setPassword(h.getUnauthorizedUser(), actor, NEW_PASSWD);
fail("Password was changed without permission.");
} catch (AuthorizationException e) {
- // This is what must happen
+ // Expected.
}
- assertFalse("Password was changed without permission.", th.isPasswordCorrect(actor.getName(), NEW_PASSWD));
+ assertFalse("Password was changed without permission.", h.isPasswordCorrect(actor.getName(), NEW_PASSWD));
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AASystemServiceDelegateLoginTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/SystemServiceDelegateLoginTest.java
similarity index 64%
rename from wfe-cactus-it/src/test/java/ru/runa/af/delegate/AASystemServiceDelegateLoginTest.java
rename to wfe-cactus-it/src/test/java/ru/runa/af/delegate/SystemServiceDelegateLoginTest.java
index 03c00205ca..1eb3bd51ec 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/delegate/AASystemServiceDelegateLoginTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/delegate/SystemServiceDelegateLoginTest.java
@@ -17,62 +17,58 @@
*/
package ru.runa.af.delegate;
+import com.google.common.collect.Lists;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.af.service.ServiceTestHelper;
import ru.runa.wfe.security.AuthenticationException;
import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
+import ru.runa.wfe.security.SecuredSingleton;
import ru.runa.wfe.service.SystemService;
import ru.runa.wfe.service.delegate.Delegates;
-import com.google.common.collect.Lists;
-
/**
* Created on 16.08.2004
*/
-public class AASystemServiceDelegateLoginTest extends ServletTestCase {
- private ServiceTestHelper th;
+public class SystemServiceDelegateLoginTest extends ServletTestCase {
+ private ServiceTestHelper h;
private SystemService systemService;
- private static String testPrefix = AASystemServiceDelegateLoginTest.class.getName();
@Override
- protected void tearDown() throws Exception {
- th.releaseResources();
- systemService = null;
- super.tearDown();
+ protected void setUp() {
+ systemService = Delegates.getSystemService();
+ h = new ServiceTestHelper(getClass().getName());
+
+ h.createDefaultExecutorsMap();
+ h.setPermissionsToAuthorizedActor(Lists.newArrayList(Permission.LOGIN), SecuredSingleton.SYSTEM);
}
@Override
- protected void setUp() throws Exception {
- systemService = Delegates.getSystemService();
- th = new ServiceTestHelper(testPrefix);
- th.createDefaultExecutorsMap();
- th.setPermissionsToAuthorizedPerformerOnExecutors(Lists.newArrayList(Permission.LOGIN));
- super.setUp();
+ protected void tearDown() {
+ h.releaseResources();
+ systemService = null;
}
- public void testLoginWithUnauthorizedPerformer() throws Exception {
+ public void testLoginWithUnauthorizedUser() {
try {
- systemService.login(th.getUnauthorizedPerformerUser());
+ systemService.login(h.getUnauthorizedUser());
fail("SystemServiceDelegate does not throw AuthorizationFailedException on login() with unauthorized performer user call.");
} catch (AuthorizationException e) {
- // that's what we expected
+ // Expected.
}
}
- public void testLoginWithAuthorizedPerformer() throws Exception {
- systemService.login(th.getAuthorizedPerformerUser());
+ public void testLoginWithAuthorizedUser() {
+ systemService.login(h.getAuthorizedUser());
assertTrue("SystemServiceDelegate.login() works.", true);
}
- public void testLoginWithFakeUser() throws Exception {
+ public void testLoginWithFakeUser() {
try {
- systemService.login(th.getFakeUser());
+ systemService.login(h.getFakeUser());
fail("SystemServiceDelegate does not throw AuthorizationFailedException on login() with fakeUser call.");
} catch (AuthenticationException e) {
- // that's what we expected
+ // Expected.
}
}
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/organizationfunction/impl/OrganizationFunctionFactoryTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/organizationfunction/impl/OrganizationFunctionFactoryTest.java
index 0f5e96c61e..5418ddffa4 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/organizationfunction/impl/OrganizationFunctionFactoryTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/organizationfunction/impl/OrganizationFunctionFactoryTest.java
@@ -17,31 +17,24 @@
*/
package ru.runa.af.organizationfunction.impl;
+import com.google.common.collect.Lists;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import junit.framework.Test;
import junit.framework.TestSuite;
-
import org.apache.cactus.ServletTestCase;
-
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.task.dto.WfTask;
import ru.runa.wfe.user.User;
-import com.google.common.collect.Lists;
-
/**
* @author Gordienko_m
* @author Vitaliy S aka Yilativs
*/
public class OrganizationFunctionFactoryTest extends ServletTestCase {
- private final static String PREFIX = OrganizationFunctionFactoryTest.class.getName();
-
- private WfServiceTestHelper th;
-
+ private WfServiceTestHelper h;
private Map legalVariables;
public static Test suite() {
@@ -49,74 +42,71 @@ public static Test suite() {
}
@Override
- protected void setUp() throws Exception {
-
- th = new WfServiceTestHelper(PREFIX);
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
- th.addExecutorToGroup(th.getHrOperator(), th.getBossGroup());
+ h.addExecutorToGroup(h.getHrOperator(), h.getBossGroup());
- th.deployValidProcessDefinition(WfServiceTestHelper.SWIMLANE_PROCESS_FILE_NAME);
+ h.deployValidProcessDefinition(WfServiceTestHelper.SWIMLANE_PROCESS_FILE_NAME);
- th.setPermissionsToAuthorizedPerformerOnDefinitionByName(Lists.newArrayList(Permission.START), WfServiceTestHelper.SWIMLANE_PROCESS_NAME);
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(Lists.newArrayList(Permission.START_PROCESS),
+ WfServiceTestHelper.SWIMLANE_PROCESS_NAME);
- th.getExecutionService().startProcess(th.getAuthorizedPerformerUser(), WfServiceTestHelper.SWIMLANE_PROCESS_NAME, null);
+ h.getExecutionService().startProcess(h.getAuthorizedUser(), WfServiceTestHelper.SWIMLANE_PROCESS_NAME, null);
- legalVariables = new HashMap();
+ legalVariables = new HashMap<>();
legalVariables.put("approved", "true");
-
- super.setUp();
}
- private User getBossActorUser() {
- return th.getHrOperatorUser();
+ @Override
+ protected void tearDown() {
+ h.undeployValidProcessDefinition(WfServiceTestHelper.SWIMLANE_PROCESS_NAME);
+ h.releaseResources();
+ h = null;
}
- @Override
- protected void tearDown() throws Exception {
- th.undeployValidProcessDefinition(WfServiceTestHelper.SWIMLANE_PROCESS_NAME);
- th.releaseResources();
- th = null;
- super.tearDown();
+ private User getBossActorUser() {
+ return h.getHrOperatorUser();
}
- public void testOrganizationFunction() throws Exception {
- List tasks = th.getTaskService().getMyTasks(th.getErpOperatorUser(), th.getTaskBatchPresentation());
+ public void testOrganizationFunction() {
+ List tasks = h.getTaskService().getMyTasks(h.getErpOperatorUser(), h.getTaskBatchPresentation());
assertEquals("tasks count differs from expected", 0, tasks.size());
- tasks = th.getTaskService().getMyTasks(th.getAuthorizedPerformerUser(), th.getTaskBatchPresentation());
+ tasks = h.getTaskService().getMyTasks(h.getAuthorizedUser(), h.getTaskBatchPresentation());
assertEquals("tasks count differs from expected", 0, tasks.size());
- tasks = th.getTaskService().getMyTasks(getBossActorUser(), th.getTaskBatchPresentation());
+ tasks = h.getTaskService().getMyTasks(getBossActorUser(), h.getTaskBatchPresentation());
assertEquals("tasks count differs from expected", 1, tasks.size());
assertEquals("task name differs from expected", "evaluating", tasks.get(0).getName());
- th.getTaskService().completeTask(getBossActorUser(), tasks.get(0).getId(), legalVariables, null);
+ h.getTaskService().completeTask(getBossActorUser(), tasks.get(0).getId(), legalVariables);
- tasks = th.getTaskService().getMyTasks(getBossActorUser(), th.getTaskBatchPresentation());
+ tasks = h.getTaskService().getMyTasks(getBossActorUser(), h.getTaskBatchPresentation());
assertEquals("tasks count differs from expected", 0, tasks.size());
- tasks = th.getTaskService().getMyTasks(th.getErpOperatorUser(), th.getTaskBatchPresentation());
+ tasks = h.getTaskService().getMyTasks(h.getErpOperatorUser(), h.getTaskBatchPresentation());
assertEquals("tasks count differs from expected", 1, tasks.size());
assertEquals("task name differs from expected", "updating erp asynchronously", tasks.get(0).getName());
- th.getTaskService().completeTask(th.getErpOperatorUser(), tasks.get(0).getId(), legalVariables, null);
+ h.getTaskService().completeTask(h.getErpOperatorUser(), tasks.get(0).getId(), legalVariables);
- tasks = th.getTaskService().getMyTasks(th.getAuthorizedPerformerUser(), th.getTaskBatchPresentation());
+ tasks = h.getTaskService().getMyTasks(h.getAuthorizedUser(), h.getTaskBatchPresentation());
assertEquals("tasks count differs from expected", 1, tasks.size());
assertEquals("task name differs from expected", "treating collegues on cake and pie", tasks.get(0).getName());
- th.getTaskService().completeTask(th.getAuthorizedPerformerUser(), tasks.get(0).getId(), legalVariables, null);
+ h.getTaskService().completeTask(h.getAuthorizedUser(), tasks.get(0).getId(), legalVariables);
- tasks = th.getTaskService().getMyTasks(getBossActorUser(), th.getTaskBatchPresentation());
+ tasks = h.getTaskService().getMyTasks(getBossActorUser(), h.getTaskBatchPresentation());
assertEquals("tasks count differs from expected", 0, tasks.size());
- tasks = th.getTaskService().getMyTasks(th.getErpOperatorUser(), th.getTaskBatchPresentation());
+ tasks = h.getTaskService().getMyTasks(h.getErpOperatorUser(), h.getTaskBatchPresentation());
assertEquals("tasks count differs from expected", 1, tasks.size());
assertEquals("task name differs from expected", "notify", tasks.get(0).getName());
- th.getTaskService().completeTask(th.getErpOperatorUser(), tasks.get(0).getId(), legalVariables, null);
+ h.getTaskService().completeTask(h.getErpOperatorUser(), tasks.get(0).getId(), legalVariables);
- tasks = th.getTaskService().getMyTasks(th.getAuthorizedPerformerUser(), th.getTaskBatchPresentation());
+ tasks = h.getTaskService().getMyTasks(h.getAuthorizedUser(), h.getTaskBatchPresentation());
assertEquals("tasks count differs from expected", 0, tasks.size());
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/organizationfunction/impl/OrganizationFunctionParserTest.java b/wfe-cactus-it/src/test/java/ru/runa/af/organizationfunction/impl/OrganizationFunctionParserTest.java
index 1ef60b4543..64fa52c889 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/organizationfunction/impl/OrganizationFunctionParserTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/organizationfunction/impl/OrganizationFunctionParserTest.java
@@ -21,60 +21,42 @@
*/
package ru.runa.af.organizationfunction.impl;
-import java.util.HashMap;
+import com.google.common.collect.Lists;
import java.util.List;
-import java.util.Map;
-
import org.apache.cactus.ServletTestCase;
-
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.task.dto.WfTask;
-import com.google.common.collect.Lists;
-
/**
* @author Gritsenko_S
*/
public class OrganizationFunctionParserTest extends ServletTestCase {
- private final static String PREFIX = OrganizationFunctionParserTest.class.getName();
-
- private WfServiceTestHelper th;
-
private static final String PROCESS_PATH = "organizationProcess.par";
private static final String PROCESS_NAME = "organizationProcess";
- private Map legalVariables;
+ private WfServiceTestHelper h;
@Override
- protected void setUp() throws Exception {
-
- th = new WfServiceTestHelper(PREFIX);
-
- th.addExecutorToGroup(th.getHrOperator(), th.getBossGroup());
-
- th.deployValidProcessDefinition(PROCESS_PATH);
-
- th.setPermissionsToAuthorizedPerformerOnDefinitionByName(Lists.newArrayList(Permission.START), PROCESS_NAME);
-
- legalVariables = new HashMap();
- legalVariables.put("approved", "true");
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
- super.setUp();
+ h.addExecutorToGroup(h.getHrOperator(), h.getBossGroup());
+ h.deployValidProcessDefinition(PROCESS_PATH);
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(Lists.newArrayList(Permission.START_PROCESS), PROCESS_NAME);
}
@Override
- protected void tearDown() throws Exception {
- th.undeployValidProcessDefinition(PROCESS_NAME);
- th.releaseResources();
- th = null;
- super.tearDown();
+ protected void tearDown() {
+ h.undeployValidProcessDefinition(PROCESS_NAME);
+ h.releaseResources();
+ h = null;
}
- public void testOrganizationFunction() throws Exception {
- th.getExecutionService().startProcess(th.getAuthorizedPerformerUser(), PROCESS_NAME, null);
+ public void testOrganizationFunction() {
+ h.getExecutionService().startProcess(h.getAuthorizedUser(), PROCESS_NAME, null);
- List tasks = th.getTaskService().getMyTasks(th.getAdminUser(), th.getTaskBatchPresentation());
+ List tasks = h.getTaskService().getMyTasks(h.getAdminUser(), h.getTaskBatchPresentation());
assertEquals("tasks count differs from expected", 0, tasks.size());
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/af/service/ServiceTestHelper.java b/wfe-cactus-it/src/test/java/ru/runa/af/service/ServiceTestHelper.java
index 10063930e6..3333ff09c0 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/af/service/ServiceTestHelper.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/af/service/ServiceTestHelper.java
@@ -17,28 +17,24 @@
*/
package ru.runa.af.service;
-import java.io.Serializable;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import javax.security.auth.Subject;
-
+import lombok.Getter;
+import lombok.val;
import ru.runa.wfe.InternalApplicationException;
import ru.runa.wfe.presentation.BatchPresentation;
import ru.runa.wfe.presentation.BatchPresentationFactory;
import ru.runa.wfe.relation.Relation;
-import ru.runa.wfe.relation.RelationAlreadyExistException;
-import ru.runa.wfe.relation.RelationDoesNotExistException;
import ru.runa.wfe.relation.RelationPair;
-import ru.runa.wfe.security.SecuredSingleton;
-import ru.runa.wfe.security.AuthenticationException;
-import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.security.SecuredObject;
-import ru.runa.wfe.security.WeakPasswordException;
import ru.runa.wfe.service.AuthenticationService;
import ru.runa.wfe.service.AuthorizationService;
import ru.runa.wfe.service.ExecutorService;
@@ -49,19 +45,13 @@
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.ss.Substitution;
import ru.runa.wfe.ss.SubstitutionCriteria;
-import ru.runa.wfe.ss.SubstitutionDoesNotExistException;
import ru.runa.wfe.ss.TerminatorSubstitution;
import ru.runa.wfe.user.Actor;
import ru.runa.wfe.user.Executor;
-import ru.runa.wfe.user.ExecutorAlreadyExistsException;
import ru.runa.wfe.user.ExecutorDoesNotExistException;
import ru.runa.wfe.user.Group;
import ru.runa.wfe.user.User;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
public class ServiceTestHelper {
private final static String ADMINISTRATOR_NAME = "Administrator";
@@ -72,83 +62,83 @@ public class ServiceTestHelper {
private final Set createdExecutorsSet = Sets.newHashSet();
+ @Getter
private final Map defaultExecutorsMap = Maps.newHashMap();
public final static String AUTHORIZED_PERFORMER_NAME = "AUTHORIZED_PERFORMER_NAME";
-
public final static String AUTHORIZED_PERFORMER_DESCRIPTION = "AUTHORIZED_PERFORMER_DESCRIPTION";
-
public final static String AUTHORIZED_PERFORMER_PASSWORD = "AUTHORIZED_PERFORMER_PASSWORD";
public final static String UNAUTHORIZED_PERFORMER_NAME = "UNAUTHORIZED_PERFORMER_NAME";
-
public final static String UNAUTHORIZED_PERFORMER_DESCRIPTION = "UNAUTHORIZED_PERFORMER_DESCRIPTION";
-
public final static String UNAUTHORIZED_PERFORMER_PASSWORD = "UNAUTHORIZED_PERFORMER_PASSWORD";
public final static String BASE_GROUP_NAME = "BASE_GROUP_NAME";
-
public final static String BASE_GROUP_DESC = "BASE_GROUP_DESC";
-
public final static String BASE_GROUP_ACTOR_NAME = "BASE_GROUP_ACTOR_NAME";
-
public final static String BASE_GROUP_ACTOR_DESC = "BASE_GROUP_ACTOR_DESC";
-
public final static String SUB_GROUP_NAME = "SUB_GROUP_NAME";
-
public final static String SUB_GROUP_DESC = "SUB_GROUP_DESC";
-
public final static String SUB_GROUP_ACTOR_NAME = "SUB_GROUP_ACTOR_NAME";
-
public final static String SUB_GROUP_ACTOR_DESC = "SUB_GROUP_ACTOR_DESC";
-
public final static String FAKE_ACTOR_NAME = "FAKE_ACTOR_NAME";
-
public final static String FAKE_ACTOR_DESC = "FAKE_ACTOR_DESC";
-
public final static String FAKE_GROUP_NAME = "FAKE_GROUP_NAME";
-
public final static String FAKE_GROUP_DESC = "FAKE_GROUP_DESC";
+ @Getter
private ExecutorService executorService;
private RelationService relationService;
private SubstitutionService substitutionService;
+ @Getter
protected AuthorizationService authorizationService;
+ @Getter
private AuthenticationService authenticationService;
+ @Getter
private SystemService systemService;
+ @Getter
private ProfileService profileService;
+ @Getter
private Actor fakeActor;
+ @Getter
private List fakeExecutors;
private Actor baseGroupActor;
private Actor subGroupActor;
+ @Getter
private Group fakeGroup;
private Group baseGroup;
private Group subGroup;
+ @Getter
private User fakeUser;
- private User authorizedPerformerUser, unauthorizedPerformerUser;
+ @Getter
+ private User authorizedUser;
+
+ @Getter
+ private User unauthorizedUser;
private final String testClassName;
+ @Getter
protected User adminUser;
private Set subjectOfActorsWithProfileSet = Sets.newHashSet();
- public ServiceTestHelper(String testClassName) throws InternalApplicationException {
+ public ServiceTestHelper(String testClassName) {
this.testClassName = testClassName;
createExecutorServiceDelegate();
createRelationServiceDelegate();
@@ -163,8 +153,14 @@ public ServiceTestHelper(String testClassName) throws InternalApplicationExcepti
createProfileServiceDelegate();
}
- public List toIds(Collection extends SecuredObject> list) {
- List ids = Lists.newArrayList();
+// @SafeVarargs
+// public final ArrayList list(T... oo) {
+// return Lists.newArrayList(oo);
+// }
+
+ public ArrayList toIds(Collection extends SecuredObject> list) {
+ // TODO Use java8 map.
+ val ids = new ArrayList(list.size());
for (SecuredObject securedObject : list) {
ids.add(securedObject.getIdentifiableId());
}
@@ -175,18 +171,10 @@ private void createProfileServiceDelegate() {
profileService = Delegates.getProfileService();
}
- public ProfileService getProfileService() {
- return profileService;
- }
-
- public User getAdminUser() {
- return adminUser;
- }
-
/**
* Creates groups and actors group contains subGroup and subActor subGroup contains subGroupActor
*/
- public void createDefaultExecutorsMap() throws InternalApplicationException {
+ public void createDefaultExecutorsMap() {
baseGroup = executorService.create(adminUser, new Group(testClassName + BASE_GROUP_NAME, testClassName + BASE_GROUP_DESC));
defaultExecutorsMap.put(BASE_GROUP_NAME, baseGroup);
@@ -205,34 +193,28 @@ public void createDefaultExecutorsMap() throws InternalApplicationException {
executorService.addExecutorsToGroup(adminUser, Lists.newArrayList(subGroupActor.getId()), subGroup.getId());
}
- public void releaseResources() throws InternalApplicationException {
+ public void releaseResources() {
removeCreatedProfiles();
removeCreatedExecutors();
removeDefaultExecutors();
executorService = null;
- executorService = null;
- authorizationService = null;
authorizationService = null;
authenticationService = null;
- authenticationService = null;
- systemService = null;
systemService = null;
fakeActor = null;
fakeGroup = null;
-
fakeExecutors.clear();
fakeExecutors = null;
+ fakeUser = null;
baseGroup = null;
baseGroupActor = null;
subGroup = null;
subGroupActor = null;
- fakeUser = null;
-
}
- private void removeCreatedProfiles() throws AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
+ private void removeCreatedProfiles() {
subjectOfActorsWithProfileSet.clear();
subjectOfActorsWithProfileSet = null;
profileService = null;
@@ -245,7 +227,7 @@ public void removeCreatedExecutor(Executor executor) {
createdExecutorsSet.remove(executor);
}
- public void removeExecutorIfExists(Executor executor) throws InternalApplicationException {
+ public void removeExecutorIfExists(Executor executor) {
if (executor != null) {
try {
if (executor instanceof Actor) {
@@ -260,15 +242,15 @@ public void removeExecutorIfExists(Executor executor) throws InternalApplication
}
}
- public void addExecutorToGroup(Executor executor, Group group) throws InternalApplicationException {
+ public void addExecutorToGroup(Executor executor, Group group) {
executorService.addExecutorsToGroup(adminUser, Lists.newArrayList(executor.getId()), group.getId());
}
- public void removeExecutorFromGroup(Executor executor, Group group) throws InternalApplicationException {
+ public void removeExecutorFromGroup(Executor executor, Group group) {
executorService.removeExecutorsFromGroup(adminUser, Lists.newArrayList(executor.getId()), group.getId());
}
- public boolean isExecutorExist(Executor executor) throws InternalApplicationException {
+ public boolean isExecutorExist(Executor executor) {
boolean isExecutorExist = true;
try {
if (executor instanceof Actor) {
@@ -293,23 +275,17 @@ public boolean isPasswordCorrect(String name, String password) {
return isPasswordCorrect;
}
- public void setPermissionsToAuthorizedPerformer(Collection permissions, Executor executor) throws InternalApplicationException {
- authorizationService.setPermissions(adminUser, getAuthorizedPerformerActor().getId(), permissions, executor);
+ public void setPermissionsToAuthorizedActor(Collection permissions, SecuredObject object) {
+ authorizationService.setPermissions(adminUser, getAuthorizedActor().getId(), permissions, object);
}
- public void setPermissionsToAuthorizedPerformerOnExecutorsList(Collection permissions, List extends Executor> executors)
- throws InternalApplicationException {
- for (Executor executor : executors) {
- authorizationService.setPermissions(adminUser, getAuthorizedPerformerActor().getId(), permissions, executor);
+ public void setPermissionsToAuthorizedActor(Collection permissions, List extends SecuredObject> objects) {
+ for (SecuredObject o : objects) {
+ setPermissionsToAuthorizedActor(permissions, o);
}
}
- public void setPermissionsToAuthorizedPerformerOnExecutors(Collection permissions) {
- authorizationService.setPermissions(adminUser, getAuthorizedPerformerActor().getId(), permissions, SecuredSingleton.EXECUTORS);
- }
-
- public Actor createActorIfNotExist(String name, String description)
- throws ExecutorAlreadyExistsException, AuthorizationException, AuthenticationException {
+ public Actor createActorIfNotExist(String name, String description) {
Actor actor;
try {
actor = executorService.getExecutorByName(adminUser, name);
@@ -320,8 +296,7 @@ public Actor createActorIfNotExist(String name, String description)
return actor;
}
- public List createActorArray(String name, String description)
- throws ExecutorAlreadyExistsException, AuthorizationException, AuthenticationException {
+ public List createActorArray(String name, String description) {
Actor[] actorArray = new Actor[5];
actorArray[0] = executorService.create(adminUser, new Actor(name + "0", description + "0"));
actorArray[1] = executorService.create(adminUser, new Actor(name + "1", description + "1"));
@@ -336,8 +311,7 @@ public List createActorArray(String name, String description)
return Lists.newArrayList(actorArray);
}
- public Group createGroupIfNotExist(String name, String description)
- throws ExecutorAlreadyExistsException, AuthorizationException, AuthenticationException {
+ public Group createGroupIfNotExist(String name, String description) {
Group group;
try {
group = executorService.getExecutorByName(adminUser, name);
@@ -348,7 +322,7 @@ public Group createGroupIfNotExist(String name, String description)
return group;
}
- public List createGroupArray(String name, String description) throws InternalApplicationException {
+ public ArrayList createGroupArray(String name, String description) {
Group[] groupArray = new Group[5];
groupArray[0] = executorService.create(adminUser, new Group(name + "0", description + "0"));
groupArray[1] = executorService.create(adminUser, new Group(name + "1", description + "1"));
@@ -363,7 +337,7 @@ public List createGroupArray(String name, String description) throws Inte
return Lists.newArrayList(groupArray);
}
- public List createMixedActorsGroupsArray(String name, String description) throws InternalApplicationException {
+ public ArrayList createMixedActorsGroupsArray(String name, String description) {
Executor[] mixedArray = new Executor[5];
mixedArray[0] = executorService.create(adminUser, new Actor(name + "0", description + "0"));
mixedArray[1] = executorService.create(adminUser, new Group(name + "1", description + "1"));
@@ -378,39 +352,11 @@ public List createMixedActorsGroupsArray(String name, String descripti
return Lists.newArrayList(mixedArray);
}
- public User getAuthorizedPerformerUser() {
- return authorizedPerformerUser;
- }
-
- public ExecutorService getExecutorService() {
- return executorService;
- }
-
- public User getUnauthorizedPerformerUser() {
- return unauthorizedPerformerUser;
- }
-
- public Map getDefaultExecutorsMap() {
- return defaultExecutorsMap;
- }
-
- public Actor getFakeActor() {
- return fakeActor;
- }
-
- public Group getFakeGroup() {
- return fakeGroup;
- }
-
- public List getFakeExecutors() {
- return fakeExecutors;
- }
-
- public boolean isExecutorInGroup(Executor executor, Group group) throws InternalApplicationException {
+ public boolean isExecutorInGroup(Executor executor, Group group) {
return executorService.isExecutorInGroup(adminUser, executor, group);
}
- public boolean isExecutorInGroups(Executor executor, List groups) throws InternalApplicationException {
+ public boolean isExecutorInGroups(Executor executor, List groups) {
for (Group group : groups) {
if (!executorService.isExecutorInGroup(adminUser, executor, group)) {
return false;
@@ -419,7 +365,7 @@ public boolean isExecutorInGroups(Executor executor, List groups) throws
return true;
}
- public boolean isExecutorsInGroup(List extends Executor> executors, Group group) throws InternalApplicationException {
+ public boolean isExecutorsInGroup(List extends Executor> executors, Group group) {
for (Executor executor : executors) {
if (!executorService.isExecutorInGroup(adminUser, executor, group)) {
return false;
@@ -452,36 +398,35 @@ private void createSystemServiceDelegate() {
systemService = Delegates.getSystemService();
}
- private void createPerformersAndPerformesSubjects() throws ExecutorDoesNotExistException, ExecutorAlreadyExistsException, AuthorizationException,
- AuthenticationException, WeakPasswordException {
+ private void createPerformersAndPerformesSubjects() {
String authorizedActorName = testClassName + AUTHORIZED_PERFORMER_NAME;
- Actor authorizedPerformerActor;
+ Actor authorizedActor;
try {
- authorizedPerformerActor = executorService.getExecutorByName(adminUser, authorizedActorName);
+ authorizedActor = executorService.getExecutorByName(adminUser, authorizedActorName);
} catch (ExecutorDoesNotExistException e) {
- authorizedPerformerActor = executorService.create(adminUser, new Actor(authorizedActorName, AUTHORIZED_PERFORMER_DESCRIPTION));
- executorService.setPassword(adminUser, authorizedPerformerActor, AUTHORIZED_PERFORMER_PASSWORD);
+ authorizedActor = executorService.create(adminUser, new Actor(authorizedActorName, AUTHORIZED_PERFORMER_DESCRIPTION));
+ executorService.setPassword(adminUser, authorizedActor, AUTHORIZED_PERFORMER_PASSWORD);
}
String unauthorizedActorName = testClassName + UNAUTHORIZED_PERFORMER_NAME;
- Actor unauthorizedPerformerActor;
+ Actor unauthorizedActor;
try {
- unauthorizedPerformerActor = executorService.getExecutorByName(adminUser, unauthorizedActorName);
+ unauthorizedActor = executorService.getExecutorByName(adminUser, unauthorizedActorName);
} catch (ExecutorDoesNotExistException e) {
- unauthorizedPerformerActor = executorService.create(adminUser, new Actor(unauthorizedActorName, UNAUTHORIZED_PERFORMER_DESCRIPTION));
- executorService.setPassword(adminUser, unauthorizedPerformerActor, UNAUTHORIZED_PERFORMER_PASSWORD);
+ unauthorizedActor = executorService.create(adminUser, new Actor(unauthorizedActorName, UNAUTHORIZED_PERFORMER_DESCRIPTION));
+ executorService.setPassword(adminUser, unauthorizedActor, UNAUTHORIZED_PERFORMER_PASSWORD);
}
- authorizedPerformerUser = authenticationService.authenticateByLoginPassword(authorizedPerformerActor.getName(),
+ authorizedUser = authenticationService.authenticateByLoginPassword(authorizedActor.getName(),
AUTHORIZED_PERFORMER_PASSWORD);
- unauthorizedPerformerUser = authenticationService.authenticateByLoginPassword(unauthorizedPerformerActor.getName(),
+ unauthorizedUser = authenticationService.authenticateByLoginPassword(unauthorizedActor.getName(),
UNAUTHORIZED_PERFORMER_PASSWORD);
}
- private void createAdminSubject() throws InternalApplicationException {
+ private void createAdminSubject() {
adminUser = authenticationService.authenticateByLoginPassword(ADMINISTRATOR_NAME, ADMINISTRATOR_PASSWORD);
}
/** Removes all created executors from DB. */
- private void removeCreatedExecutors() throws InternalApplicationException {
+ private void removeCreatedExecutors() {
try {
for (Executor executor : createdExecutorsSet) {
executor = executorService.getExecutor(adminUser, executor.getId());
@@ -489,15 +434,15 @@ private void removeCreatedExecutors() throws InternalApplicationException {
}
} catch (ExecutorDoesNotExistException ignored) {
}
- executorService.remove(adminUser, Lists.newArrayList(getAuthorizedPerformerActor().getId(), getUnauthorizedPerformerActor().getId()));
+ executorService.remove(adminUser, Lists.newArrayList(getAuthorizedActor().getId(), getUnauthorizedActor().getId()));
}
- public Collection getOwnPermissions(Executor performer, Executor executor) throws InternalApplicationException {
+ public Collection getOwnPermissions(Executor performer, Executor executor) {
return authorizationService.getIssuedPermissions(adminUser, performer, executor);
}
/** check if default executors still exists in db, and id so removes them */
- private void removeDefaultExecutors() throws InternalApplicationException {
+ private void removeDefaultExecutors() {
List undeletedExecutorsList = Lists.newArrayList();
for (Executor executor : defaultExecutorsMap.values()) {
boolean canRemove = false;
@@ -528,35 +473,19 @@ private void createFakeUser() {
fakeUser = new User(fakeActor, null);
}
- public AuthorizationService getAuthorizationService() {
- return authorizationService;
- }
-
- public AuthenticationService getAuthenticationService() {
- return authenticationService;
- }
-
- public SystemService getSystemService() {
- return systemService;
- }
-
- public User getFakeUser() {
- return fakeUser;
- }
-
- public Actor getAuthorizedPerformerActor() throws InternalApplicationException {
- return authorizedPerformerUser.getActor();
+ public Actor getAuthorizedActor() {
+ return authorizedUser.getActor();
}
- public Actor getUnauthorizedPerformerActor() throws InternalApplicationException {
- return unauthorizedPerformerUser.getActor();
+ public Actor getUnauthorizedActor() {
+ return unauthorizedUser.getActor();
}
- public Group getAdministratorsGroup() throws InternalApplicationException {
+ public Group getAdministratorsGroup() {
return executorService.getExecutorByName(adminUser, ADMINISTRATORS_NAME);
}
- public Actor getAdministrator() throws InternalApplicationException {
+ public Actor getAdministrator() {
return executorService.getExecutorByName(adminUser, ADMINISTRATOR_NAME);
}
@@ -564,37 +493,37 @@ public String getAdministratorPassword() {
return ADMINISTRATOR_PASSWORD;
}
- public Group getBaseGroup() throws InternalApplicationException {
+ public Group getBaseGroup() {
return executorService.getExecutorByName(adminUser, baseGroup.getName());
// return baseGroup; we can't cache executor that changes it's state in
// db
}
- public Actor getBaseGroupActor() throws InternalApplicationException {
+ public Actor getBaseGroupActor() {
return executorService.getExecutorByName(adminUser, baseGroupActor.getName());
// return baseGroupActor;
}
- public Group getSubGroup() throws InternalApplicationException {
+ public Group getSubGroup() {
return executorService.getExecutorByName(adminUser, subGroup.getName());
// return subGroup;
}
- public Actor getSubGroupActor() throws InternalApplicationException {
+ public Actor getSubGroupActor() {
return executorService.getExecutorByName(adminUser, subGroupActor.getName());
// return subGroupActor;
}
- public Executor getExecutor(String name) throws InternalApplicationException {
+ public Executor getExecutor(String name) {
return executorService.getExecutorByName(adminUser, name);
}
- public void setActorStatus(Actor actor, boolean isActive) throws AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
+ public void setActorStatus(Actor actor, boolean isActive) {
executorService.setStatus(getAdminUser(), actor, isActive);
}
/*
- * TODO: remove public Profile getDefaultProfile(Subject subject) throws InternalApplicationException, AuthenticationException { Profile profile =
+ * TODO: remove public Profile getDefaultProfile(Subject subject) { Profile profile =
* profileService.getProfile(subject); subjectOfActorsWithProfileSet.add(subject); return profile; }
*
* public Identifiable getFakeIdentifiable() { return new Identifiable() {
@@ -604,8 +533,7 @@ public void setActorStatus(Actor actor, boolean isActive) throws AuthorizationEx
* @Override public SecuredObjectType getSecuredObjectType() { return SecuredObjectType.DEFINITION; } }; }
*/
- public Substitution createTerminator(User user, SubstitutionCriteria substitutionCriteria, boolean isEnabled)
- throws AuthorizationException, ExecutorDoesNotExistException, AuthenticationException {
+ public Substitution createTerminator(User user, SubstitutionCriteria substitutionCriteria, boolean isEnabled) {
TerminatorSubstitution terminatorSubstitution = new TerminatorSubstitution();
terminatorSubstitution.setOrgFunction("");
terminatorSubstitution.setActorId(user.getActor().getId());
@@ -614,8 +542,7 @@ public Substitution createTerminator(User user, SubstitutionCriteria substitutio
return substitutionService.createSubstitution(getAdminUser(), terminatorSubstitution);
}
- public Substitution createActorSubstitutor(User user, String orgFunction, SubstitutionCriteria substitutionCriteria, boolean isEnabled)
- throws AuthorizationException, ExecutorDoesNotExistException, AuthenticationException {
+ public Substitution createActorSubstitutor(User user, String orgFunction, SubstitutionCriteria substitutionCriteria, boolean isEnabled) {
Substitution substitution = new Substitution();
substitution.setActorId(user.getActor().getId());
substitution.setOrgFunction(orgFunction);
@@ -632,22 +559,19 @@ public BatchPresentation getExecutorBatchPresentation(String presentationId) {
return BatchPresentationFactory.EXECUTORS.createDefault(presentationId);
}
- public Relation createRelation(String name, String description)
- throws RelationAlreadyExistException, AuthorizationException, AuthenticationException {
+ public Relation createRelation(String name, String description) {
return relationService.createRelation(adminUser, new Relation(name, description));
}
- public RelationPair addRelationPair(Long relationId, Executor left, Executor right)
- throws RelationDoesNotExistException, AuthorizationException, AuthenticationException {
+ public RelationPair addRelationPair(Long relationId, Executor left, Executor right) {
return relationService.addRelationPair(adminUser, relationId, left, right);
}
- public void removeRelation(Long relationId) throws RelationDoesNotExistException, AuthorizationException, AuthenticationException {
+ public void removeRelation(Long relationId) {
relationService.removeRelation(adminUser, relationId);
}
- public T createSubstitutionCriteria(T substitutionCriteria)
- throws AuthorizationException, ExecutorDoesNotExistException, AuthenticationException {
+ public T createSubstitutionCriteria(T substitutionCriteria) {
if (substitutionCriteria == null) {
return null;
}
@@ -655,16 +579,14 @@ public T createSubstitutionCriteria(T substitut
return (T) substitutionService.getCriteriaByName(getAdminUser(), substitutionCriteria.getName());
}
- public void removeSubstitutionCriteria(SubstitutionCriteria substitutionCriteria)
- throws AuthorizationException, AuthenticationException, ExecutorDoesNotExistException {
+ public void removeSubstitutionCriteria(SubstitutionCriteria substitutionCriteria) {
if (substitutionCriteria == null) {
return;
}
substitutionService.deleteCriteria(getAdminUser(), substitutionCriteria);
}
- public void removeCriteriaFromSubstitution(Substitution substitution)
- throws AuthorizationException, AuthenticationException, ExecutorDoesNotExistException, SubstitutionDoesNotExistException {
+ public void removeCriteriaFromSubstitution(Substitution substitution) {
substitution.setCriteria(null);
substitutionService.updateSubstitution(getAdminUser(), substitution);
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateDeployProcessDefinitionTest.java b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateDeployProcessDefinitionTest.java
index 1e7d1b5df2..a9c3e68540 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateDeployProcessDefinitionTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateDeployProcessDefinitionTest.java
@@ -18,53 +18,43 @@
package ru.runa.wf.delegate;
import com.google.common.collect.Lists;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import org.apache.cactus.ServletTestCase;
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.definition.DefinitionArchiveFormatException;
import ru.runa.wfe.security.Permission;
+import ru.runa.wfe.security.SecuredSingleton;
import ru.runa.wfe.service.DefinitionService;
import ru.runa.wfe.service.delegate.Delegates;
-import java.util.Collection;
-
/**
* Created on 20.04.2005
*
* @author Gritsenko_S
*/
public class DefinitionServiceDelegateDeployProcessDefinitionTest extends ServletTestCase {
-
- private DefinitionService definitionService = null;
-
- private WfServiceTestHelper helper = null;
+ private WfServiceTestHelper h;
+ private DefinitionService definitionService;
@Override
- protected void setUp() throws Exception {
- helper = new WfServiceTestHelper(getClass().getName());
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
definitionService = Delegates.getDefinitionService();
- Collection deployPermissions = Lists.newArrayList(Permission.CREATE);
- helper.setPermissionsToAuthorizedPerformerOnDefinitions(deployPermissions);
-
- super.setUp();
+ h.setPermissionsToAuthorizedActor(Lists.newArrayList(Permission.CREATE_DEFINITION), SecuredSingleton.SYSTEM);
}
@Override
- protected void tearDown() throws Exception {
- helper.releaseResources();
+ protected void tearDown() {
+ h.releaseResources();
definitionService = null;
- super.tearDown();
}
- public void testDeployInvalidProcessByAuthorizedPerformer() throws Exception {
+ public void testDeployInvalidProcessByAuthorizedUser() {
try {
- definitionService.deployProcessDefinition(helper.getAuthorizedPerformerUser(), helper.getInValidProcessDefinition(),
- Lists.newArrayList("testProcess"));
- assertTrue("definitionDelegate.deployProcessByAuthorizedPerformer() no DefinitionArchiveFormatException", false);
+ definitionService.deployProcessDefinition(h.getAuthorizedUser(), h.getInValidProcessDefinition(), Lists.newArrayList("testProcess"));
+ fail();
} catch (DefinitionArchiveFormatException e) {
- // That's what we expect
+ // Expected.
}
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetDeclaredVariablesNamesTest.java b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetDeclaredVariablesNamesTest.java
index a18b8a3407..689d4dbd5e 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetDeclaredVariablesNamesTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetDeclaredVariablesNamesTest.java
@@ -1,67 +1,58 @@
package ru.runa.wf.delegate;
-import java.util.Collection;
+import com.google.common.collect.Lists;
import java.util.List;
-
import org.apache.cactus.ServletTestCase;
-
import ru.runa.junit.ArrayAssert;
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.definition.DefinitionDoesNotExistException;
import ru.runa.wfe.security.Permission;
+import ru.runa.wfe.security.SecuredSingleton;
import ru.runa.wfe.service.DefinitionService;
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.User;
import ru.runa.wfe.var.VariableDefinition;
-import com.google.common.collect.Lists;
-
/**
* @author Pashkov Alexander
*/
public class DefinitionServiceDelegateGetDeclaredVariablesNamesTest extends ServletTestCase {
-
private static final String DEFINITION_WITH_VARIABLES_XML = "processWithVariablesXml";
- private DefinitionService definitionService = null;
-
- private WfServiceTestHelper helper = null;
+ private WfServiceTestHelper h;
+ private DefinitionService definitionService;
private long definitionWithVariablesXmlId;
@Override
- protected void setUp() throws Exception {
- helper = new WfServiceTestHelper(getClass().getName());
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
definitionService = Delegates.getDefinitionService();
- Collection deployPermissions = Lists.newArrayList(Permission.CREATE);
- helper.setPermissionsToAuthorizedPerformerOnDefinitions(deployPermissions);
- definitionService.deployProcessDefinition(helper.getAuthorizedPerformerUser(),
+ h.setPermissionsToAuthorizedActor(Lists.newArrayList(Permission.CREATE_DEFINITION), SecuredSingleton.SYSTEM);
+
+ definitionService.deployProcessDefinition(h.getAuthorizedUser(),
WfServiceTestHelper.readBytesFromFile(DEFINITION_WITH_VARIABLES_XML + ".par"), Lists.newArrayList("testProcess"));
- Collection permissions = Lists.newArrayList(Permission.READ);
- helper.setPermissionsToAuthorizedPerformerOnDefinitionByName(permissions, DEFINITION_WITH_VARIABLES_XML);
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(Lists.newArrayList(Permission.READ), DEFINITION_WITH_VARIABLES_XML);
definitionWithVariablesXmlId = definitionService
- .getLatestProcessDefinition(helper.getAuthorizedPerformerUser(), DEFINITION_WITH_VARIABLES_XML).getId();
-
- super.setUp();
+ .getLatestProcessDefinition(h.getAuthorizedUser(), DEFINITION_WITH_VARIABLES_XML).getId();
}
@Override
- protected void tearDown() throws Exception {
- helper.undeployValidProcessDefinition(DEFINITION_WITH_VARIABLES_XML);
- helper.releaseResources();
+ protected void tearDown() {
+ h.undeployValidProcessDefinition(DEFINITION_WITH_VARIABLES_XML);
+ h.releaseResources();
definitionService = null;
- super.tearDown();
}
- public void testGetDeclaredVariablesNamesByAuthorizedSubject() {
- testImpl(helper.getAuthorizedPerformerUser(), definitionWithVariablesXmlId, Lists.newArrayList("var1", "Var2", "var3"), null);
+ public void testGetDeclaredVariablesNamesByAuthorizedUser() {
+ testImpl(h.getAuthorizedUser(), definitionWithVariablesXmlId, Lists.newArrayList("var1", "Var2", "var3"), null);
}
public void testGetDeclaredVariablesNamesOnInvalidDefinitionId() {
- testImpl(helper.getAuthorizedPerformerUser(), -1, null, DefinitionDoesNotExistException.class);
+ testImpl(h.getAuthorizedUser(), -1, null, DefinitionDoesNotExistException.class);
}
private void testImpl(User user, long definitionId, List expected, Class extends Exception> exception) {
diff --git a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetFileTest.java b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetFileTest.java
index b7b0c7f725..295ca63a5d 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetFileTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetFileTest.java
@@ -17,10 +17,8 @@
*/
package ru.runa.wf.delegate;
-import java.util.Collection;
-
+import com.google.common.collect.Lists;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.definition.DefinitionDoesNotExistException;
import ru.runa.wfe.definition.DefinitionFileDoesNotExistException;
@@ -29,82 +27,71 @@
import ru.runa.wfe.service.DefinitionService;
import ru.runa.wfe.service.delegate.Delegates;
-import com.google.common.collect.Lists;
-
/**
* Powered by Dofs
*/
public class DefinitionServiceDelegateGetFileTest extends ServletTestCase {
+ private static final String VALID_FILE_NAME = "description.txt";
+ private static final String INVALID_FILE_NAME = "processdefinitioninvalid.xml";
+ private WfServiceTestHelper h = null;
private DefinitionService definitionService = null;
- private WfServiceTestHelper helper = null;
-
private long definitionId;
- private final String VALID_FILE_NAME = "description.txt";
-
- private final String INVALID_FILE_NAME = "processdefinitioninvalid.xml";
-
@Override
- protected void setUp() throws Exception {
- helper = new WfServiceTestHelper(getClass().getName());
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
definitionService = Delegates.getDefinitionService();
- helper.deployValidProcessDefinition();
-
- Collection permissions = Lists.newArrayList(Permission.READ);
- helper.setPermissionsToAuthorizedPerformerOnDefinitionByName(permissions, WfServiceTestHelper.VALID_PROCESS_NAME);
-
- definitionId = definitionService.getLatestProcessDefinition(helper.getAuthorizedPerformerUser(), WfServiceTestHelper.VALID_PROCESS_NAME)
- .getId();
-
- super.setUp();
+ h.deployValidProcessDefinition();
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(Lists.newArrayList(Permission.READ), WfServiceTestHelper.VALID_PROCESS_NAME);
+ definitionId = definitionService.getLatestProcessDefinition(h.getAuthorizedUser(), WfServiceTestHelper.VALID_PROCESS_NAME).getId();
}
@Override
- protected void tearDown() throws Exception {
- helper.undeployValidProcessDefinition();
- helper.releaseResources();
+ protected void tearDown() {
+ h.undeployValidProcessDefinition();
+ h.releaseResources();
definitionService = null;
- super.tearDown();
}
- public void testGetFileTestByAuthorizedSubject() throws Exception {
- byte[] fileBytes = definitionService.getProcessDefinitionFile(helper.getAuthorizedPerformerUser(), definitionId, VALID_FILE_NAME);
+ public void testGetFileTestByAuthorizedUser() {
+ byte[] fileBytes = definitionService.getProcessDefinitionFile(h.getAuthorizedUser(), definitionId, VALID_FILE_NAME);
assertNotNull("file bytes is null", fileBytes);
}
/*
- * We allowing that now public void testGetFileTestByUnauthorizedSubject() throws Exception { try {
- * definitionDelegate.getFile(helper.getUnauthorizedPerformerUser(), definitionId, VALID_FILE_NAME);
- * assertTrue("testGetFileTestByUnauthorizedSubject , no AuthorizationException" , false); } catch (AuthorizationException e) { } }
+ * We allowing that now public void testGetFileTestByUnauthorizedUser() { try {
+ * definitionDelegate.getFile(h.getUnauthorizedUser(), definitionId, VALID_FILE_NAME);
+ * fail(); } catch (AuthorizationException e) { } }
*/
- public void testGetFileTestByFakeSubject() throws Exception {
+ public void testGetFileTestByFakeUser() {
try {
- definitionService.getProcessDefinitionFile(helper.getFakeUser(), definitionId, VALID_FILE_NAME);
- assertTrue("testGetFileTestByFakeSubject , no AuthenticationException", false);
+ definitionService.getProcessDefinitionFile(h.getFakeUser(), definitionId, VALID_FILE_NAME);
+ fail();
} catch (AuthenticationException e) {
+ // Expected.
}
}
- public void testGetFileTestByAuthorizedSubjectWithInvalidDefinitionId() throws Exception {
+ public void testGetFileTestByAuthorizedUserWithInvalidDefinitionId() {
try {
- definitionService.getProcessDefinitionFile(helper.getAuthorizedPerformerUser(), -1L, VALID_FILE_NAME);
- fail("testGetFileTestByAuthorizedSubjectWithInvalidDefinitionId, no DefinitionDoesNotExistException");
+ definitionService.getProcessDefinitionFile(h.getAuthorizedUser(), -1L, VALID_FILE_NAME);
+ fail();
} catch (DefinitionDoesNotExistException e) {
- // expected
+ // Expected.
}
}
- public void testGetFileTestByAuthorizedSubjectWithInvalidFileName() throws Exception {
+ public void testGetFileTestByAuthorizedUserWithInvalidFileName() {
try {
- definitionService.getProcessDefinitionFile(helper.getAuthorizedPerformerUser(), definitionId, INVALID_FILE_NAME);
+ definitionService.getProcessDefinitionFile(h.getAuthorizedUser(), definitionId, INVALID_FILE_NAME);
// TODO
- // fail("testGetFileTestByAuthorizedSubjectWithInvalidFileName, no ProcessDefinitionFileNotFoundException");
+ // fail();
} catch (DefinitionFileDoesNotExistException e) {
- // expected
+ // Expected.
fail("TODO trap");
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetFormTest.java b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetFormTest.java
index a1f2613570..4815499d9d 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetFormTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetFormTest.java
@@ -17,27 +17,21 @@
*/
package ru.runa.wf.delegate;
-import java.util.Collection;
-import java.util.HashMap;
+import com.google.common.collect.Lists;
import java.util.List;
import java.util.Map;
-
+import lombok.val;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.definition.DefinitionDoesNotExistException;
import ru.runa.wfe.form.Interaction;
import ru.runa.wfe.security.AuthenticationException;
-import ru.runa.wfe.security.AuthorizationException;
import ru.runa.wfe.security.Permission;
import ru.runa.wfe.service.DefinitionService;
-import ru.runa.wfe.service.ExecutionService;
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.task.dto.WfTask;
import ru.runa.wfe.var.VariableDefinition;
-import com.google.common.collect.Lists;
-
/**
* Created on 20.04.2005
*
@@ -47,56 +41,44 @@
public class DefinitionServiceDelegateGetFormTest extends ServletTestCase {
private final static String STATE_1_TYPE = "html";
private final static String STATE_2_TYPE = "swt";
+ private static final String VARIABLE_DEFAULT_FORMAT = "ru.runa.bpm.web.formgen.format.DefaultFormat";
+ private static final String VARIABLE_DOUBLE_FORMAT = "ru.runa.bpm.web.formgen.format.DoubleFormat";
- final String VARIABLE_DEFAULT_FORMAT = "ru.runa.bpm.web.formgen.format.DefaultFormat";
-
- final String VARIABLE_DOUBLE_FORMAT = "ru.runa.bpm.web.formgen.format.DoubleFormat";
-
- private ExecutionService executionService;
-
+ private WfServiceTestHelper h = null;
private DefinitionService definitionService;
-
- private WfServiceTestHelper th = null;
-
private WfTask task;
- protected static final long FAKE_ID = -1;
- protected static final String FAKE_NAME = "FAKE NAME OF TASK";
-
@Override
- protected void setUp() throws Exception {
- th = new WfServiceTestHelper(getClass().getName());
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
definitionService = Delegates.getDefinitionService();
- executionService = Delegates.getExecutionService();
- definitionService.deployProcessDefinition(th.getAdminUser(),
+ definitionService.deployProcessDefinition(h.getAdminUser(),
WfServiceTestHelper.readBytesFromFile(WfServiceTestHelper.ONE_SWIMLANE_FILE_NAME), Lists.newArrayList("testProcess"));
- Collection permissions = Lists.newArrayList(Permission.START, Permission.READ_PROCESS);
- th.setPermissionsToAuthorizedPerformerOnDefinitionByName(permissions, WfServiceTestHelper.ONE_SWIMLANE_PROCESS_NAME);
-
- executionService.startProcess(th.getAuthorizedPerformerUser(), WfServiceTestHelper.ONE_SWIMLANE_PROCESS_NAME, null);
- super.setUp();
- }
+ val pp = Lists.newArrayList(Permission.START_PROCESS, Permission.READ_PROCESS);
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(pp, WfServiceTestHelper.ONE_SWIMLANE_PROCESS_NAME);
- private void initTaskData() throws AuthorizationException, AuthenticationException {
- List tasks = th.getTaskService().getMyTasks(th.getAuthorizedPerformerUser(), th.getTaskBatchPresentation());
- assertNotNull(tasks);
- assertEquals(tasks.size() > 0, true);
- task = tasks.get(0);
+ Delegates.getExecutionService().startProcess(h.getAuthorizedUser(), WfServiceTestHelper.ONE_SWIMLANE_PROCESS_NAME, null);
}
@Override
- protected void tearDown() throws Exception {
- th.undeployValidProcessDefinition(WfServiceTestHelper.ONE_SWIMLANE_PROCESS_NAME);
- th.releaseResources();
+ protected void tearDown() {
+ h.undeployValidProcessDefinition(WfServiceTestHelper.ONE_SWIMLANE_PROCESS_NAME);
+ h.releaseResources();
definitionService = null;
- super.tearDown();
}
- public void testGetFormTestByAuthorizedSubject() throws Exception {
+ private void initTaskData() {
+ List tasks = h.getTaskService().getMyTasks(h.getAuthorizedUser(), h.getTaskBatchPresentation());
+ assertNotNull(tasks);
+ assertTrue(tasks.size() > 0);
+ task = tasks.get(0);
+ }
+
+ public void testGetFormTestByAuthorizedUser() {
initTaskData();
- Interaction interaction = definitionService.getTaskNodeInteraction(th.getAuthorizedPerformerUser(), task.getDefinitionId(), task.getNodeId());
+ Interaction interaction = definitionService.getTaskNodeInteraction(h.getAuthorizedUser(), task.getDefinitionId(), task.getNodeId());
// TODO assertEquals("form name differ from original", STATE_1_NAME,
// interaction.getStateName());
// TODO assertEquals("form name differ from original", STATE_1_TYPE,
@@ -104,35 +86,37 @@ public void testGetFormTestByAuthorizedSubject() throws Exception {
}
- public void testGetFormTestByUnauthorizedSubject() throws Exception {
+ public void testGetFormTestByUnauthorizedUser() {
initTaskData();
- definitionService.getTaskNodeInteraction(th.getUnauthorizedPerformerUser(), task.getDefinitionId(), task.getNodeId());
+ definitionService.getTaskNodeInteraction(h.getUnauthorizedUser(), task.getDefinitionId(), task.getNodeId());
}
- public void testGetFormTestByFakeSubject() throws Exception {
+ public void testGetFormTestByFakeUser() {
initTaskData();
try {
- task = th.getTaskService().getMyTasks(th.getAuthorizedPerformerUser(), th.getTaskBatchPresentation()).get(0);
- definitionService.getTaskNodeInteraction(th.getFakeUser(), task.getDefinitionId(), task.getNodeId());
- fail("testGetFormTestByFakeSubject , no AuthenticationException");
+ task = h.getTaskService().getMyTasks(h.getAuthorizedUser(), h.getTaskBatchPresentation()).get(0);
+ definitionService.getTaskNodeInteraction(h.getFakeUser(), task.getDefinitionId(), task.getNodeId());
+ fail();
} catch (AuthenticationException e) {
+ // Expected.
}
}
- public void testGetFormTestByAuthorizedSubjectWithInvalidDefinitionId() throws Exception {
+ public void testGetFormTestByAuthorizedUserWithInvalidDefinitionId() {
initTaskData();
try {
- definitionService.getTaskNodeInteraction(th.getAuthorizedPerformerUser(), -1l, "");
- fail("testGetFormTestByAuthorizedSubjectWithInvalidDefinitionId , no Exception");
+ definitionService.getTaskNodeInteraction(h.getAuthorizedUser(), -1L, "");
+ fail();
} catch (DefinitionDoesNotExistException e) {
+ // Expected.
}
}
- public void testCheckForm() throws Exception {
- List tasks = th.getTaskService().getMyTasks(th.getAuthorizedPerformerUser(), th.getTaskBatchPresentation());
- assertEquals(tasks.size() > 0, true);
+ public void testCheckForm() {
+ List tasks = h.getTaskService().getMyTasks(h.getAuthorizedUser(), h.getTaskBatchPresentation());
+ assertTrue(tasks.size() > 0);
- Interaction interaction = definitionService.getTaskNodeInteraction(th.getAuthorizedPerformerUser(), tasks.get(0).getDefinitionId(),
+ Interaction interaction = definitionService.getTaskNodeInteraction(h.getAuthorizedUser(), tasks.get(0).getDefinitionId(),
tasks.get(0).getNodeId());
// TODO assertEquals("state name differs from expected", STATE_1_NAME,
@@ -167,10 +151,10 @@ public void testCheckForm() throws Exception {
// assertTrue("optional variable flag was set to true",
// var.isOptional());
- th.getTaskService().completeTask(th.getAuthorizedPerformerUser(), tasks.get(0).getId(), new HashMap(), null);
+ h.getTaskService().completeTask(h.getAuthorizedUser(), tasks.get(0).getId(), null);
- tasks = th.getTaskService().getMyTasks(th.getAuthorizedPerformerUser(), th.getTaskBatchPresentation());
- interaction = definitionService.getTaskNodeInteraction(th.getAuthorizedPerformerUser(), tasks.get(0).getDefinitionId(),
+ tasks = h.getTaskService().getMyTasks(h.getAuthorizedUser(), h.getTaskBatchPresentation());
+ interaction = definitionService.getTaskNodeInteraction(h.getAuthorizedUser(), tasks.get(0).getDefinitionId(),
tasks.get(0).getNodeId());
// TODO assertEquals("state name differs from expected",
@@ -187,5 +171,4 @@ public void testCheckForm() throws Exception {
// var.isOptional());
}
}
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetLatestDefinitionStubTest.java b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetLatestDefinitionStubTest.java
index 4baee36c0e..862f3ac966 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetLatestDefinitionStubTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetLatestDefinitionStubTest.java
@@ -17,10 +17,8 @@
*/
package ru.runa.wf.delegate;
-import java.util.Collection;
-
+import com.google.common.collect.Lists;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.definition.DefinitionDoesNotExistException;
import ru.runa.wfe.definition.dto.WfDefinition;
@@ -30,8 +28,6 @@
import ru.runa.wfe.service.DefinitionService;
import ru.runa.wfe.service.delegate.Delegates;
-import com.google.common.collect.Lists;
-
/**
* Created on 20.04.2005
*
@@ -39,59 +35,56 @@
*
*/
public class DefinitionServiceDelegateGetLatestDefinitionStubTest extends ServletTestCase {
+ private WfServiceTestHelper h;
private DefinitionService definitionService;
- private WfServiceTestHelper helper = null;
@Override
- protected void setUp() throws Exception {
- helper = new WfServiceTestHelper(getClass().getName());
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
definitionService = Delegates.getDefinitionService();
- helper.deployValidProcessDefinition();
-
- Collection permissions = Lists.newArrayList(Permission.READ);
- helper.setPermissionsToAuthorizedPerformerOnDefinitionByName(permissions, WfServiceTestHelper.VALID_PROCESS_NAME);
-
- super.setUp();
+ h.deployValidProcessDefinition();
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(Lists.newArrayList(Permission.READ), WfServiceTestHelper.VALID_PROCESS_NAME);
}
@Override
- protected void tearDown() throws Exception {
- helper.undeployValidProcessDefinition();
-
- helper.releaseResources();
+ protected void tearDown() {
+ h.undeployValidProcessDefinition();
+ h.releaseResources();
definitionService = null;
- super.tearDown();
}
- public void testGetLatestDefinitionStubByAuthorizedUser() throws Exception {
- WfDefinition process = definitionService.getLatestProcessDefinition(helper.getAuthorizedPerformerUser(),
+ public void testGetLatestDefinitionStubByAuthorizedUser() {
+ WfDefinition process = definitionService.getLatestProcessDefinition(h.getAuthorizedUser(),
WfServiceTestHelper.VALID_PROCESS_NAME);
assertEquals("definitionDelegate.getLatestDefinitionStub() returned process with different name", process.getName(),
WfServiceTestHelper.VALID_PROCESS_NAME);
}
- public void testGetLatestDefinitionStubByUnauthorizedUser() throws Exception {
+ public void testGetLatestDefinitionStubByUnauthorizedUser() {
try {
- definitionService.getLatestProcessDefinition(helper.getUnauthorizedPerformerUser(), WfServiceTestHelper.VALID_PROCESS_NAME);
- fail("testGetLatestDefinitionStubByUnauthorizedSubject, no AuthorizationException");
+ definitionService.getLatestProcessDefinition(h.getUnauthorizedUser(), WfServiceTestHelper.VALID_PROCESS_NAME);
+ fail();
} catch (AuthorizationException e) {
+ // Expected.
}
}
- public void testGetLatestDefinitionStubByFakeUser() throws Exception {
+ public void testGetLatestDefinitionStubByFakeUser() {
try {
- definitionService.getLatestProcessDefinition(helper.getFakeUser(), WfServiceTestHelper.VALID_PROCESS_NAME);
- fail("testGetLatestDefinitionStubByUnauthorizedSubject, no AuthenticationException");
+ definitionService.getLatestProcessDefinition(h.getFakeUser(), WfServiceTestHelper.VALID_PROCESS_NAME);
+ fail();
} catch (AuthenticationException e) {
+ // Expected.
}
}
- public void testGetLatestDefinitionStubByAuthorizedSubjectWithInvalidProcessName() throws Exception {
+ public void testGetLatestDefinitionStubByAuthorizedUserWithInvalidProcessName() {
try {
- definitionService.getLatestProcessDefinition(helper.getAuthorizedPerformerUser(), "0_Invalid_Process_Name");
- fail("testGetLatestDefinitionStubByAuthorizedSubjectWithInvalidProcessName, no Exception");
+ definitionService.getLatestProcessDefinition(h.getAuthorizedUser(), "0_Invalid_Process_Name");
+ fail();
} catch (DefinitionDoesNotExistException e) {
+ // Expected.
}
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetLatestProcessDefinitionsStubsTest.java b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetLatestProcessDefinitionsStubsTest.java
index 8314974b48..bc00b8ddba 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetLatestProcessDefinitionsStubsTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetLatestProcessDefinitionsStubsTest.java
@@ -19,6 +19,7 @@
import java.util.List;
+import lombok.val;
import org.apache.cactus.ServletTestCase;
import ru.runa.wf.service.WfServiceTestHelper;
@@ -35,54 +36,50 @@
* @author Gritsenko_S
*/
public class DefinitionServiceDelegateGetLatestProcessDefinitionsStubsTest extends ServletTestCase {
+ private WfServiceTestHelper h;
private DefinitionService definitionService;
-
- private WfServiceTestHelper helper = null;
-
private BatchPresentation batchPresentation;
@Override
- protected void setUp() throws Exception {
- helper = new WfServiceTestHelper(getClass().getName());
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
definitionService = Delegates.getDefinitionService();
- helper.deployValidProcessDefinition();
- batchPresentation = helper.getProcessDefinitionBatchPresentation();
- super.setUp();
+ h.deployValidProcessDefinition();
+ batchPresentation = h.getProcessDefinitionBatchPresentation();
}
@Override
- protected void tearDown() throws Exception {
- helper.undeployValidProcessDefinition();
- helper.releaseResources();
+ protected void tearDown() {
+ h.undeployValidProcessDefinition();
+ h.releaseResources();
definitionService = null;
batchPresentation = null;
- super.tearDown();
}
- public void testGetLatestProcessDefinitionsStubsByAuthorizedSubject() throws Exception {
- List processes = definitionService.getProcessDefinitions(helper.getAuthorizedPerformerUser(), batchPresentation, false);
+ public void testGetLatestProcessDefinitionsStubsByAuthorizedUser() {
+ List processes = definitionService.getProcessDefinitions(h.getAuthorizedUser(), batchPresentation, false);
assertEquals("definitionDelegate.getLatestDefinitionStub() returned not expected list", 1, processes.size());
assertEquals("definitionDelegate.getLatestDefinitionStub() returned process with different name", processes.get(0).getName(),
WfServiceTestHelper.VALID_PROCESS_NAME);
}
- public void testGetLatestProcessDefinitionsStubsByUnauthorizedSubject() throws Exception {
- List processes;
+ public void testGetLatestProcessDefinitionsStubsByUnauthorizedUser() {
try {
- processes = definitionService.getProcessDefinitions(helper.getUnauthorizedPerformerUser(), batchPresentation, false);
- assertEquals("testGetLatestDefinitionStubByUnauthorizedSubject returns process definition for unauthorized performer", 0,
- processes.size());
+ val processes = definitionService.getProcessDefinitions(h.getUnauthorizedUser(), batchPresentation, false);
+ assertEquals(0, processes.size());
} catch (AuthorizationException e) {
+ // Expected.
}
}
- public void testGetLatestProcessDefinitionsStubsByFakeSubject() throws Exception {
+ public void testGetLatestProcessDefinitionsStubsByFakeUser() {
try {
- definitionService.getProcessDefinitions(helper.getFakeUser(), batchPresentation, false);
- assertTrue("testGetLatestDefinitionStubByUnauthorizedSubject, no AuthenticationException", false);
+ definitionService.getProcessDefinitions(h.getFakeUser(), batchPresentation, false);
+ fail();
} catch (AuthenticationException e) {
+ // Expected.
}
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetProcessDefinitionStubTest.java b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetProcessDefinitionStubTest.java
index 9e0dae616c..095660f5a9 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetProcessDefinitionStubTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetProcessDefinitionStubTest.java
@@ -17,10 +17,9 @@
*/
package ru.runa.wf.delegate;
+import com.google.common.collect.Lists;
import java.util.Collection;
-
import org.apache.cactus.ServletTestCase;
-
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.definition.dto.WfDefinition;
import ru.runa.wfe.security.AuthenticationException;
@@ -29,45 +28,38 @@
import ru.runa.wfe.service.DefinitionService;
import ru.runa.wfe.service.delegate.Delegates;
-import com.google.common.collect.Lists;
-
/**
* Created on 20.04.2005
*
* @author Gritsenko_S
*/
public class DefinitionServiceDelegateGetProcessDefinitionStubTest extends ServletTestCase {
+ private WfServiceTestHelper h = null;
private DefinitionService definitionService;
- private WfServiceTestHelper helper = null;
-
@Override
- protected void setUp() throws Exception {
- helper = new WfServiceTestHelper(getClass().getName());
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
definitionService = Delegates.getDefinitionService();
- helper.deployValidProcessDefinition();
-
- super.setUp();
+ h.deployValidProcessDefinition();
}
@Override
- protected void tearDown() throws Exception {
- helper.undeployValidProcessDefinition();
-
- helper.releaseResources();
+ protected void tearDown() {
+ h.undeployValidProcessDefinition();
+ h.releaseResources();
definitionService = null;
- super.tearDown();
}
- public void testGetProcessDefinitionStubByAuthorizedSubject() throws Exception {
+ public void testGetProcessDefinitionStubByAuthorizedUser() {
Collection permissions = Lists.newArrayList(Permission.READ);
- helper.setPermissionsToAuthorizedPerformerOnDefinitionByName(permissions, WfServiceTestHelper.VALID_PROCESS_NAME);
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(permissions, WfServiceTestHelper.VALID_PROCESS_NAME);
- WfDefinition process = definitionService.getLatestProcessDefinition(helper.getAuthorizedPerformerUser(),
+ WfDefinition process = definitionService.getLatestProcessDefinition(h.getAuthorizedUser(),
WfServiceTestHelper.VALID_PROCESS_NAME);
long processId = process.getId();
- WfDefinition actualProcess = definitionService.getProcessDefinition(helper.getAuthorizedPerformerUser(), processId);
+ WfDefinition actualProcess = definitionService.getProcessDefinition(h.getAuthorizedUser(), processId);
assertEquals("definitionDelegate.getLatestDefinitionStub returns different process by the same processId", process.getName(),
actualProcess.getName());
assertEquals("definitionDelegate.getLatestDefinitionStub returns different process by the same processId", process.getId(),
@@ -76,29 +68,32 @@ public void testGetProcessDefinitionStubByAuthorizedSubject() throws Exception {
actualProcess.getId());
}
- public void testGetProcessDefinitionStubByAuthorizedSubjectWithoutREADPermission() throws Exception {
+ public void testGetProcessDefinitionStubByAuthorizedUserWithoutREADPermission() {
Collection permissions = Lists.newArrayList();
- helper.setPermissionsToAuthorizedPerformerOnDefinitionByName(permissions, WfServiceTestHelper.VALID_PROCESS_NAME);
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(permissions, WfServiceTestHelper.VALID_PROCESS_NAME);
try {
- definitionService.getLatestProcessDefinition(helper.getAuthorizedPerformerUser(), WfServiceTestHelper.VALID_PROCESS_NAME);
- fail("testGetProcessDefinitionStubByAuthorizedSubjectWithourREADPermission(), no AuthorizationException");
+ definitionService.getLatestProcessDefinition(h.getAuthorizedUser(), WfServiceTestHelper.VALID_PROCESS_NAME);
+ fail();
} catch (AuthorizationException e) {
+ // Expected.
}
}
- public void testGetProcessDefinitionStubByUnauthorizedSubject() throws Exception {
+ public void testGetProcessDefinitionStubByUnauthorizedUser() {
try {
- definitionService.getLatestProcessDefinition(helper.getUnauthorizedPerformerUser(), WfServiceTestHelper.VALID_PROCESS_NAME);
- fail("testGetProcessDefinitionStubByUnauthorizedSubject(), no AuthorizationException");
+ definitionService.getLatestProcessDefinition(h.getUnauthorizedUser(), WfServiceTestHelper.VALID_PROCESS_NAME);
+ fail();
} catch (AuthorizationException e) {
+ // Expected.
}
}
- public void testGetProcessDefinitionStubByFakeSubject() throws Exception {
+ public void testGetProcessDefinitionStubByFakeUser() {
try {
- definitionService.getLatestProcessDefinition(helper.getFakeUser(), WfServiceTestHelper.VALID_PROCESS_NAME);
- fail("testGetProcessDefinitionStubByFakeSubject(), no AuthenticationException");
+ definitionService.getLatestProcessDefinition(h.getFakeUser(), WfServiceTestHelper.VALID_PROCESS_NAME);
+ fail();
} catch (AuthenticationException e) {
+ // Expected.
}
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetStartFormTest.java b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetStartFormTest.java
index d86a68f926..42af6a18d9 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetStartFormTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateGetStartFormTest.java
@@ -17,12 +17,12 @@
*/
package ru.runa.wf.delegate;
+import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
+import lombok.val;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.junit.ArrayAssert;
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.definition.DefinitionDoesNotExistException;
@@ -32,42 +32,34 @@
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.var.VariableDefinition;
-import com.google.common.collect.Lists;
-
/**
* Created on 20.04.2005
*
* @author Gritsenko_S
*/
public class DefinitionServiceDelegateGetStartFormTest extends ServletTestCase {
+ private WfServiceTestHelper h;
private DefinitionService definitionService;
-
- private WfServiceTestHelper helper = null;
-
private Long definitionId;
@Override
- protected void setUp() throws Exception {
- helper = new WfServiceTestHelper(getClass().getName());
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
definitionService = Delegates.getDefinitionService();
- helper.deployValidProcessDefinition();
-
- definitionId = definitionService.getLatestProcessDefinition(helper.getAdminUser(), WfServiceTestHelper.VALID_PROCESS_NAME).getId();
-
- super.setUp();
+ h.deployValidProcessDefinition();
+ definitionId = definitionService.getLatestProcessDefinition(h.getAdminUser(), WfServiceTestHelper.VALID_PROCESS_NAME).getId();
}
@Override
- protected void tearDown() throws Exception {
- helper.undeployValidProcessDefinition();
- helper.releaseResources();
+ protected void tearDown() {
+ h.undeployValidProcessDefinition();
+ h.releaseResources();
definitionService = null;
- super.tearDown();
}
- public void testGetStartFormTestByAuthorizedSubject() throws Exception {
- Interaction startForm = definitionService.getStartInteraction(helper.getAuthorizedPerformerUser(), definitionId);
+ public void testGetStartFormTestByAuthorizedUser() {
+ Interaction startForm = definitionService.getStartInteraction(h.getAuthorizedUser(), definitionId);
// / TO DO : xml read from forms.xml & processdefinition.xml
// TODO assertEquals("start form name differ from original",
@@ -75,7 +67,7 @@ public void testGetStartFormTestByAuthorizedSubject() throws Exception {
if (false) {
assertEquals("start form name differ from original", "html", startForm.getType());
Map vars = startForm.getVariables();
- List actual = new ArrayList();
+ val actual = new ArrayList();
for (VariableDefinition var : vars.values()) {
actual.add(var.getName());
}
@@ -85,23 +77,25 @@ public void testGetStartFormTestByAuthorizedSubject() throws Exception {
}
}
- public void testGetStartFormTestByUnauthorizedSubject() throws Exception {
- definitionService.getStartInteraction(helper.getUnauthorizedPerformerUser(), definitionId);
+ public void testGetStartFormTestByUnauthorizedUser() {
+ definitionService.getStartInteraction(h.getUnauthorizedUser(), definitionId);
}
- public void testGetStartFormTestByFakeSubject() throws Exception {
+ public void testGetStartFormTestByFakeUser() {
try {
- definitionService.getStartInteraction(helper.getFakeUser(), definitionId);
- fail("testGetStartFormTestByFakeSubject , no AuthenticationException");
+ definitionService.getStartInteraction(h.getFakeUser(), definitionId);
+ fail();
} catch (AuthenticationException e) {
+ // Expected.
}
}
- public void testGetStartFormTestByAuthorizedSubjectWithInvalidDefinitionId() throws Exception {
+ public void testGetStartFormTestByAuthorizedUserWithInvalidDefinitionId() {
try {
- definitionService.getStartInteraction(helper.getAuthorizedPerformerUser(), -1l);
- fail("testGetStartFormTestByAuthorizedSubjectWithInvalidDefinitionId , no Exception");
+ definitionService.getStartInteraction(h.getAuthorizedUser(), -1L);
+ fail();
} catch (DefinitionDoesNotExistException e) {
+ // Expected.
}
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateRedeployProcessDefinitionTest.java b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateRedeployProcessDefinitionTest.java
index 22d2e00495..ecc37d66fb 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateRedeployProcessDefinitionTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateRedeployProcessDefinitionTest.java
@@ -17,11 +17,10 @@
*/
package ru.runa.wf.delegate;
+import com.google.common.collect.Lists;
import java.util.Collection;
import java.util.List;
-
import org.apache.cactus.ServletTestCase;
-
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.definition.DefinitionArchiveFormatException;
import ru.runa.wfe.definition.DefinitionDoesNotExistException;
@@ -33,114 +32,108 @@
import ru.runa.wfe.service.delegate.Delegates;
import ru.runa.wfe.user.User;
-import com.google.common.collect.Lists;
-
/**
* Created on 20.04.2005
*
* @author Gritsenko_S
*/
public class DefinitionServiceDelegateRedeployProcessDefinitionTest extends ServletTestCase {
-
+ private WfServiceTestHelper h;
private DefinitionService definitionService;
- private WfServiceTestHelper helper = null;
-
private long processDefinitionId;
@Override
- protected void setUp() throws Exception {
- helper = new WfServiceTestHelper(getClass().getName());
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
definitionService = Delegates.getDefinitionService();
- helper.deployValidProcessDefinition();
-
- processDefinitionId = definitionService.getLatestProcessDefinition(helper.getAdminUser(), WfServiceTestHelper.VALID_PROCESS_NAME).getId();
-
- Collection redeployPermissions = Lists.newArrayList(Permission.UPDATE);
- helper.setPermissionsToAuthorizedPerformerOnDefinitionByName(redeployPermissions, WfServiceTestHelper.VALID_PROCESS_NAME);
-
- super.setUp();
+ h.deployValidProcessDefinition();
+ processDefinitionId = definitionService.getLatestProcessDefinition(h.getAdminUser(), WfServiceTestHelper.VALID_PROCESS_NAME).getId();
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(Lists.newArrayList(Permission.UPDATE), WfServiceTestHelper.VALID_PROCESS_NAME);
}
@Override
- protected void tearDown() throws Exception {
- helper.undeployValidProcessDefinition();
-
- helper.releaseResources();
+ protected void tearDown() {
+ h.undeployValidProcessDefinition();
+ h.releaseResources();
definitionService = null;
- super.tearDown();
}
- public void testRedeployProcessByAuthorizedPerformer() throws Exception {
- definitionService.redeployProcessDefinition(helper.getAuthorizedPerformerUser(), processDefinitionId, helper.getValidProcessDefinition(),
+ public void testRedeployProcessByAuthorizedUser() {
+ definitionService.redeployProcessDefinition(h.getAuthorizedUser(), processDefinitionId, h.getValidProcessDefinition(),
Lists.newArrayList("testProcess"));
- List deployedProcesses = definitionService.getProcessDefinitions(helper.getAuthorizedPerformerUser(),
- helper.getProcessDefinitionBatchPresentation(), false);
+ List deployedProcesses = definitionService.getProcessDefinitions(h.getAuthorizedUser(),
+ h.getProcessDefinitionBatchPresentation(), false);
if (deployedProcesses.size() != 1) {
- assertTrue("testRedeployProcessByAuthorizedPerformer wrongNumberOfProcessDefinitions", false);
+ fail("testRedeployProcessByAuthorizedUser() wrongNumberOfProcessDefinitions");
}
if (!deployedProcesses.get(0).getName().equals(WfServiceTestHelper.VALID_PROCESS_NAME)) {
- assertTrue("testRedeployProcessByAuthorizedPerformer wrongNameOfDeployedProcessDefinitions", false);
+ fail("testRedeployProcessByAuthorizedUser() wrongNameOfDeployedProcessDefinitions");
}
}
- public void testRedeployProcessByAuthorizedPerformerWithoutREDEPLOYPermission() throws Exception {
+ public void testRedeployProcessByAuthorizedUserWithoutREDEPLOYPermission() {
Collection nullPermissions = Lists.newArrayList();
- helper.setPermissionsToAuthorizedPerformerOnDefinitionByName(nullPermissions, WfServiceTestHelper.VALID_PROCESS_NAME);
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(nullPermissions, WfServiceTestHelper.VALID_PROCESS_NAME);
try {
- definitionService.redeployProcessDefinition(helper.getAuthorizedPerformerUser(), processDefinitionId, helper.getValidProcessDefinition(),
+ definitionService.redeployProcessDefinition(h.getAuthorizedUser(), processDefinitionId, h.getValidProcessDefinition(),
Lists.newArrayList("testProcess"));
- assertTrue("definitionDelegate.redeployProcessByAuthorizedPerformer() no AuthorizationException", false);
+ fail("testRedeployProcessByAuthorizedUserWithoutREDEPLOYPermission() no AuthorizationException");
} catch (AuthorizationException e) {
+ // Expected.
}
}
- public void testRedeployProcessByUnauthorizedPerformer() throws Exception {
+ public void testRedeployProcessByUnauthorizedUser() {
try {
- definitionService.redeployProcessDefinition(helper.getUnauthorizedPerformerUser(), processDefinitionId,
- helper.getValidProcessDefinition(), Lists.newArrayList("testProcess"));
- assertTrue("definitionDelegate.redeployProcessByUnauthorizedPerformer() no AuthorizationException", false);
+ definitionService.redeployProcessDefinition(h.getUnauthorizedUser(), processDefinitionId,
+ h.getValidProcessDefinition(), Lists.newArrayList("testProcess"));
+ fail("testRedeployProcessByUnauthorizedUser() no AuthorizationException");
} catch (AuthorizationException e) {
+ // Expected.
}
}
- public void testRedeployProcessWithFakeSubject() throws Exception {
+ public void testRedeployProcessWithFakeUser() {
try {
- User fakeUser = helper.getFakeUser();
- definitionService.redeployProcessDefinition(fakeUser, processDefinitionId, helper.getValidProcessDefinition(),
+ User fakeUser = h.getFakeUser();
+ definitionService.redeployProcessDefinition(fakeUser, processDefinitionId, h.getValidProcessDefinition(),
Lists.newArrayList("testProcess"));
- assertTrue("testRedeployProcessWithFakeSubject no AuthenticationException", false);
+ fail();
} catch (AuthenticationException e) {
+ // Expected.
}
}
- public void testRedeployInvalidProcessByAuthorizedPerformer() throws Exception {
+ public void testRedeployInvalidProcessByAuthorizedUser() {
try {
- definitionService.redeployProcessDefinition(helper.getAuthorizedPerformerUser(), processDefinitionId,
- helper.getInValidProcessDefinition(), Lists.newArrayList("testProcess"));
- assertTrue("definitionDelegate.deployProcessByAuthorizedPerformer() no DefinitionParsingException", false);
+ definitionService.redeployProcessDefinition(h.getAuthorizedUser(), processDefinitionId,
+ h.getInValidProcessDefinition(), Lists.newArrayList("testProcess"));
+ fail("testRedeployInvalidProcessByAuthorizedUser() no DefinitionParsingException");
} catch (DefinitionArchiveFormatException e) {
+ // Expected.
}
}
- public void testRedeployWithInvalidProcessId() throws Exception {
+ public void testRedeployWithInvalidProcessId() {
try {
- definitionService.redeployProcessDefinition(helper.getAuthorizedPerformerUser(), -1l, helper.getValidProcessDefinition(),
+ definitionService.redeployProcessDefinition(h.getAuthorizedUser(), -1L, h.getValidProcessDefinition(),
Lists.newArrayList("testProcess"));
fail("testRedeployWithInvalidProcessId() no Exception");
} catch (DefinitionDoesNotExistException e) {
+ // Expected.
}
}
- public void testRedeployInvalidProcess() throws Exception {
+ public void testRedeployInvalidProcess() {
try {
- definitionService.redeployProcessDefinition(helper.getAuthorizedPerformerUser(), processDefinitionId,
- helper.getInValidProcessDefinition(), Lists.newArrayList("testProcess"));
+ definitionService.redeployProcessDefinition(h.getAuthorizedUser(), processDefinitionId,
+ h.getInValidProcessDefinition(), Lists.newArrayList("testProcess"));
fail("testRedeployInvalidProcess() no Exception");
} catch (DefinitionArchiveFormatException e) {
+ // Expected.
}
}
-
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateUndeployProcessDefinitionTest.java b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateUndeployProcessDefinitionTest.java
index 4ec913b6a6..8dd0c5dba5 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateUndeployProcessDefinitionTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/DefinitionServiceDelegateUndeployProcessDefinitionTest.java
@@ -17,11 +17,10 @@
*/
package ru.runa.wf.delegate;
+import com.google.common.collect.Lists;
import java.util.Collection;
import java.util.List;
-
import org.apache.cactus.ServletTestCase;
-
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.definition.DefinitionDoesNotExistException;
import ru.runa.wfe.definition.dto.WfDefinition;
@@ -31,98 +30,93 @@
import ru.runa.wfe.service.DefinitionService;
import ru.runa.wfe.service.delegate.Delegates;
-import com.google.common.collect.Lists;
-
/**
* Created on 20.04.2005
*
* @author Gritsenko_S
*/
public class DefinitionServiceDelegateUndeployProcessDefinitionTest extends ServletTestCase {
-
+ private WfServiceTestHelper h;
private DefinitionService definitionService;
- private WfServiceTestHelper helper = null;
-
@Override
- protected void setUp() throws Exception {
- helper = new WfServiceTestHelper(getClass().getName());
+ protected void setUp() {
+ h = new WfServiceTestHelper(getClass().getName());
definitionService = Delegates.getDefinitionService();
- helper.deployValidProcessDefinition();
-
- Collection undeployPermissions = Lists.newArrayList(Permission.ALL);
- helper.setPermissionsToAuthorizedPerformerOnExecutors(undeployPermissions);
-
- super.setUp();
+ h.deployValidProcessDefinition();
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(Lists.newArrayList(Permission.DELETE), WfServiceTestHelper.VALID_PROCESS_NAME);
}
@Override
- protected void tearDown() throws Exception {
- helper.releaseResources();
+ protected void tearDown() {
+ h.releaseResources();
definitionService = null;
- super.tearDown();
}
- public void testUndeployProcessByAuthorizedPerformer() throws Exception {
- definitionService.undeployProcessDefinition(helper.getAuthorizedPerformerUser(), WfServiceTestHelper.VALID_PROCESS_NAME, null);
- List deployedProcesses = definitionService.getProcessDefinitions(helper.getAuthorizedPerformerUser(),
- helper.getProcessDefinitionBatchPresentation(), false);
+ public void testUndeployProcessByAuthorizedUser() {
+ definitionService.undeployProcessDefinition(h.getAuthorizedUser(), WfServiceTestHelper.VALID_PROCESS_NAME, null);
+ List deployedProcesses = definitionService.getProcessDefinitions(h.getAuthorizedUser(),
+ h.getProcessDefinitionBatchPresentation(), false);
if (deployedProcesses.size() != 0) {
- fail("testUndeployProcessByAuthorizedPerformer wrongNumberOfProcessDefinitions after undeployment");
+ fail("testUndeployProcessByAuthorizedUser() wrongNumberOfProcessDefinitions after undeployment");
}
try {
- definitionService.undeployProcessDefinition(helper.getAuthorizedPerformerUser(), WfServiceTestHelper.VALID_PROCESS_NAME, null);
- fail("testUndeployProcessByAuthorizedPerformer allows undeploy process definition after undeployment");
+ definitionService.undeployProcessDefinition(h.getAuthorizedUser(), WfServiceTestHelper.VALID_PROCESS_NAME, null);
+ fail("testUndeployProcessByAuthorizedUser() allows undeploy process definition after undeployment");
} catch (DefinitionDoesNotExistException e) {
+ // Expected.
}
}
- public void testUndeployProcessByAuthorizedPerformerWithoutUNDEPLOYPermission() throws Exception {
+ public void testUndeployProcessByAuthorizedUserWithoutUNDEPLOYPermission() {
try {
Collection undeployPermissions = Lists.newArrayList();
- helper.setPermissionsToAuthorizedPerformerOnDefinitionByName(undeployPermissions, WfServiceTestHelper.VALID_PROCESS_NAME);
+ h.setPermissionsToAuthorizedActorOnDefinitionByName(undeployPermissions, WfServiceTestHelper.VALID_PROCESS_NAME);
try {
- definitionService.undeployProcessDefinition(helper.getAuthorizedPerformerUser(), WfServiceTestHelper.VALID_PROCESS_NAME, null);
- fail("testUndeployProcessByAuthorizedPerformerWithoutUNDEPLOYPermission, no AuthorizationException");
+ definitionService.undeployProcessDefinition(h.getAuthorizedUser(), WfServiceTestHelper.VALID_PROCESS_NAME, null);
+ fail("testUndeployProcessByAuthorizedUserWithoutUNDEPLOYPermission(), no AuthorizationException");
} catch (AuthorizationException e1) {
+ // Expected.
}
} finally {
- helper.undeployValidProcessDefinition();
+ h.undeployValidProcessDefinition();
}
}
- public void testUndeployProcessByUnauthorizedPerformer() throws Exception {
+ public void testUndeployProcessByUnauthorizedUser() {
try {
- definitionService.undeployProcessDefinition(helper.getUnauthorizedPerformerUser(), WfServiceTestHelper.VALID_PROCESS_NAME, null);
- fail("testUndeployProcessByUnauthorizedPerformer, no AuthorizationException");
+ definitionService.undeployProcessDefinition(h.getUnauthorizedUser(), WfServiceTestHelper.VALID_PROCESS_NAME, null);
+ fail("testUndeployProcessByUnauthorizedUser(), no AuthorizationException");
} catch (AuthorizationException e1) {
+ // Expected.
} finally {
- helper.undeployValidProcessDefinition();
+ h.undeployValidProcessDefinition();
}
}
- public void testUndeployProcessByFakePerformer() throws Exception {
+ public void testUndeployProcessByFakeUser() {
try {
- definitionService.undeployProcessDefinition(helper.getFakeUser(), WfServiceTestHelper.VALID_PROCESS_NAME, null);
- fail("testUndeployProcessByFakePerformer, no AuthenticationException");
+ definitionService.undeployProcessDefinition(h.getFakeUser(), WfServiceTestHelper.VALID_PROCESS_NAME, null);
+ fail("no AuthenticationException");
} catch (AuthenticationException e1) {
+ // Expected.
} finally {
- helper.undeployValidProcessDefinition();
+ h.undeployValidProcessDefinition();
}
}
- public void testUndeployProcessWithUnexistentProcessName() throws Exception {
+ public void testUndeployProcessWithUnexistentProcessName() {
try {
- definitionService.undeployProcessDefinition(helper.getUnauthorizedPerformerUser(), "Unexistent_Process_definition_Name_000", null);
+ definitionService.undeployProcessDefinition(h.getUnauthorizedUser(), "Unexistent_Process_definition_Name_000", null);
fail("testUndeployProcessWithNullProcessName allows undeploy process definition with unexistent name");
} catch (DefinitionDoesNotExistException e) {
+ // Expected.
} finally {
- helper.undeployValidProcessDefinition();
+ h.undeployValidProcessDefinition();
}
-
}
}
diff --git a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/ExecutionServiceDelegateAssignTaskTest.java b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/ExecutionServiceDelegateAssignTaskTest.java
index 1f86691570..d9d9004ee4 100644
--- a/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/ExecutionServiceDelegateAssignTaskTest.java
+++ b/wfe-cactus-it/src/test/java/ru/runa/wf/delegate/ExecutionServiceDelegateAssignTaskTest.java
@@ -17,12 +17,10 @@
*/
package ru.runa.wf.delegate;
-import java.util.Collection;
-import java.util.HashMap;
+import com.google.common.collect.Lists;
import java.util.List;
-
+import lombok.val;
import org.apache.cactus.ServletTestCase;
-
import ru.runa.wf.service.WfServiceTestHelper;
import ru.runa.wfe.InternalApplicationException;
import ru.runa.wfe.definition.dto.WfDefinition;
@@ -40,18 +38,13 @@
import ru.runa.wfe.user.User;
import ru.runa.wfe.validation.ValidationException;
-import com.google.common.collect.Lists;
-
/**
* This test class is to check concurrent work of 2 users concerning "Assign task" function.
- * It does not take into account substitution logic.
+ * It does not take substitution logic into account.
*
* @see ExecutionServiceDelegateSubstitutionAssignTaskTest
*/
public class ExecutionServiceDelegateAssignTaskTest extends ServletTestCase {
-
- private final static String PREFIX = ExecutionServiceDelegateAssignTaskTest.class.getName();
-
private static final String PROCESS_NAME = WfServiceTestHelper.SWIMLANE_SAME_GROUP_SEQ_PROCESS_NAME;
private final static String nameActor1 = "actor1";
@@ -61,54 +54,46 @@ public class ExecutionServiceDelegateAssignTaskTest extends ServletTestCase {
private final static String pwdActor1 = "123";
private final static String pwdActor2 = "123";
- private Actor actor1;
- private Actor actor2;
- private Group group;
-
private User actor1User = null;
private User actor2User = null;
- private WfServiceTestHelper testHelper;
-
+ private WfServiceTestHelper h;
private BatchPresentation batchPresentation;
@Override
- protected void setUp() throws Exception {
- testHelper = new WfServiceTestHelper(PREFIX);
-
- actor1 = testHelper.createActorIfNotExist(nameActor1, PREFIX);
- testHelper.getExecutorService().setPassword(testHelper.getAdminUser(), actor1, pwdActor1);
- actor2 = testHelper.createActorIfNotExist(nameActor2, PREFIX);
- testHelper.getExecutorService().setPassword(testHelper.getAdminUser(), actor2, pwdActor2);
- group = testHelper.createGroupIfNotExist(nameGroup, "description");
- testHelper.addExecutorToGroup(actor1, group);
- testHelper.addExecutorToGroup(actor2, group);
+ protected void setUp() {
+ val prefix = getClass().getName();
+ h = new WfServiceTestHelper(prefix);
+ batchPresentation = h.getTaskBatchPresentation();
+
+ Actor actor1 = h.createActorIfNotExist(nameActor1, prefix);
+ h.getExecutorService().setPassword(h.getAdminUser(), actor1, pwdActor1);
+ Actor actor2 = h.createActorIfNotExist(nameActor2, prefix);
+ h.getExecutorService().setPassword(h.getAdminUser(), actor2, pwdActor2);
+ Group group = h.createGroupIfNotExist(nameGroup, "description");
+ h.addExecutorToGroup(actor1, group);
+ h.addExecutorToGroup(actor2, group);
{
- Collection perm = Lists.newArrayList(Permission.LOGIN);
- testHelper.getAuthorizationService().setPermissions(testHelper.getAdminUser(), group.getId(), perm, SecuredSingleton.EXECUTORS);
- testHelper.getAuthorizationService().setPermissions(testHelper.getAdminUser(), actor1.getId(), perm, SecuredSingleton.EXECUTORS);
- testHelper.getAuthorizationService().setPermissions(testHelper.getAdminUser(), actor2.getId(), perm, SecuredSingleton.EXECUTORS);
+ val pp = Lists.newArrayList(Permission.LOGIN);
+ h.getAuthorizationService().setPermissions(h.getAdminUser(), group.getId(), pp, SecuredSingleton.SYSTEM); // TODO What for?
+ h.getAuthorizationService().setPermissions(h.getAdminUser(), actor1.getId(), pp, SecuredSingleton.SYSTEM);
+ h.getAuthorizationService().setPermissions(h.getAdminUser(), actor2.getId(), pp, SecuredSingleton.SYSTEM);
}
- actor1User = testHelper.getAuthenticationService().authenticateByLoginPassword(nameActor1, pwdActor1);
- actor2User = testHelper.getAuthenticationService().authenticateByLoginPassword(nameActor2, pwdActor2);
+ actor1User = h.getAuthenticationService().authenticateByLoginPassword(nameActor1, pwdActor1);
+ actor2User = h.getAuthenticationService().authenticateByLoginPassword(nameActor2, pwdActor2);
byte[] parBytes = WfServiceTestHelper.readBytesFromFile(PROCESS_NAME + ".par");
- testHelper.getDefinitionService().deployProcessDefinition(testHelper.getAdminUser(), parBytes, Lists.newArrayList("testProcess"));
- WfDefinition definition = testHelper.getDefinitionService().getLatestProcessDefinition(testHelper.getAdminUser(), PROCESS_NAME);
- Collection definitionPermission = Lists.newArrayList(Permission.START);
- testHelper.getAuthorizationService().setPermissions(testHelper.getAdminUser(), actor1.getId(), definitionPermission, definition);
-
- batchPresentation = testHelper.getTaskBatchPresentation();
- super.setUp();
+ h.getDefinitionService().deployProcessDefinition(h.getAdminUser(), parBytes, Lists.newArrayList("testProcess"));
+ WfDefinition definition = h.getDefinitionService().getLatestProcessDefinition(h.getAdminUser(), PROCESS_NAME);
+ h.getAuthorizationService().setPermissions(h.getAdminUser(), actor1.getId(), Lists.newArrayList(Permission.START_PROCESS), definition);
}
@Override
- protected void tearDown() throws Exception {
- testHelper.getDefinitionService().undeployProcessDefinition(testHelper.getAdminUser(), PROCESS_NAME, null);
- testHelper.releaseResources();
- super.tearDown();
+ protected void tearDown() {
+ h.getDefinitionService().undeployProcessDefinition(h.getAdminUser(), PROCESS_NAME, null);
+ h.releaseResources();
}
/**
@@ -117,16 +102,14 @@ protected void tearDown() throws Exception {
* User 1 assigns a task
* User 2 tries to assign the task
*
- *
- * @throws Exception
*/
// 1
- public void testAssignAssigned() throws Exception {
+ public void testAssignAssigned() {
{
checkTaskList(actor1User, 0);
checkTaskList(actor2User, 0);
}
- testHelper.getExecutionService().startProcess(actor1User, PROCESS_NAME, null);
+ h.getExecutionService().startProcess(actor1User, PROCESS_NAME, null);
for (int i = 0; i < 3; ++i) {
moveAssignAssigned();
}
@@ -142,15 +125,13 @@ public void testAssignAssigned() throws Exception {
* User 1 executes a task
* User 2 tries to assign the task
*
- *
- * @throws Exception
*/
- public void testAssignMoved() throws Exception {
+ public void testAssignMoved() {
{
checkTaskList(actor1User, 0);
checkTaskList(actor2User, 0);
}
- testHelper.getExecutionService().startProcess(actor1User, PROCESS_NAME, null);
+ h.getExecutionService().startProcess(actor1User, PROCESS_NAME, null);
for (int i = 0; i < 3; ++i) {
try {
moveAssignMoved();
@@ -172,15 +153,13 @@ public void testAssignMoved() throws Exception {
* User 1 assign a task
* User 2 tries to move the task
*
- *
- * @throws Exception
*/
- public void testMoveAssigned() throws Exception {
+ public void testMoveAssigned() {
{
checkTaskList(actor1User, 0);
checkTaskList(actor2User, 0);
}
- testHelper.getExecutionService().startProcess(actor1User, PROCESS_NAME, null);
+ h.getExecutionService().startProcess(actor1User, PROCESS_NAME, null);
for (int i = 0; i < 3; ++i) {
moveMoveAssigned();
}
@@ -196,19 +175,17 @@ public void testMoveAssigned() throws Exception {
* User 1 executes a task
* User 2 tries to execute the task
*
- *
- * @throws Exception
*/
- public void testMoveMoved() throws Exception {
+ public void testMoveMoved() {
{
checkTaskList(actor1User, 0);
checkTaskList(actor2User, 0);
}
- testHelper.getExecutionService().startProcess(actor1User, PROCESS_NAME, null);
+ h.getExecutionService().startProcess(actor1User, PROCESS_NAME, null);
moveExecuteExecuted();
}
- private void moveAssignAssigned() throws Exception {
+ private void moveAssignAssigned() {
WfTask[] tasks1, tasks2;
{
@@ -216,7 +193,7 @@ private void moveAssignAssigned() throws Exception {
tasks2 = checkTaskList(actor2User, 1);
}
Actor actor = actor1User.getActor();
- testHelper.getTaskService().assignTask(actor1User, tasks1[0].getId(), tasks1[0].getOwner(), actor);
+ h.getTaskService().assignTask(actor1User, tasks1[0].getId(), tasks1[0].getOwner(), actor);
{
tasks1 = checkTaskList(actor1User, 1);
checkTaskList(actor2User, 0);
@@ -226,22 +203,22 @@ private void moveAssignAssigned() throws Exception {
tasks1 = checkTaskList(actor1User, 1);
checkTaskList(actor2User, 0);
}
- testHelper.getTaskService().completeTask(actor1User, tasks1[0].getId(), new HashMap(), null);
+ h.getTaskService().completeTask(actor1User, tasks1[0].getId(), null);
}
- private void moveAssignMoved() throws Exception {
+ private void moveAssignMoved() {
WfTask[] tasks1, tasks2;
{
tasks1 = checkTaskList(actor1User, 1);
tasks2 = checkTaskList(actor2User, 1);
}
- testHelper.getTaskService().completeTask(actor1User, tasks1[0].getId(), new HashMap(), null);
+ h.getTaskService().completeTask(actor1User, tasks1[0].getId(), null);
assertExceptionThrownOnAssign(actor2User, tasks2[0]);
}
// ------------------------------------------------------------------------------------------------------------------------
- private void moveMoveAssigned() throws Exception {
+ private void moveMoveAssigned() {
WfTask[] tasks1, tasks2;
{
@@ -249,7 +226,7 @@ private void moveMoveAssigned() throws Exception {
tasks2 = checkTaskList(actor2User, 1);
}
Actor actor = actor1User.getActor();
- testHelper.getTaskService().assignTask(actor1User, tasks1[0].getId(), tasks1[0].getOwner(), actor);
+ h.getTaskService().assignTask(actor1User, tasks1[0].getId(), tasks1[0].getOwner(), actor);
{
tasks1 = checkTaskList(actor1User, 1);
checkTaskList(actor2User, 0);
@@ -259,17 +236,17 @@ private void moveMoveAssigned() throws Exception {
tasks1 = checkTaskList(actor1User, 1);
checkTaskList(actor2User, 0);
}
- testHelper.getTaskService().completeTask(actor1User, tasks1[0].getId(), new HashMap(), null);
+ h.getTaskService().completeTask(actor1User, tasks1[0].getId(), null);
}
- private void moveExecuteExecuted() throws Exception {
+ private void moveExecuteExecuted() {
WfTask[] tasks1, tasks2;
{
tasks1 = checkTaskList(actor1User, 1);
tasks2 = checkTaskList(actor2User, 1);
}
- testHelper.getTaskService().completeTask(actor1User, tasks1[0].getId(), new HashMap(), null);
+ h.getTaskService().completeTask(actor1User, tasks1[0].getId(), null);
{
checkTaskList(actor1User, tasks1[0]);
checkTaskList(actor2User, tasks2[0]);
@@ -277,9 +254,9 @@ private void moveExecuteExecuted() throws Exception {
assertExceptionThrownOnExecute(actor2User, tasks2[0]);
}
- private void assertExceptionThrownOnExecute(User user, WfTask task) throws InternalApplicationException {
+ private void assertExceptionThrownOnExecute(User user, WfTask task) {
try {
- testHelper.getTaskService().completeTask(user, task.getId(), new HashMap(), null);
+ h.getTaskService().completeTask(user, task.getId(), null);
throw new InternalApplicationException("Exception TaskDoesNotExistException not thrown");
} catch (AuthenticationException e) {
} catch (AuthorizationException e) {
@@ -292,10 +269,10 @@ private void assertExceptionThrownOnExecute(User user, WfTask task) throws Inter
}
// /rask:
- private void assertExceptionThrownOnAssign(User user, WfTask task) throws ExecutorDoesNotExistException {
+ private void assertExceptionThrownOnAssign(User user, WfTask task) {
try {
Actor actor = actor1User.getActor();
- testHelper.getTaskService().assignTask(user, task.getId(), task.getOwner(), actor);
+ h.getTaskService().assignTask(user, task.getId(), task.getOwner(), actor);
throw new InternalApplicationException("Exception TaskAlreadyAcceptedException not thrown");
} catch (TaskAlreadyAcceptedException e) {
} catch (AuthenticationException e) {
@@ -303,9 +280,9 @@ private void assertExceptionThrownOnAssign(User user, WfTask task) throws Execut
}
}
- private List checkTaskList(User user, WfTask task) throws Exception {
+ private List