TSK-74: added acceptance test to updating workbaskets.

This commit is contained in:
Holger Hagen 2018-02-02 17:26:34 +01:00 committed by Marcel Lengl
parent 407a4a33d8
commit 5419132014
2 changed files with 89 additions and 1 deletions

View File

@ -0,0 +1,88 @@
package acceptance.workbasket;
import java.sql.SQLException;
import java.time.Instant;
import org.h2.store.fs.FileUtils;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import acceptance.AbstractAccTest;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.model.WorkbasketType;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
/**
* Acceptance test for all "update workbasket" scenarios.
*/
@RunWith(JAASRunner.class)
public class UpdateWorkbasketAccTest extends AbstractAccTest {
public UpdateWorkbasketAccTest() {
super();
}
@WithAccessId(
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testUpdateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasketByKey("GPK_KSC");
Instant modified = workbasket.getModified();
workbasket.setName("new name");
workbasket.setDescription("new description");
workbasket.setType(WorkbasketType.TOPIC);
workbasket.setDomain("DOMAIN_C");
workbasket.setOrgLevel1("new level 1");
workbasket.setOrgLevel2("new level 2");
workbasket.setOrgLevel3("new level 3");
workbasket.setOrgLevel4("new level 4");
workbasket.setCustom1("new custom 1");
workbasket.setCustom2("new custom 2");
workbasket.setCustom3("new custom 3");
workbasket.setCustom4("new custom 4");
workbasket.setDescription("new description");
workbasketService.updateWorkbasket(workbasket);
Workbasket updatedWorkbasket = workbasketService.getWorkbasketByKey("GPK_KSC");
Assert.assertEquals(workbasket.getId(), updatedWorkbasket.getId());
Assert.assertEquals(workbasket.getCreated(), updatedWorkbasket.getCreated());
Assert.assertNotEquals(modified, updatedWorkbasket.getModified());
Assert.assertEquals("new name", updatedWorkbasket.getName());
Assert.assertEquals(WorkbasketType.TOPIC, updatedWorkbasket.getType());
}
@Ignore
@WithAccessId(
userName = "teamlead_1",
groupNames = {"group_1"})
@Test(expected = NotAuthorizedException.class)
public void testCheckAuthorizationToUpdateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasketByKey("GPK_KSC");
workbasket.setName("new name");
workbasketService.updateWorkbasket(workbasket);
}
@AfterClass
public static void cleanUpClass() {
FileUtils.deleteRecursive("~/data", true);
}
}

View File

@ -4,7 +4,7 @@ INSERT INTO WORKBASKET VALUES ('3', 'key3', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
INSERT INTO WORKBASKET VALUES ('4', 'key4', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Basket4', 'DOMAIN_A', 'TOPIC', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'Max', '', '', '', '', '', '', '', '');
-- KSC workbaskets
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000001', 'GPK_KSC', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000001', 'GPK_KSC', '2018-02-01T12:00:00', '2018-02-01T12:00:00', 'Gruppenpostkorb KSC', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000002', 'GPK_KSC_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC 1', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC 1', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000003', 'GPK_KSC_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC 2', 'DOMAIN_A', 'GROUP', 'Gruppenpostkorb KSC 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000004', 'TEAMLEAD_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'PPK Teamlead KSC 1', 'DOMAIN_A', 'PERSONAL', 'PPK Teamlead KSC 1', '', '', '', '', '', '', '', '', '');