TSK-329 (draft): method removed. Tests are not running.

This commit is contained in:
Holger Hagen 2018-02-22 12:50:45 +01:00 committed by Marcel Lengl
parent e10cc3a0c9
commit 02effb36f3
6 changed files with 33 additions and 72 deletions

View File

@ -44,13 +44,6 @@ public interface WorkbasketService {
Workbasket getWorkbasket(String workbasketKey, String domain)
throws WorkbasketNotFoundException, NotAuthorizedException;
/**
* Get all available Workbaskets without checking any permission.
*
* @return a list containing all Workbasket Summaries
*/
List<WorkbasketSummary> getWorkbaskets();
/**
* Create a new Workbasket.
*

View File

@ -124,27 +124,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
}
}
@Override
public List<WorkbasketSummary> getWorkbaskets() {
LOGGER.debug("entry to getWorkbaskets()");
List<WorkbasketSummary> workbaskets = new ArrayList<>();
try {
taskanaEngine.openConnection();
List<WorkbasketSummaryImpl> workbasketImpls = workbasketMapper.findAll();
for (WorkbasketSummaryImpl workbasketSummaryImpl : workbasketImpls) {
workbaskets.add(workbasketSummaryImpl);
}
return workbaskets;
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = workbaskets.size();
LOGGER.debug("exit from getWorkbaskets(). Returning {} resulting Objects: {} ", numberOfResultObjects,
LoggerUtils.listToString(workbaskets));
}
}
}
@Override
public Workbasket createWorkbasket(Workbasket newWorkbasket)
throws InvalidWorkbasketException {

View File

@ -199,7 +199,8 @@ public interface QueryMapper {
@Select("<script>"
+ "SELECT DISTINCT w.ID, w.KEY, w.NAME, w.DOMAIN, W.TYPE, w.DESCRIPTION, w.OWNER, w.ORG_LEVEL_1, w.ORG_LEVEL_2, w.ORG_LEVEL_3, w.ORG_LEVEL_4 from WORKBASKET w "
+ "<if test='accessId != null'>LEFT OUTER JOIN WORKBASKET_ACCESS_LIST a on w.ID = a.WORKBASKET_ID</if> "
// + "<if test='accessId != null'>LEFT OUTER JOIN WORKBASKET_ACCESS_LIST a on w.ID = a.WORKBASKET_ID</if> "
+ "LEFT OUTER JOIN WORKBASKET_ACCESS_LIST a on w.ID = a.WORKBASKET_ID "
+ "<where>"
+ "<if test='ownerIn != null'>AND w.OWNER IN(<foreach item='item' collection='ownerIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='ownerLike != null'>AND (<foreach item='item' collection='ownerLike' separator=' OR ' >UPPER(w.OWNER) LIKE #{item}</foreach>)</if> "
@ -233,7 +234,6 @@ public interface QueryMapper {
+ "<if test='orgLevel4Like != null'>AND (<foreach item='item' collection='orgLevel4Like' separator=' OR ' >UPPER(w.ORG_LEVEL_4) LIKE #{item}</foreach>)</if> "
+ "<if test='authorization != null'>AND "
+ "<if test=\"authorization.name().equals('OPEN')\">PERM_OPEN</if> "
+ "<if test=\"authorization.name().equals('READ')\">PERM_READ</if>"
+ "<if test=\"authorization.name().equals('APPEND')\">PERM_APPEND</if>"
+ "<if test=\"authorization.name().equals('TRANSFER')\">PERM_TRANSFER</if>"
+ "<if test=\"authorization.name().equals('DISTRIBUTE')\">PERM_DISTRIBUTE</if>"
@ -250,6 +250,7 @@ public interface QueryMapper {
+ "<if test=\"authorization.name().equals('CUSTOM_11')\">PERM_CUSTOM_11</if>"
+ "<if test=\"authorization.name().equals('CUSTOM_12')\">PERM_CUSTOM_12</if> = 1 "
+ "</if>"
+ "AND a.PERM_READ = 1"
+ "</where>"
+ "<if test='!orderBy.isEmpty()'>ORDER BY <foreach item='orderItem' collection='orderBy' separator=',' >${orderItem}</foreach></if> "
+ "</script>")
@ -419,7 +420,8 @@ public interface QueryMapper {
@Select("<script>"
+ "SELECT COUNT(ID) from WORKBASKET w "
+ "<if test='accessId != null'>LEFT OUTER JOIN WORKBASKET_ACCESS_LIST a on w.ID = a.WORKBASKET_ID</if> "
// + "<if test='accessId != null'>LEFT OUTER JOIN WORKBASKET_ACCESS_LIST a on w.ID = a.WORKBASKET_ID</if> "
+ "LEFT OUTER JOIN WORKBASKET_ACCESS_LIST a on w.ID = a.WORKBASKET_ID "
+ "<where>"
+ "<if test='ownerIn != null'>AND w.OWNER IN(<foreach item='item' collection='ownerIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='ownerLike != null'>AND (<foreach item='item' collection='ownerLike' separator=' OR ' >UPPER(w.OWNER) LIKE #{item}</foreach>)</if> "
@ -453,7 +455,6 @@ public interface QueryMapper {
+ "<if test='orgLevel4Like != null'>AND (<foreach item='item' collection='orgLevel4Like' separator=' OR ' >UPPER(w.ORG_LEVEL_4) LIKE #{item}</foreach>)</if> "
+ "<if test='authorization != null'>AND "
+ "<if test=\"authorization.name().equals('OPEN')\">PERM_OPEN</if> "
+ "<if test=\"authorization.name().equals('READ')\">PERM_READ</if>"
+ "<if test=\"authorization.name().equals('APPEND')\">PERM_APPEND</if>"
+ "<if test=\"authorization.name().equals('TRANSFER')\">PERM_TRANSFER</if>"
+ "<if test=\"authorization.name().equals('DISTRIBUTE')\">PERM_DISTRIBUTE</if>"
@ -470,6 +471,7 @@ public interface QueryMapper {
+ "<if test=\"authorization.name().equals('CUSTOM_11')\">PERM_CUSTOM_11</if>"
+ "<if test=\"authorization.name().equals('CUSTOM_12')\">PERM_CUSTOM_12</if> = 1 "
+ "</if>"
+ "AND PERM_READ = 1"
+ "</where>"
+ "</script>")
Long countQueryWorkbaskets(WorkbasketQueryImpl workbasketQuery);

View File

@ -1,15 +1,17 @@
package acceptance.workbasket;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import acceptance.AbstractAccTest;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketAccessItem;
import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
@ -17,9 +19,10 @@ import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.WorkbasketType;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
/**
* Acceptance test for all "get workbasket" scenarios.
* Acceptance test for all "create workbasket" scenarios.
*/
@RunWith(JAASRunner.class)
public class CreateWorkbasketAccTest extends AbstractAccTest {
@ -28,19 +31,33 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
super();
}
@WithAccessId(
userName = "user_1_2",
groupNames = {"group_1"})
@Test
public void testCreateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
int before = workbasketService.getWorkbaskets().size();
Workbasket workbasket = workbasketService.newWorkbasket("key", "novatec");
Workbasket workbasket = workbasketService.newWorkbasket("NT1234", "DOMAIN_A");
workbasket.setName("Megabasket");
workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company");
workbasketService.createWorkbasket(workbasket);
Assert.assertEquals(before + 1, workbasketService.getWorkbaskets().size());
workbasket = workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem wbai = workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user_1_2");
wbai.setPermRead(true);
workbasketService.createWorkbasketAuthorization(wbai);
int after = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
assertEquals(before + 1, after);
Workbasket createdWorkbasket = workbasketService.getWorkbasket("NT1234", "DOMAIN_A");
assertNotNull(createdWorkbasket);
assertNotNull(createdWorkbasket.getId());
Workbasket createdWorkbasket2 = workbasketService.getWorkbasket(createdWorkbasket.getId());
assertNotNull(createdWorkbasket);
assertEquals(createdWorkbasket, createdWorkbasket2);
}
@Test

View File

@ -91,23 +91,10 @@ public class WorkbasketServiceImplIntAutocommitTest {
now = Instant.now();
}
@Test
public void testInsertWorkbasket()
throws NotAuthorizedException, InvalidWorkbasketException, WorkbasketNotFoundException {
int before = workBasketService.getWorkbaskets().size();
WorkbasketImpl workbasket = (WorkbasketImpl) workBasketService.newWorkbasket("key", "novatec");
String id1 = IdGenerator.generateWithPrefix("TWB");
workbasket.setId(id1);
workbasket.setName("Megabasket");
workbasket.setType(WorkbasketType.GROUP);
workBasketService.createWorkbasket(workbasket);
Assert.assertEquals(before + 1, workBasketService.getWorkbaskets().size());
}
@Test
public void testSelectAllWorkbaskets()
throws NotAuthorizedException, InvalidWorkbasketException, WorkbasketNotFoundException {
int before = workBasketService.getWorkbaskets().size();
int before = workBasketService.createWorkbasketQuery().list().size();
WorkbasketImpl workbasket0 = (WorkbasketImpl) workBasketService.newWorkbasket("key0", "novatec");
String id0 = IdGenerator.generateWithPrefix("TWB");
workbasket0.setId(id0);
@ -126,7 +113,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
workbasket2.setName("Hyperbasket");
workbasket2.setType(WorkbasketType.GROUP);
workBasketService.createWorkbasket(workbasket2);
Assert.assertEquals(before + THREE, workBasketService.getWorkbaskets().size());
Assert.assertEquals(before + THREE, workBasketService.createWorkbasketQuery().list().size());
}
@WithAccessId(userName = "Elena")

View File

@ -74,30 +74,13 @@ public class WorkbasketServiceImplIntExplicitTest {
cleaner.clearDb(dataSource, false);
}
@Test
public void testInsertWorkbasket()
throws NotAuthorizedException, SQLException, InvalidWorkbasketException, WorkbasketNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
workBasketService = taskanaEngine.getWorkbasketService();
int before = workBasketService.getWorkbaskets().size();
WorkbasketImpl workbasket = (WorkbasketImpl) workBasketService.newWorkbasket("key", "novatec");
String id1 = IdGenerator.generateWithPrefix("TWB");
workbasket.setId(id1);
workbasket.setName("Megabasket");
workbasket.setType(WorkbasketType.GROUP);
workBasketService.createWorkbasket(workbasket);
Assert.assertEquals(before + 1, workBasketService.getWorkbaskets().size());
taskanaEngineImpl.closeConnection();
}
@Test
public void testSelectAllWorkbaskets()
throws NotAuthorizedException, SQLException, InvalidWorkbasketException, WorkbasketNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
workBasketService = taskanaEngine.getWorkbasketService();
int before = workBasketService.getWorkbaskets().size();
int before = workBasketService.createWorkbasketQuery().list().size();
WorkbasketImpl workbasket0 = (WorkbasketImpl) workBasketService.newWorkbasket("key0", "novatec");
String id0 = IdGenerator.generateWithPrefix("TWB");
workbasket0.setId(id0);
@ -116,7 +99,7 @@ public class WorkbasketServiceImplIntExplicitTest {
workbasket2.setName("Hyperbasket");
workbasket2.setType(WorkbasketType.GROUP);
workBasketService.createWorkbasket(workbasket2);
Assert.assertEquals(before + THREE, workBasketService.getWorkbaskets().size());
Assert.assertEquals(before + THREE, workBasketService.createWorkbasketQuery().list().size());
connection.commit();
taskanaEngineImpl.closeConnection();
}