TSK-597: fixed validation of parent id and key for classifications during creation.
This commit is contained in:
parent
b84ee12f45
commit
104d5ed60e
|
@ -82,15 +82,13 @@ public interface ClassificationService {
|
||||||
* when the classification does already exists at the given domain.
|
* when the classification does already exists at the given domain.
|
||||||
* @throws NotAuthorizedException
|
* @throws NotAuthorizedException
|
||||||
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
|
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
|
||||||
* @throws ClassificationNotFoundException
|
|
||||||
* if the current parentId is not NULL/EMPTY and can not be found.
|
|
||||||
* @throws DomainNotFoundException
|
* @throws DomainNotFoundException
|
||||||
* if the domain does not exist in the configuration
|
* if the domain does not exist in the configuration
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
* if the ServiceLevel property does not comply with the ISO 8601 specification
|
* if the ServiceLevel property does not comply with the ISO 8601 specification
|
||||||
*/
|
*/
|
||||||
Classification createClassification(Classification classification)
|
Classification createClassification(Classification classification)
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException,
|
||||||
DomainNotFoundException, InvalidArgumentException;
|
DomainNotFoundException, InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class ClassificationServiceImpl implements ClassificationService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Classification createClassification(Classification classification)
|
public Classification createClassification(Classification classification)
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
LOGGER.debug("entry to createClassification(classification = {})", classification);
|
LOGGER.debug("entry to createClassification(classification = {})", classification);
|
||||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||||
|
@ -76,12 +76,8 @@ public class ClassificationServiceImpl implements ClassificationService {
|
||||||
classificationImpl.setModified(classificationImpl.getCreated());
|
classificationImpl.setModified(classificationImpl.getCreated());
|
||||||
this.initDefaultClassificationValues(classificationImpl);
|
this.initDefaultClassificationValues(classificationImpl);
|
||||||
|
|
||||||
if (classificationImpl.getParentId() != null && !classificationImpl.getParentId().isEmpty()) {
|
validateAndPopulateParentInformation(classificationImpl);
|
||||||
this.getClassification(classificationImpl.getParentId());
|
|
||||||
}
|
|
||||||
if (classificationImpl.getParentKey() != null && !classificationImpl.getParentKey().isEmpty()) {
|
|
||||||
this.getClassification(classificationImpl.getParentKey(), classificationImpl.getDomain());
|
|
||||||
}
|
|
||||||
classificationMapper.insert(classificationImpl);
|
classificationMapper.insert(classificationImpl);
|
||||||
LOGGER.debug("Method createClassification created classification {}.", classificationImpl);
|
LOGGER.debug("Method createClassification created classification {}.", classificationImpl);
|
||||||
|
|
||||||
|
@ -95,6 +91,32 @@ public class ClassificationServiceImpl implements ClassificationService {
|
||||||
return classificationImpl;
|
return classificationImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateAndPopulateParentInformation(ClassificationImpl classificationImpl)
|
||||||
|
throws InvalidArgumentException {
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (classificationImpl.getParentId() != null && !classificationImpl.getParentId().isEmpty()) {
|
||||||
|
Classification parentClassification = this.getClassification(classificationImpl.getParentId());
|
||||||
|
if (classificationImpl.getParentKey() != null && !classificationImpl.getParentKey().isEmpty()) {
|
||||||
|
if (!classificationImpl.getParentKey().equals(parentClassification.getKey())) {
|
||||||
|
throw new InvalidArgumentException(
|
||||||
|
"Given parent key of classification does not match key of parent id.");
|
||||||
|
}
|
||||||
|
classificationImpl.setParentKey(parentClassification.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (classificationImpl.getParentKey() != null && !classificationImpl.getParentKey().isEmpty()) {
|
||||||
|
Classification parentClassification = this.getClassification(classificationImpl.getParentKey(),
|
||||||
|
classificationImpl.getDomain());
|
||||||
|
classificationImpl.setParentId(parentClassification.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ClassificationNotFoundException e) {
|
||||||
|
throw new InvalidArgumentException("Parent classification could not be found.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void checkClassificationId(ClassificationImpl classificationImpl) throws InvalidArgumentException {
|
private void checkClassificationId(ClassificationImpl classificationImpl) throws InvalidArgumentException {
|
||||||
if (classificationImpl.getId() != null && !"".equals(classificationImpl.getId())) {
|
if (classificationImpl.getId() != null && !"".equals(classificationImpl.getId())) {
|
||||||
throw new InvalidArgumentException("ClassificationId should be null on creation");
|
throw new InvalidArgumentException("ClassificationId should be null on creation");
|
||||||
|
|
|
@ -101,8 +101,7 @@ public class CreateClassificationAccTest extends AbstractAccTest {
|
||||||
groupNames = {"group_1", "businessadmin"})
|
groupNames = {"group_1", "businessadmin"})
|
||||||
@Test
|
@Test
|
||||||
public void testCreateClassificationWithInvalidValues()
|
public void testCreateClassificationWithInvalidValues()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException {
|
||||||
DomainNotFoundException {
|
|
||||||
long amountOfClassificationsBefore = classificationService.createClassificationQuery().count();
|
long amountOfClassificationsBefore = classificationService.createClassificationQuery().count();
|
||||||
|
|
||||||
// Check key NULL
|
// Check key NULL
|
||||||
|
@ -128,8 +127,8 @@ public class CreateClassificationAccTest extends AbstractAccTest {
|
||||||
groupNames = {"group_1", "businessadmin"})
|
groupNames = {"group_1", "businessadmin"})
|
||||||
@Test(expected = ClassificationAlreadyExistException.class)
|
@Test(expected = ClassificationAlreadyExistException.class)
|
||||||
public void testCreateClassificationAlreadyExisting()
|
public void testCreateClassificationAlreadyExisting()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
Classification classification = classificationService.newClassification("Key3", "", "TASK");
|
Classification classification = classificationService.newClassification("Key3", "", "TASK");
|
||||||
classification = classificationService.createClassification(classification);
|
classification = classificationService.createClassification(classification);
|
||||||
classification = classificationService.createClassification(classification);
|
classification = classificationService.createClassification(classification);
|
||||||
|
@ -140,8 +139,8 @@ public class CreateClassificationAccTest extends AbstractAccTest {
|
||||||
groupNames = {"group_1", "businessadmin"})
|
groupNames = {"group_1", "businessadmin"})
|
||||||
@Test(expected = DomainNotFoundException.class)
|
@Test(expected = DomainNotFoundException.class)
|
||||||
public void testCreateClassificationInUnknownDomain()
|
public void testCreateClassificationInUnknownDomain()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
Classification classification = classificationService.newClassification("Key3", "UNKNOWN_DOMAIN", "TASK");
|
Classification classification = classificationService.newClassification("Key3", "UNKNOWN_DOMAIN", "TASK");
|
||||||
classification = classificationService.createClassification(classification);
|
classification = classificationService.createClassification(classification);
|
||||||
}
|
}
|
||||||
|
@ -151,8 +150,8 @@ public class CreateClassificationAccTest extends AbstractAccTest {
|
||||||
groupNames = {"group_1", "businessadmin"})
|
groupNames = {"group_1", "businessadmin"})
|
||||||
@Test(expected = InvalidArgumentException.class)
|
@Test(expected = InvalidArgumentException.class)
|
||||||
public void testCreateClassificationOfUnknownType()
|
public void testCreateClassificationOfUnknownType()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
Classification classification = classificationService.newClassification("Key3", "DOMAIN_A", "UNKNOWN_TYPE");
|
Classification classification = classificationService.newClassification("Key3", "DOMAIN_A", "UNKNOWN_TYPE");
|
||||||
classification = classificationService.createClassification(classification);
|
classification = classificationService.createClassification(classification);
|
||||||
}
|
}
|
||||||
|
@ -162,8 +161,8 @@ public class CreateClassificationAccTest extends AbstractAccTest {
|
||||||
groupNames = {"group_1", "businessadmin"})
|
groupNames = {"group_1", "businessadmin"})
|
||||||
@Test(expected = InvalidArgumentException.class)
|
@Test(expected = InvalidArgumentException.class)
|
||||||
public void testCreateClassificationOfUnknownCategory()
|
public void testCreateClassificationOfUnknownCategory()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
Classification classification = classificationService.newClassification("Key4", "DOMAIN_A", "TASK");
|
Classification classification = classificationService.newClassification("Key4", "DOMAIN_A", "TASK");
|
||||||
classification.setCategory("UNKNOWN_CATEGORY");
|
classification.setCategory("UNKNOWN_CATEGORY");
|
||||||
classification = classificationService.createClassification(classification);
|
classification = classificationService.createClassification(classification);
|
||||||
|
@ -172,10 +171,10 @@ public class CreateClassificationAccTest extends AbstractAccTest {
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "teamlead_1",
|
userName = "teamlead_1",
|
||||||
groupNames = {"group_1", "businessadmin"})
|
groupNames = {"group_1", "businessadmin"})
|
||||||
@Test(expected = ClassificationNotFoundException.class)
|
@Test(expected = InvalidArgumentException.class)
|
||||||
public void testCreateClassificationWithInvalidParentId()
|
public void testCreateClassificationWithInvalidParentId()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
Classification classification = classificationService.newClassification("Key5", "", "TASK");
|
Classification classification = classificationService.newClassification("Key5", "", "TASK");
|
||||||
classification.setParentId("ID WHICH CANT BE FOUND");
|
classification.setParentId("ID WHICH CANT BE FOUND");
|
||||||
classification = classificationService.createClassification(classification);
|
classification = classificationService.createClassification(classification);
|
||||||
|
@ -184,10 +183,10 @@ public class CreateClassificationAccTest extends AbstractAccTest {
|
||||||
@WithAccessId(
|
@WithAccessId(
|
||||||
userName = "teamlead_1",
|
userName = "teamlead_1",
|
||||||
groupNames = {"group_1", "businessadmin"})
|
groupNames = {"group_1", "businessadmin"})
|
||||||
@Test(expected = ClassificationNotFoundException.class)
|
@Test(expected = InvalidArgumentException.class)
|
||||||
public void testCreateClassificationWithInvalidParentKey()
|
public void testCreateClassificationWithInvalidParentKey()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
Classification classification = classificationService.newClassification("Key5", "", "TASK");
|
Classification classification = classificationService.newClassification("Key5", "", "TASK");
|
||||||
classification.setParentKey("KEY WHICH CANT BE FOUND");
|
classification.setParentKey("KEY WHICH CANT BE FOUND");
|
||||||
classification = classificationService.createClassification(classification);
|
classification = classificationService.createClassification(classification);
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ClassificationServiceImplTest {
|
||||||
|
|
||||||
@Test(expected = ClassificationAlreadyExistException.class)
|
@Test(expected = ClassificationAlreadyExistException.class)
|
||||||
public void testCreateClassificationAlreadyExisting()
|
public void testCreateClassificationAlreadyExisting()
|
||||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
Classification classification = createDummyClassification();
|
Classification classification = createDummyClassification();
|
||||||
doReturn(classification).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(),
|
doReturn(classification).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(),
|
||||||
|
@ -84,7 +84,7 @@ public class ClassificationServiceImplTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = ClassificationNotFoundException.class)
|
@Test(expected = InvalidArgumentException.class)
|
||||||
public void testCreateClassificationParentIdNotExisting()
|
public void testCreateClassificationParentIdNotExisting()
|
||||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException,
|
throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
|
@ -97,7 +97,7 @@ public class ClassificationServiceImplTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cutSpy.createClassification(classification);
|
cutSpy.createClassification(classification);
|
||||||
} catch (ClassificationNotFoundException e) {
|
} catch (InvalidArgumentException e) {
|
||||||
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
||||||
verify(taskanaEngineImplMock, times(2)).openConnection();
|
verify(taskanaEngineImplMock, times(2)).openConnection();
|
||||||
verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(),
|
verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(),
|
||||||
|
@ -111,7 +111,7 @@ public class ClassificationServiceImplTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = ClassificationNotFoundException.class)
|
@Test(expected = InvalidArgumentException.class)
|
||||||
public void testCreateClassificationParentKeyNotExisting()
|
public void testCreateClassificationParentKeyNotExisting()
|
||||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException,
|
throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
|
@ -125,7 +125,7 @@ public class ClassificationServiceImplTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cutSpy.createClassification(classification);
|
cutSpy.createClassification(classification);
|
||||||
} catch (ClassificationNotFoundException e) {
|
} catch (InvalidArgumentException e) {
|
||||||
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
||||||
verify(taskanaEngineImplMock, times(2)).openConnection();
|
verify(taskanaEngineImplMock, times(2)).openConnection();
|
||||||
verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(),
|
verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(),
|
||||||
|
@ -143,7 +143,7 @@ public class ClassificationServiceImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateClassificationInOwnDomainButExistingInRoot()
|
public void testCreateClassificationInOwnDomainButExistingInRoot()
|
||||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException, InterruptedException,
|
throws ClassificationAlreadyExistException, InterruptedException,
|
||||||
NotAuthorizedException, DomainNotFoundException, InvalidArgumentException {
|
NotAuthorizedException, DomainNotFoundException, InvalidArgumentException {
|
||||||
Instant beforeTimestamp = Instant.now();
|
Instant beforeTimestamp = Instant.now();
|
||||||
Thread.sleep(10L);
|
Thread.sleep(10L);
|
||||||
|
@ -176,8 +176,8 @@ public class ClassificationServiceImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateClassificationInOwnDomainAndCopyInRootDomain()
|
public void testCreateClassificationInOwnDomainAndCopyInRootDomain()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
Classification classification = createDummyClassification("");
|
Classification classification = createDummyClassification("");
|
||||||
String domain = classification.getDomain();
|
String domain = classification.getDomain();
|
||||||
String key = classification.getKey();
|
String key = classification.getKey();
|
||||||
|
@ -203,7 +203,7 @@ public class ClassificationServiceImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateClassificationIntoRootDomain()
|
public void testCreateClassificationIntoRootDomain()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
ClassificationImpl classification = (ClassificationImpl) createDummyClassification(null);
|
ClassificationImpl classification = (ClassificationImpl) createDummyClassification(null);
|
||||||
classification.setDomain("");
|
classification.setDomain("");
|
||||||
|
@ -364,7 +364,7 @@ public class ClassificationServiceImplTest {
|
||||||
|
|
||||||
@Test(expected = InvalidArgumentException.class)
|
@Test(expected = InvalidArgumentException.class)
|
||||||
public void testThrowExceptionIdIfClassificationIsCreatedWithAnExplicitId()
|
public void testThrowExceptionIdIfClassificationIsCreatedWithAnExplicitId()
|
||||||
throws ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException,
|
throws DomainNotFoundException, InvalidArgumentException,
|
||||||
NotAuthorizedException, ClassificationAlreadyExistException {
|
NotAuthorizedException, ClassificationAlreadyExistException {
|
||||||
try {
|
try {
|
||||||
Classification classification = createDummyClassification();
|
Classification classification = createDummyClassification();
|
||||||
|
|
|
@ -153,8 +153,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindAllClassifications()
|
public void testFindAllClassifications()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
Classification classification0 = this.createDummyClassificationWithUniqueKey("", "TASK");
|
Classification classification0 = this.createDummyClassificationWithUniqueKey("", "TASK");
|
||||||
classificationService.createClassification(classification0);
|
classificationService.createClassification(classification0);
|
||||||
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "TASK");
|
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "TASK");
|
||||||
|
@ -183,8 +183,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertAndClassificationMapper()
|
public void testInsertAndClassificationMapper()
|
||||||
throws NotAuthorizedException, ClassificationAlreadyExistException, ClassificationNotFoundException,
|
throws NotAuthorizedException, ClassificationAlreadyExistException, InvalidArgumentException,
|
||||||
InvalidArgumentException, DomainNotFoundException {
|
DomainNotFoundException {
|
||||||
Classification classification = this.createDummyClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
Classification classification = this.createDummyClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
||||||
classification = classificationService.createClassification(classification);
|
classification = classificationService.createClassification(classification);
|
||||||
|
|
||||||
|
@ -221,8 +221,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindWithClassificationMapperDomainAndCategory()
|
public void testFindWithClassificationMapperDomainAndCategory()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
Classification classification1 = this.createDummyClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
Classification classification1 = this.createDummyClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
||||||
classification1.setCategory("EXTERNAL");
|
classification1.setCategory("EXTERNAL");
|
||||||
classificationService.createClassification(classification1);
|
classificationService.createClassification(classification1);
|
||||||
|
@ -244,8 +244,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindWithClassificationMapperCustomAndCategory()
|
public void testFindWithClassificationMapperCustomAndCategory()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "TASK");
|
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "TASK");
|
||||||
classification1.setDescription("DESC1");
|
classification1.setDescription("DESC1");
|
||||||
classification1.setCategory("EXTERNAL");
|
classification1.setCategory("EXTERNAL");
|
||||||
|
@ -283,7 +283,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testFindWithClassificationMapperPriorityTypeAndParent()
|
public void testFindWithClassificationMapperPriorityTypeAndParent()
|
||||||
throws ClassificationAlreadyExistException, NumberFormatException, NotAuthorizedException,
|
throws ClassificationAlreadyExistException, NumberFormatException, NotAuthorizedException,
|
||||||
ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
Classification classification = this.createDummyClassificationWithUniqueKey("", "TASK");
|
Classification classification = this.createDummyClassificationWithUniqueKey("", "TASK");
|
||||||
classification.setPriority(Integer.decode("5"));
|
classification.setPriority(Integer.decode("5"));
|
||||||
classificationService.createClassification(classification);
|
classificationService.createClassification(classification);
|
||||||
|
@ -317,8 +317,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindWithClassificationMapperServiceLevelNameAndDescription()
|
public void testFindWithClassificationMapperServiceLevelNameAndDescription()
|
||||||
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
|
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
|
||||||
DomainNotFoundException, InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
int all = 0;
|
int all = 0;
|
||||||
Classification classification = this.createDummyClassificationWithUniqueKey("", "TASK");
|
Classification classification = this.createDummyClassificationWithUniqueKey("", "TASK");
|
||||||
classification.setServiceLevel("P1D");
|
classification.setServiceLevel("P1D");
|
||||||
|
|
|
@ -166,7 +166,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testFindAllClassifications()
|
public void testFindAllClassifications()
|
||||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
||||||
ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
Connection connection = dataSource.getConnection();
|
Connection connection = dataSource.getConnection();
|
||||||
taskanaEngineImpl.setConnection(connection);
|
taskanaEngineImpl.setConnection(connection);
|
||||||
Classification classification0 = this.createNewClassificationWithUniqueKey("", "TASK");
|
Classification classification0 = this.createNewClassificationWithUniqueKey("", "TASK");
|
||||||
|
@ -204,7 +204,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testInsertAndClassificationQuery()
|
public void testInsertAndClassificationQuery()
|
||||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
||||||
ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
Connection connection = dataSource.getConnection();
|
Connection connection = dataSource.getConnection();
|
||||||
taskanaEngineImpl.setConnection(connection);
|
taskanaEngineImpl.setConnection(connection);
|
||||||
Classification classification = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
Classification classification = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
||||||
|
@ -249,7 +249,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testFindWithClassificationMapperDomainAndCategory()
|
public void testFindWithClassificationMapperDomainAndCategory()
|
||||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
||||||
ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
Connection connection = dataSource.getConnection();
|
Connection connection = dataSource.getConnection();
|
||||||
taskanaEngineImpl.setConnection(connection);
|
taskanaEngineImpl.setConnection(connection);
|
||||||
Classification classification1 = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
Classification classification1 = this.createNewClassificationWithUniqueKey("DOMAIN_A", "TASK");
|
||||||
|
@ -276,7 +276,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testFindWithClassificationMapperCustomAndCategory()
|
public void testFindWithClassificationMapperCustomAndCategory()
|
||||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
||||||
ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
Connection connection = dataSource.getConnection();
|
Connection connection = dataSource.getConnection();
|
||||||
taskanaEngineImpl.setConnection(connection);
|
taskanaEngineImpl.setConnection(connection);
|
||||||
Classification classification1 = this.createNewClassificationWithUniqueKey("", "TASK");
|
Classification classification1 = this.createNewClassificationWithUniqueKey("", "TASK");
|
||||||
|
@ -317,7 +317,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testFindWithClassificationMapperPriorityTypeAndParent()
|
public void testFindWithClassificationMapperPriorityTypeAndParent()
|
||||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException,
|
||||||
ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
Connection connection = dataSource.getConnection();
|
Connection connection = dataSource.getConnection();
|
||||||
taskanaEngineImpl.setConnection(connection);
|
taskanaEngineImpl.setConnection(connection);
|
||||||
Classification classification = this.createNewClassificationWithUniqueKey("", "TASK");
|
Classification classification = this.createNewClassificationWithUniqueKey("", "TASK");
|
||||||
|
@ -354,7 +354,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testFindWithClassificationMapperServiceLevelNameAndDescription()
|
public void testFindWithClassificationMapperServiceLevelNameAndDescription()
|
||||||
throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException,
|
throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException,
|
||||||
ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
|
DomainNotFoundException, InvalidArgumentException {
|
||||||
Connection connection = dataSource.getConnection();
|
Connection connection = dataSource.getConnection();
|
||||||
taskanaEngineImpl.setConnection(connection);
|
taskanaEngineImpl.setConnection(connection);
|
||||||
int all = 0;
|
int all = 0;
|
||||||
|
|
|
@ -459,8 +459,8 @@ public class TaskServiceImplIntExplicitTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task generateDummyTask() throws ClassificationAlreadyExistException, ClassificationNotFoundException,
|
private Task generateDummyTask()
|
||||||
InvalidWorkbasketException, NotAuthorizedException,
|
throws ClassificationAlreadyExistException, InvalidWorkbasketException, NotAuthorizedException,
|
||||||
WorkbasketAlreadyExistException, DomainNotFoundException, InvalidArgumentException {
|
WorkbasketAlreadyExistException, DomainNotFoundException, InvalidArgumentException {
|
||||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("wb", "DOMAIN_A");
|
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("wb", "DOMAIN_A");
|
||||||
workbasket.setName("wb");
|
workbasket.setName("wb");
|
||||||
|
|
|
@ -183,6 +183,57 @@ public class ClassificationControllerIntTest {
|
||||||
con.disconnect();
|
con.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateClassificationWithParentId() throws IOException {
|
||||||
|
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P1\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\"}";
|
||||||
|
URL url = new URL(server + port + "/v1/classifications");
|
||||||
|
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
|
con.setRequestMethod("POST");
|
||||||
|
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
|
||||||
|
out.write(newClassification);
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
assertEquals(201, con.getResponseCode());
|
||||||
|
con.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateClassificationWithParentKey() throws IOException {
|
||||||
|
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentKey\":\"T2100\"}";
|
||||||
|
URL url = new URL(server + port + "/v1/classifications");
|
||||||
|
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
|
con.setRequestMethod("POST");
|
||||||
|
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
|
||||||
|
out.write(newClassification);
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
assertEquals(201, con.getResponseCode());
|
||||||
|
con.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReturn400IfCreateClassificationWithIncompatibleParentIdAndKey() throws IOException {
|
||||||
|
String newClassification = "{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P3\",\"name\":\"new classification\",\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\",\"parentKey\":\"T2000\"}";
|
||||||
|
URL url = new URL(server + port + "/v1/classifications");
|
||||||
|
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
|
con.setRequestMethod("POST");
|
||||||
|
con.setRequestProperty("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
|
||||||
|
out.write(newClassification);
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
assertEquals(400, con.getResponseCode());
|
||||||
|
con.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateClassificationWithClassificationIdReturnsError400() throws IOException {
|
public void testCreateClassificationWithClassificationIdReturnsError400() throws IOException {
|
||||||
String newClassification = "{\"classificationId\":\"someId\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\",\"name\":\"new classification\",\"type\":\"TASK\"}";
|
String newClassification = "{\"classificationId\":\"someId\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\",\"name\":\"new classification\",\"type\":\"TASK\"}";
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class ClassificationResource extends ResourceSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParentKey() {
|
public String getParentKey() {
|
||||||
return parentId;
|
return parentKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentKey(String parentKey) {
|
public void setParentKey(String parentKey) {
|
||||||
|
|
Loading…
Reference in New Issue