TSK-100: Übergabe an Benni
This commit is contained in:
parent
fdf21365f9
commit
4cdc2508e7
|
@ -13,26 +13,34 @@ public interface Classification {
|
|||
String getId();
|
||||
|
||||
/**
|
||||
* Set/Change the classification-ID. Only ID+Domain need to be unique.
|
||||
* @param id TODO
|
||||
* @return externally known key to the classification like a code or abbreviation.
|
||||
*/
|
||||
void setId(String id);
|
||||
String getKey();
|
||||
|
||||
/**
|
||||
* Used to get the ID of the parent classification.
|
||||
* There will be no value if the current classification is
|
||||
* a parent-classification.
|
||||
* Set/Change the classification key.
|
||||
*
|
||||
* @param key
|
||||
* The key of the classification.
|
||||
*/
|
||||
void setKey(String key);
|
||||
|
||||
/**
|
||||
* Used to get the ID of the parent classification. There will be no value if the current classification is a
|
||||
* parent-classification.
|
||||
*
|
||||
* @return unique ID or null if parent itself.
|
||||
*/
|
||||
String getParentClassificationId();
|
||||
String getParentClassificationKey();
|
||||
|
||||
/**
|
||||
* Set/Change a reference to the current parent classification via ID.
|
||||
* If this field would be set to NULL the classification will become
|
||||
* a parent-classification itself.
|
||||
* @param parentClassificationId TODO
|
||||
* Set/Change a reference to the current parent classification via ID. If this field would be set to NULL the
|
||||
* classification will become a parent-classification itself.
|
||||
*
|
||||
* @param parentClassificationId
|
||||
* TODO
|
||||
*/
|
||||
void setParentClassificationId(String parentClassificationId);
|
||||
void setParentClassificationKey(String parentClassificationKey);
|
||||
|
||||
/**
|
||||
* @return category of this classification.
|
||||
|
@ -41,208 +49,266 @@ public interface Classification {
|
|||
|
||||
/**
|
||||
* Set/Change the category of this classification.
|
||||
* @param category TODO
|
||||
*
|
||||
* @param category
|
||||
* TODO
|
||||
*/
|
||||
void setCategory(String category);
|
||||
|
||||
/**
|
||||
* Get the type of the current classification.
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
String getType();
|
||||
|
||||
/**
|
||||
* Set/Change the current type of the classification.
|
||||
* @param type TODO
|
||||
*
|
||||
* @param type
|
||||
* TODO
|
||||
*/
|
||||
void setType(String type);
|
||||
|
||||
/**
|
||||
* Get the current domain-name of this
|
||||
* classification.
|
||||
* Get the current domain-name of this classification.
|
||||
*
|
||||
* @return domain name
|
||||
*/
|
||||
String getDomain();
|
||||
|
||||
/**
|
||||
* Set/Change the domain of this classification.
|
||||
* @param domain name
|
||||
*
|
||||
* @param domain
|
||||
* name
|
||||
*/
|
||||
void setDomain(String domain);
|
||||
|
||||
/**
|
||||
* Get a flag if the classification if currently valid
|
||||
* in the used domain.
|
||||
* Get a flag if the classification if currently valid in the used domain.
|
||||
*
|
||||
* @return isValidInDomain - flag
|
||||
*/
|
||||
Boolean getIsValidInDomain();
|
||||
|
||||
/**
|
||||
* Set/Change the flag which marks the classification as
|
||||
* valid/invalid in the currently used domain.
|
||||
* @param isValidInDomain - flag
|
||||
* Set/Change the flag which marks the classification as valid/invalid in the currently used domain.
|
||||
*
|
||||
* @param isValidInDomain
|
||||
* - flag
|
||||
*/
|
||||
void setIsValidInDomain(Boolean isValidInDomain);
|
||||
|
||||
/**
|
||||
* Get the Date when this classification was as created.
|
||||
*
|
||||
* @return created as date
|
||||
*/
|
||||
Date getCreated();
|
||||
|
||||
/**
|
||||
* Get the classification name.
|
||||
*
|
||||
* @return name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Set/Change the classification name.
|
||||
* @param name TODO
|
||||
*
|
||||
* @param name
|
||||
* TODO
|
||||
*/
|
||||
void setName(String name);
|
||||
|
||||
/**
|
||||
* Get the description of a classification.
|
||||
*
|
||||
* @return description
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Set/Change the classification description.
|
||||
* @param description TODO
|
||||
*
|
||||
* @param description
|
||||
* TODO
|
||||
*/
|
||||
void setDescription(String description);
|
||||
|
||||
/**
|
||||
* Get the current classification priority (numeric).
|
||||
*
|
||||
* @return priority
|
||||
*/
|
||||
int getPriority();
|
||||
|
||||
/**
|
||||
* Set/Change the numeric priority of a classification.
|
||||
* @param priority TODO
|
||||
*
|
||||
* @param priority
|
||||
* TODO
|
||||
*/
|
||||
void setPriority(int priority);
|
||||
|
||||
/**
|
||||
* Get the current service level.
|
||||
*
|
||||
* @return serviceLevel
|
||||
*/
|
||||
String getServiceLevel();
|
||||
|
||||
/**
|
||||
* Set/Change the security level.
|
||||
* @param serviceLevel TODO
|
||||
*
|
||||
* @param serviceLevel
|
||||
* TODO
|
||||
*/
|
||||
void setServiceLevel(String serviceLevel);
|
||||
|
||||
/**
|
||||
* Get the logical name of the associated application entry point.
|
||||
*
|
||||
* @return applicationEntryPoint
|
||||
*/
|
||||
String getApplicationEntryPoint();
|
||||
|
||||
/**
|
||||
* Set the logical name of the associated application entry point.
|
||||
*/
|
||||
void setApplicationEntryPoint(String applicationEntryPoint);
|
||||
|
||||
/**
|
||||
* Get the 1. custom-attribute.
|
||||
*
|
||||
* @return custom1
|
||||
*/
|
||||
String getCustom1();
|
||||
|
||||
/**
|
||||
* Set/Change the 1. custom-attribute.
|
||||
* @param custom1 TODO
|
||||
*
|
||||
* @param custom1
|
||||
* TODO
|
||||
*/
|
||||
void setCustom1(String custom1);
|
||||
|
||||
/**
|
||||
* Get the 2. custom-attribute.
|
||||
*
|
||||
* @return custom2
|
||||
*/
|
||||
String getCustom2();
|
||||
|
||||
/**
|
||||
* Set/Change the 2. custom-attribute.
|
||||
* @param custom2 TODO
|
||||
*
|
||||
* @param custom2
|
||||
* TODO
|
||||
*/
|
||||
void setCustom2(String custom2);
|
||||
|
||||
/**
|
||||
* Get the 3. custom-attribute.
|
||||
*
|
||||
* @return custom3
|
||||
*/
|
||||
String getCustom3();
|
||||
|
||||
/**
|
||||
* Set/Change the 3. custom-attribute.
|
||||
* @param custom3 TODO
|
||||
*
|
||||
* @param custom3
|
||||
* TODO
|
||||
*/
|
||||
void setCustom3(String custom3);
|
||||
|
||||
/**
|
||||
* Get the 4. custom-attribute.
|
||||
*
|
||||
* @return custom4
|
||||
*/
|
||||
String getCustom4();
|
||||
|
||||
/**
|
||||
* Set/Change the 4. custom-attribute.
|
||||
* @param custom4 TODO
|
||||
*
|
||||
* @param custom4
|
||||
* TODO
|
||||
*/
|
||||
void setCustom4(String custom4);
|
||||
|
||||
/**
|
||||
* Get the 5. custom-attribute.
|
||||
*
|
||||
* @return custom5
|
||||
*/
|
||||
String getCustom5();
|
||||
|
||||
/**
|
||||
* Set/Change the 5. custom-attribute.
|
||||
* @param custom5 TODO
|
||||
*
|
||||
* @param custom5
|
||||
* TODO
|
||||
*/
|
||||
void setCustom5(String custom5);
|
||||
|
||||
/**
|
||||
* Get the 6. custom-attribute.
|
||||
*
|
||||
* @return custom6
|
||||
*/
|
||||
String getCustom6();
|
||||
|
||||
|
||||
/**
|
||||
* Set/Change the 6. custom-attribute.
|
||||
* @param custom6 TODO
|
||||
*
|
||||
* @param custom6
|
||||
* TODO
|
||||
*/
|
||||
void setCustom6(String custom6);
|
||||
|
||||
/**
|
||||
* Get the 7. custom-attribute.
|
||||
*
|
||||
* @return custom7
|
||||
*/
|
||||
String getCustom7();
|
||||
|
||||
/**
|
||||
* Set/Change the 7. custom-attribute.
|
||||
* @param custom7 TODO
|
||||
*
|
||||
* @param custom7
|
||||
* TODO
|
||||
*/
|
||||
void setCustom7(String custom7);
|
||||
|
||||
/**
|
||||
* Get the 8. custom-attribute.
|
||||
*
|
||||
* @return custom8
|
||||
*/
|
||||
String getCustom8();
|
||||
|
||||
/**
|
||||
* Set/Change the 8. custom-attribute.
|
||||
* @param custom8 TODO
|
||||
*
|
||||
* @param custom8
|
||||
* TODO
|
||||
*/
|
||||
void setCustom8(String custom8);
|
||||
|
||||
/**
|
||||
* Get the sql-date since/when the classification is valid from.
|
||||
*
|
||||
* @return validFrom
|
||||
*/
|
||||
Date getValidFrom();
|
||||
|
||||
/**
|
||||
* Get the sql-date until the classification is valid.
|
||||
*
|
||||
* @return validUntil
|
||||
*/
|
||||
Date getValidUntil();
|
||||
|
|
|
@ -27,9 +27,13 @@ import pro.taskana.model.mappings.ClassificationMapper;
|
|||
public class ClassificationServiceImpl implements ClassificationService {
|
||||
|
||||
private static final String ID_PREFIX_CLASSIFICATION = "CLI";
|
||||
|
||||
public static final Date CURRENT_CLASSIFICATIONS_VALID_UNTIL = Date.valueOf("9999-12-31");
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationServiceImpl.class);
|
||||
|
||||
private ClassificationMapper classificationMapper;
|
||||
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
|
||||
public ClassificationServiceImpl(TaskanaEngine taskanaEngine, ClassificationMapper classificationMapper) {
|
||||
|
@ -45,24 +49,32 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
List<Classification> rootClassifications;
|
||||
rootClassifications = this.createClassificationQuery().parentClassification("").validUntil(CURRENT_CLASSIFICATIONS_VALID_UNTIL).list();
|
||||
rootClassifications = this.createClassificationQuery()
|
||||
.parentClassification("")
|
||||
.validUntil(CURRENT_CLASSIFICATIONS_VALID_UNTIL)
|
||||
.list();
|
||||
rootClassifications = this.populateChildClassifications(rootClassifications);
|
||||
return rootClassifications;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
LOGGER.debug("exit from getClassificationTree(). Returning {} resulting Objects: {} ", numberOfResultObjects, LoggerUtils.listToString(result));
|
||||
LOGGER.debug("exit from getClassificationTree(). Returning {} resulting Objects: {} ",
|
||||
numberOfResultObjects, LoggerUtils.listToString(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Classification> populateChildClassifications(List<Classification> classifications) throws NotAuthorizedException {
|
||||
private List<Classification> populateChildClassifications(List<Classification> classifications)
|
||||
throws NotAuthorizedException {
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
List<Classification> children = new ArrayList<>();
|
||||
for (Classification classification : classifications) {
|
||||
List<Classification> childClassifications = this.createClassificationQuery().parentClassification(classification.getId()).validUntil(CURRENT_CLASSIFICATIONS_VALID_UNTIL).list();
|
||||
List<Classification> childClassifications = this.createClassificationQuery()
|
||||
.parentClassification(classification.getId())
|
||||
.validUntil(CURRENT_CLASSIFICATIONS_VALID_UNTIL)
|
||||
.list();
|
||||
children.addAll(populateChildClassifications(childClassifications));
|
||||
}
|
||||
classifications.addAll(children);
|
||||
|
@ -113,10 +125,12 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
|
||||
ClassificationImpl oldClassification = null;
|
||||
try {
|
||||
oldClassification = (ClassificationImpl) this.getClassification(classificationImpl.getId(), classificationImpl.getDomain());
|
||||
oldClassification = (ClassificationImpl) this.getClassification(classificationImpl.getId(),
|
||||
classificationImpl.getDomain());
|
||||
LOGGER.debug("Method updateClassification() inserted classification {}.", classificationImpl);
|
||||
if (oldClassification == null) {
|
||||
throw new ClassificationNotFoundException("Classification not found. ID: " + classificationImpl.getId());
|
||||
throw new ClassificationNotFoundException(
|
||||
"Classification not found. ID: " + classificationImpl.getId());
|
||||
}
|
||||
// ! If you update an classification twice the same day,
|
||||
// the older version is valid from today until yesterday.
|
||||
|
@ -128,7 +142,8 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
oldClassification.setValidUntil(Date.valueOf(LocalDate.now().minusDays(1)));
|
||||
classificationMapper.update(oldClassification);
|
||||
classificationMapper.insert(classificationImpl);
|
||||
LOGGER.debug("Method updateClassification() updated old classification {} and inserted new {}.", oldClassification, classificationImpl);
|
||||
LOGGER.debug("Method updateClassification() updated old classification {} and inserted new {}.",
|
||||
oldClassification, classificationImpl);
|
||||
}
|
||||
} catch (ClassificationNotFoundException e) {
|
||||
classificationImpl.setId(IdGenerator.generateWithPrefix(ID_PREFIX_CLASSIFICATION));
|
||||
|
@ -162,12 +177,8 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
classification.setId(IdGenerator.generateWithPrefix(ID_PREFIX_CLASSIFICATION));
|
||||
}
|
||||
|
||||
if (classification.getParentClassificationId() == classification.getId()) {
|
||||
throw new IllegalArgumentException("A classification can't be a parent to itself");
|
||||
}
|
||||
|
||||
if (classification.getParentClassificationId() == null) {
|
||||
classification.setParentClassificationId("");
|
||||
if (classification.getParentClassificationKey() == null) {
|
||||
classification.setParentClassificationKey("");
|
||||
}
|
||||
|
||||
if (classification.getDomain() == null) {
|
||||
|
@ -189,7 +200,8 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
taskanaEngineImpl.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
LOGGER.debug("exit from getAllClassificationsWithId(). Returning {} resulting Objects: {} ", numberOfResultObjects, LoggerUtils.listToString(result));
|
||||
LOGGER.debug("exit from getAllClassificationsWithId(). Returning {} resulting Objects: {} ",
|
||||
numberOfResultObjects, LoggerUtils.listToString(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,25 +10,49 @@ import pro.taskana.Classification;
|
|||
public class ClassificationImpl implements Classification {
|
||||
|
||||
private String id;
|
||||
private String parentClassificationId;
|
||||
|
||||
private String key;
|
||||
|
||||
private String parentClassificationKey;
|
||||
|
||||
private String category;
|
||||
|
||||
private String type;
|
||||
|
||||
private String domain;
|
||||
|
||||
private Boolean isValidInDomain;
|
||||
|
||||
private Date created;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private int priority;
|
||||
|
||||
private String serviceLevel; // PddDThhHmmM
|
||||
|
||||
private String applicationEntryPoint;
|
||||
|
||||
private String custom1;
|
||||
|
||||
private String custom2;
|
||||
|
||||
private String custom3;
|
||||
|
||||
private String custom4;
|
||||
|
||||
private String custom5;
|
||||
|
||||
private String custom6;
|
||||
|
||||
private String custom7;
|
||||
|
||||
private String custom8;
|
||||
|
||||
private Date validFrom;
|
||||
|
||||
private Date validUntil;
|
||||
|
||||
@Override
|
||||
|
@ -41,13 +65,22 @@ public class ClassificationImpl implements Classification {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getParentClassificationId() {
|
||||
return parentClassificationId;
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentClassificationId(String parentClassificationId) {
|
||||
this.parentClassificationId = parentClassificationId;
|
||||
public String getParentClassificationKey() {
|
||||
return parentClassificationKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentClassificationKey(String parentClassificationKey) {
|
||||
this.parentClassificationKey = parentClassificationKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -138,6 +171,16 @@ public class ClassificationImpl implements Classification {
|
|||
this.serviceLevel = serviceLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getApplicationEntryPoint() {
|
||||
return applicationEntryPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationEntryPoint(String applicationEntryPoint) {
|
||||
this.applicationEntryPoint = applicationEntryPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustom1() {
|
||||
return custom1;
|
||||
|
@ -242,7 +285,7 @@ public class ClassificationImpl implements Classification {
|
|||
builder.append("Classification [id=");
|
||||
builder.append(id);
|
||||
builder.append(", parentClassificationId=");
|
||||
builder.append(parentClassificationId);
|
||||
builder.append(parentClassificationKey);
|
||||
builder.append(", category=");
|
||||
builder.append(category);
|
||||
builder.append(", type=");
|
||||
|
|
|
@ -19,95 +19,102 @@ public interface ClassificationMapper {
|
|||
|
||||
String VALID_UNTIL = "9999-12-31";
|
||||
|
||||
@Select("SELECT ID, PARENT_CLASSIFICATION_ID, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL "
|
||||
+ "FROM CLASSIFICATION "
|
||||
+ "WHERE ID = #{id}"
|
||||
+ "AND DOMAIN = #{domain}"
|
||||
+ "AND VALID_UNTIL = #{valid_until}")
|
||||
@Results({@Result(property = "id", column = "ID"),
|
||||
@Result(property = "parentClassificationId", column = "PARENT_CLASSIFICATION_ID"),
|
||||
@Result(property = "category", column = "CATEGORY"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "isValidInDomain", column = "VALID_IN_DOMAIN"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "serviceLevel", column = "SERVICE_LEVEL"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "validFrom", column = "VALID_FROM"),
|
||||
@Result(property = "validUntil", column = "VALID_UNTIL")})
|
||||
ClassificationImpl findByIdAndDomain(@Param("id") String id, @Param("domain") String domain, @Param("valid_until")Date validUntil);
|
||||
@Select("SELECT ID, KEY, PARENT_CLASSIFICATION_KEY, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, APPLICATION_ENTRY_POINT, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL "
|
||||
+ "FROM CLASSIFICATION "
|
||||
+ "WHERE ID = #{id}"
|
||||
+ "AND DOMAIN = #{domain}"
|
||||
+ "AND VALID_UNTIL = #{valid_until}")
|
||||
@Results({ @Result(property = "id", column = "ID"),
|
||||
@Result(property = "key", column = "KEY"),
|
||||
@Result(property = "parentClassificationKey", column = "PARENT_CLASSIFICATION_KEY"),
|
||||
@Result(property = "category", column = "CATEGORY"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "isValidInDomain", column = "VALID_IN_DOMAIN"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "serviceLevel", column = "SERVICE_LEVEL"),
|
||||
@Result(property = "applicationEntryPoint", column = "APPLICATION_ENTRY_POINT"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "validFrom", column = "VALID_FROM"),
|
||||
@Result(property = "validUntil", column = "VALID_UNTIL") })
|
||||
ClassificationImpl findByIdAndDomain(@Param("id") String id, @Param("domain") String domain,
|
||||
@Param("valid_until") Date validUntil);
|
||||
|
||||
@Select("SELECT ID, PARENT_CLASSIFICATION_ID, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL "
|
||||
+ "FROM CLASSIFICATION "
|
||||
+ "WHERE ID = #{id} "
|
||||
+ "AND VALID_UNTIL = '" + VALID_UNTIL + "'")
|
||||
@Results({@Result(property = "id", column = "ID"),
|
||||
@Result(property = "parentClassificationId", column = "PARENT_CLASSIFICATION_ID"),
|
||||
@Result(property = "category", column = "CATEGORY"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "isValidInDomain", column = "VALID_IN_DOMAIN"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "serviceLevel", column = "SERVICE_LEVEL"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "validFrom", column = "VALID_FROM"),
|
||||
@Result(property = "validUntil", column = "VALID_UNTIL")})
|
||||
@Select("SELECT ID, KEY, PARENT_CLASSIFICATION_KEY, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, APPLICATION_ENTRY_POINT, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL "
|
||||
+ "FROM CLASSIFICATION "
|
||||
+ "WHERE ID = #{id} "
|
||||
+ "AND VALID_UNTIL = '" + VALID_UNTIL + "'")
|
||||
@Results({ @Result(property = "id", column = "ID"),
|
||||
@Result(property = "key", column = "KEY"),
|
||||
@Result(property = "parentClassificationKey", column = "PARENT_CLASSIFICATION_KEY"),
|
||||
@Result(property = "category", column = "CATEGORY"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "isValidInDomain", column = "VALID_IN_DOMAIN"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "serviceLevel", column = "SERVICE_LEVEL"),
|
||||
@Result(property = "applicationEntryPoint", column = "APPLICATION_ENTRY_POINT"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "validFrom", column = "VALID_FROM"),
|
||||
@Result(property = "validUntil", column = "VALID_UNTIL") })
|
||||
ClassificationImpl findById(@Param("id") String id);
|
||||
|
||||
@Insert("INSERT INTO CLASSIFICATION (ID, PARENT_CLASSIFICATION_ID, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL) VALUES (#{classification.id}, #{classification.parentClassificationId}, #{classification.category}, #{classification.type}, #{classification.domain}, #{classification.isValidInDomain}, #{classification.created}, #{classification.name}, #{classification.description}, #{classification.priority}, #{classification.serviceLevel}, #{classification.custom1}, #{classification.custom2}, #{classification.custom3}, #{classification.custom4}, #{classification.custom5}, #{classification.custom6}, #{classification.custom7}, #{classification.custom8}, #{classification.validFrom}, #{classification.validUntil})")
|
||||
@Insert("INSERT INTO CLASSIFICATION (ID, KEY, PARENT_CLASSIFICATION_KEY, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, APPLICATION_ENTRY_POINT, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL) VALUES (#{classification.id}, #{classification.key}, #{classification.parentClassificationKey}, #{classification.category}, #{classification.type}, #{classification.domain}, #{classification.isValidInDomain}, #{classification.created}, #{classification.name}, #{classification.description}, #{classification.priority}, #{classification.serviceLevel}, #{classification.applicationEntryPoint}, #{classification.custom1}, #{classification.custom2}, #{classification.custom3}, #{classification.custom4}, #{classification.custom5}, #{classification.custom6}, #{classification.custom7}, #{classification.custom8}, #{classification.validFrom}, #{classification.validUntil})")
|
||||
void insert(@Param("classification") ClassificationImpl classification);
|
||||
|
||||
@Update(value = "UPDATE CLASSIFICATION SET PARENT_CLASSIFICATION_ID = #{classification.parentClassificationId}, CATEGORY = #{classification.category}, TYPE = #{classification.type}, NAME = #{classification.name}, DESCRIPTION = #{classification.description}, PRIORITY = #{classification.priority}, SERVICE_LEVEL = #{classification.serviceLevel}, DOMAIN = #{classification.domain}, VALID_IN_DOMAIN = #{classification.isValidInDomain}, CUSTOM_1 = #{classification.custom1}, CUSTOM_2 = #{classification.custom2}, CUSTOM_3 = #{classification.custom3}, CUSTOM_4 = #{classification.custom4}, CUSTOM_5 = #{classification.custom5}, CUSTOM_6 = #{classification.custom6}, CUSTOM_7 = #{classification.custom7}, CUSTOM_8 = #{classification.custom8}, VALID_FROM = #{classification.validFrom}, VALID_UNTIL = #{classification.validUntil} WHERE ID = #{classification.id}")
|
||||
@Update(
|
||||
value = "UPDATE CLASSIFICATION SET KEY = #{classification.key}, PARENT_CLASSIFICATION_KEY = #{classification.parentClassificationKey}, CATEGORY = #{classification.category}, TYPE = #{classification.type}, NAME = #{classification.name}, DESCRIPTION = #{classification.description}, PRIORITY = #{classification.priority}, SERVICE_LEVEL = #{classification.serviceLevel}, APPLICATION_ENTRY_POINT = #{classification.applicationEntryPoint}, DOMAIN = #{classification.domain}, VALID_IN_DOMAIN = #{classification.isValidInDomain}, CUSTOM_1 = #{classification.custom1}, CUSTOM_2 = #{classification.custom2}, CUSTOM_3 = #{classification.custom3}, CUSTOM_4 = #{classification.custom4}, CUSTOM_5 = #{classification.custom5}, CUSTOM_6 = #{classification.custom6}, CUSTOM_7 = #{classification.custom7}, CUSTOM_8 = #{classification.custom8}, VALID_FROM = #{classification.validFrom}, VALID_UNTIL = #{classification.validUntil} WHERE ID = #{classification.id}")
|
||||
void update(@Param("classification") ClassificationImpl classification);
|
||||
|
||||
@Select("<script>"
|
||||
+ "SELECT * "
|
||||
+ "FROM CLASSIFICATION "
|
||||
+ "WHERE ID = #{id} "
|
||||
+ "AND DOMAIN = #{domain}"
|
||||
+ "ORDER BY VALID_FROM DESC"
|
||||
+ "</script>")
|
||||
@Results({@Result(property = "id", column = "ID"),
|
||||
@Result(property = "parentClassificationId", column = "PARENT_CLASSIFICATION_ID"),
|
||||
@Result(property = "category", column = "CATEGORY"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "isValidInDomain", column = "VALID_IN_DOMAIN"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "serviceLevel", column = "SERVICE_LEVEL"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "validFrom", column = "VALID_FROM"),
|
||||
@Result(property = "validUntil", column = "VALID_UNTIL")})
|
||||
+ "SELECT * "
|
||||
+ "FROM CLASSIFICATION "
|
||||
+ "WHERE ID = #{id} "
|
||||
+ "AND DOMAIN = #{domain}"
|
||||
+ "ORDER BY VALID_FROM DESC"
|
||||
+ "</script>")
|
||||
@Results({ @Result(property = "id", column = "ID"),
|
||||
@Result(property = "key", column = "KEY"),
|
||||
@Result(property = "parentClassificationKey", column = "PARENT_CLASSIFICATION_KEY"),
|
||||
@Result(property = "category", column = "CATEGORY"),
|
||||
@Result(property = "type", column = "TYPE"),
|
||||
@Result(property = "domain", column = "DOMAIN"),
|
||||
@Result(property = "isValidInDomain", column = "VALID_IN_DOMAIN"),
|
||||
@Result(property = "created", column = "CREATED"),
|
||||
@Result(property = "name", column = "NAME"),
|
||||
@Result(property = "description", column = "DESCRIPTION"),
|
||||
@Result(property = "priority", column = "PRIORITY"),
|
||||
@Result(property = "serviceLevel", column = "SERVICE_LEVEL"),
|
||||
@Result(property = "applicationEntryPoint", column = "APPLICATION_ENTRY_POINT"),
|
||||
@Result(property = "custom1", column = "CUSTOM_1"),
|
||||
@Result(property = "custom2", column = "CUSTOM_2"),
|
||||
@Result(property = "custom3", column = "CUSTOM_3"),
|
||||
@Result(property = "custom4", column = "CUSTOM_4"),
|
||||
@Result(property = "custom5", column = "CUSTOM_5"),
|
||||
@Result(property = "custom6", column = "CUSTOM_6"),
|
||||
@Result(property = "custom7", column = "CUSTOM_7"),
|
||||
@Result(property = "custom8", column = "CUSTOM_8"),
|
||||
@Result(property = "validFrom", column = "VALID_FROM"),
|
||||
@Result(property = "validUntil", column = "VALID_UNTIL") })
|
||||
List<ClassificationImpl> getAllClassificationsWithId(@Param("id") String id, @Param("domain") String domain);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ CREATE TABLE TASK (
|
|||
DESCRIPTION VARCHAR(4096) NULL,
|
||||
PRIORITY INT NULL,
|
||||
STATE VARCHAR(20) NULL,
|
||||
CLASSIFICATION_ID CHAR(40) NULL,
|
||||
CLASSIFICATION_KEY VARCHAR(32) NULL,
|
||||
WORKBASKETID CHAR(40) NULL,
|
||||
BUSINESS_PROCESS_ID VARCHAR(128) NULL,
|
||||
PARENT_BUSINESS_PROCESS_ID VARCHAR(128) NULL,
|
||||
|
@ -58,9 +58,10 @@ CREATE TABLE DISTRIBUTION_TARGETS(
|
|||
|
||||
CREATE TABLE CLASSIFICATION(
|
||||
ID CHAR(40) NOT NULL,
|
||||
PARENT_CLASSIFICATION_ID VARCHAR(255) NOT NULL,
|
||||
CATEGORY VARCHAR(255),
|
||||
TYPE VARCHAR(255),
|
||||
KEY VARCHAR(32) NOT NULL,
|
||||
PARENT_CLASSIFICATION_KEY VARCHAR(32) NOT NULL,
|
||||
CATEGORY VARCHAR(32),
|
||||
TYPE VARCHAR(32),
|
||||
DOMAIN VARCHAR(255) NOT NULL,
|
||||
VALID_IN_DOMAIN BOOLEAN NOT NULL,
|
||||
CREATED DATE NULL,
|
||||
|
@ -68,6 +69,7 @@ CREATE TABLE CLASSIFICATION(
|
|||
DESCRIPTION VARCHAR(255) NULL,
|
||||
PRIORITY INT NULL,
|
||||
SERVICE_LEVEL VARCHAR(255) NULL,
|
||||
APPLICATION_ENTRY_POINT VARCHAR(255) NULL,
|
||||
CUSTOM_1 VARCHAR(255) NULL,
|
||||
CUSTOM_2 VARCHAR(255) NULL,
|
||||
CUSTOM_3 VARCHAR(255) NULL,
|
||||
|
|
|
@ -34,13 +34,16 @@ import pro.taskana.model.mappings.ClassificationMapper;
|
|||
|
||||
/**
|
||||
* Unit Test for ClassificationServiceImpl.
|
||||
*
|
||||
* @author EH
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ClassificationServiceImplTest {
|
||||
|
||||
private final Date today = Date.valueOf(LocalDate.now());
|
||||
|
||||
private final String idPrefixClassification = "CLI";
|
||||
|
||||
@Spy
|
||||
@InjectMocks
|
||||
private ClassificationServiceImpl cutSpy;
|
||||
|
@ -66,7 +69,8 @@ public class ClassificationServiceImplTest {
|
|||
|
||||
doReturn(classificationQueryImplMock).when(cutSpy).createClassificationQuery();
|
||||
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).parentClassification("");
|
||||
doReturn(classificationQueryImplMock).when(classificationQueryImplMock).validUntil(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
doReturn(classificationQueryImplMock).when(classificationQueryImplMock)
|
||||
.validUntil(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
doReturn(classifications).when(classificationQueryImplMock).list();
|
||||
|
||||
List<Classification> actaulResults = cutSpy.getClassificationTree();
|
||||
|
@ -74,14 +78,16 @@ public class ClassificationServiceImplTest {
|
|||
verify(taskanaEngineImplMock, times(2)).openConnection();
|
||||
verify(cutSpy, times(1)).createClassificationQuery();
|
||||
verify(classificationQueryImplMock, times(1)).parentClassification("");
|
||||
verify(classificationQueryImplMock, times(1)).validUntil(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
verify(classificationQueryImplMock, times(1))
|
||||
.validUntil(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
verify(classificationQueryImplMock, times(1)).list();
|
||||
verify(taskanaEngineImplMock, times(2)).returnConnection();
|
||||
assertThat(actaulResults, equalTo(classifications));
|
||||
}
|
||||
|
||||
@Test(expected = ClassificationAlreadyExistException.class)
|
||||
public void testCreateClassificationAlreadyExisting() throws ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
public void testCreateClassificationAlreadyExisting()
|
||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
Classification classification = createDummyCLassification();
|
||||
doReturn(classification).when(cutSpy).getClassification(classification.getId(), classification.getDomain());
|
||||
|
||||
|
@ -97,7 +103,8 @@ public class ClassificationServiceImplTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateClassificationInOwnDomain() throws ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
public void testCreateClassificationInOwnDomain()
|
||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
Classification classification = createDummyCLassification();
|
||||
String domain = classification.getDomain();
|
||||
doReturn(null).when(cutSpy).getClassification(classification.getId(), classification.getDomain());
|
||||
|
@ -112,11 +119,13 @@ public class ClassificationServiceImplTest {
|
|||
assertThat(classification.getCreated(), equalTo(today));
|
||||
assertThat(classification.getDomain(), equalTo(""));
|
||||
assertThat(classification.getValidFrom(), equalTo(today));
|
||||
assertThat(classification.getValidUntil(), equalTo(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL));
|
||||
assertThat(classification.getValidUntil(),
|
||||
equalTo(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateClassificationAsRoot() throws ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
public void testCreateClassificationAsRoot()
|
||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
Classification classification = createDummyCLassification();
|
||||
classification.setDomain("");
|
||||
doReturn(null).when(cutSpy).getClassification(classification.getId(), classification.getDomain());
|
||||
|
@ -131,7 +140,8 @@ public class ClassificationServiceImplTest {
|
|||
assertThat(classification.getCreated(), equalTo(today));
|
||||
assertThat(classification.getDomain(), equalTo(""));
|
||||
assertThat(classification.getValidFrom(), equalTo(today));
|
||||
assertThat(classification.getValidUntil(), equalTo(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL));
|
||||
assertThat(classification.getValidUntil(),
|
||||
equalTo(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -150,7 +160,8 @@ public class ClassificationServiceImplTest {
|
|||
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
|
||||
assertThat(classification.getCreated(), equalTo(today));
|
||||
assertThat(classification.getValidFrom(), equalTo(today));
|
||||
assertThat(classification.getValidUntil(), equalTo(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL));
|
||||
assertThat(classification.getValidUntil(),
|
||||
equalTo(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -175,13 +186,17 @@ public class ClassificationServiceImplTest {
|
|||
@Test
|
||||
public void testGetAllClassificationWithId() {
|
||||
Classification dummyClassification = createDummyCLassification();
|
||||
List<ClassificationImpl> classificationImpls = Arrays.asList(createDummyCLassificationImpl(), createDummyCLassificationImpl());
|
||||
doReturn(classificationImpls).when(classificationMapperMock).getAllClassificationsWithId(dummyClassification.getId(), dummyClassification.getDomain());
|
||||
List<ClassificationImpl> classificationImpls = Arrays.asList(createDummyCLassificationImpl(),
|
||||
createDummyCLassificationImpl());
|
||||
doReturn(classificationImpls).when(classificationMapperMock)
|
||||
.getAllClassificationsWithId(dummyClassification.getId(), dummyClassification.getDomain());
|
||||
|
||||
List<Classification> actualResults = cutSpy.getAllClassificationsWithId(dummyClassification.getId(), dummyClassification.getDomain());
|
||||
List<Classification> actualResults = cutSpy.getAllClassificationsWithId(dummyClassification.getId(),
|
||||
dummyClassification.getDomain());
|
||||
|
||||
verify(taskanaEngineImplMock, times(1)).openConnection();
|
||||
verify(classificationMapperMock, times(1)).getAllClassificationsWithId(dummyClassification.getId(), dummyClassification.getDomain());
|
||||
verify(classificationMapperMock, times(1)).getAllClassificationsWithId(dummyClassification.getId(),
|
||||
dummyClassification.getDomain());
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
|
||||
assertThat(actualResults.size(), equalTo(classificationImpls.size()));
|
||||
|
@ -191,12 +206,15 @@ public class ClassificationServiceImplTest {
|
|||
public void testGetClassificationFromChildDomain() throws ClassificationNotFoundException {
|
||||
Classification expectedClassification = createDummyCLassification();
|
||||
doReturn(expectedClassification).when(classificationMapperMock)
|
||||
.findByIdAndDomain(expectedClassification.getId(), expectedClassification.getDomain(), ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
.findByIdAndDomain(expectedClassification.getId(), expectedClassification.getDomain(),
|
||||
ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
|
||||
Classification actualClassification = cutSpy.getClassification(expectedClassification.getId(), expectedClassification.getDomain());
|
||||
Classification actualClassification = cutSpy.getClassification(expectedClassification.getId(),
|
||||
expectedClassification.getDomain());
|
||||
|
||||
verify(taskanaEngineImplMock, times(1)).openConnection();
|
||||
verify(classificationMapperMock, times(1)).findByIdAndDomain(expectedClassification.getId(), expectedClassification.getDomain(), ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
verify(classificationMapperMock, times(1)).findByIdAndDomain(expectedClassification.getId(),
|
||||
expectedClassification.getDomain(), ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
|
||||
assertThat(actualClassification, equalTo(expectedClassification));
|
||||
|
@ -208,15 +226,20 @@ public class ClassificationServiceImplTest {
|
|||
Classification expectedClassification = createDummyCLassification();
|
||||
expectedClassification.setDomain("");
|
||||
doReturn(null).when(classificationMapperMock)
|
||||
.findByIdAndDomain(classification.getId(), classification.getDomain(), ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
.findByIdAndDomain(classification.getId(), classification.getDomain(),
|
||||
ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
doReturn(expectedClassification).when(classificationMapperMock)
|
||||
.findByIdAndDomain(expectedClassification.getId(), expectedClassification.getDomain(), ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
.findByIdAndDomain(expectedClassification.getId(), expectedClassification.getDomain(),
|
||||
ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
|
||||
Classification actualClassification = cutSpy.getClassification(classification.getId(), classification.getDomain());
|
||||
Classification actualClassification = cutSpy.getClassification(classification.getId(),
|
||||
classification.getDomain());
|
||||
|
||||
verify(taskanaEngineImplMock, times(1)).openConnection();
|
||||
verify(classificationMapperMock, times(1)).findByIdAndDomain(classification.getId(), classification.getDomain(), ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
verify(classificationMapperMock, times(1)).findByIdAndDomain(expectedClassification.getId(), "", ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
verify(classificationMapperMock, times(1)).findByIdAndDomain(classification.getId(), classification.getDomain(),
|
||||
ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
verify(classificationMapperMock, times(1)).findByIdAndDomain(expectedClassification.getId(), "",
|
||||
ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
|
||||
assertThat(actualClassification, equalTo(expectedClassification));
|
||||
|
@ -236,10 +259,11 @@ public class ClassificationServiceImplTest {
|
|||
assertThat(actualResult.getId(), not(equalTo(null)));
|
||||
assertThat(actualResult.getId(), startsWith(idPrefixClassification));
|
||||
assertThat(actualResult.getCreated(), equalTo(today));
|
||||
assertThat(actualResult.getParentClassificationId(), equalTo(""));
|
||||
assertThat(actualResult.getParentClassificationKey(), equalTo(""));
|
||||
assertThat(actualResult.getDomain(), equalTo(""));
|
||||
assertThat(actualResult.getValidFrom(), equalTo(today));
|
||||
assertThat(actualResult.getValidUntil(), equalTo(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL));
|
||||
assertThat(actualResult.getValidUntil(),
|
||||
equalTo(ClassificationServiceImpl.CURRENT_CLASSIFICATIONS_VALID_UNTIL));
|
||||
}
|
||||
|
||||
private Classification createDummyCLassification() {
|
||||
|
@ -249,7 +273,8 @@ public class ClassificationServiceImplTest {
|
|||
classificationImpl.setDomain("test-domain");
|
||||
classificationImpl.setServiceLevel("P2D");
|
||||
classificationImpl.setId("ID: 1");
|
||||
classificationImpl.setParentClassificationId("");
|
||||
classificationImpl.setKey("ABC111");
|
||||
classificationImpl.setParentClassificationKey("");
|
||||
return (Classification) classificationImpl;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,11 @@ import pro.taskana.model.ClassificationImpl;
|
|||
public class TestClassificationQuery implements ClassificationQuery {
|
||||
|
||||
private List<ClassificationImpl> classifications;
|
||||
|
||||
private String[] parentId;
|
||||
|
||||
private Date[] validUntil;
|
||||
|
||||
private String description;
|
||||
|
||||
public TestClassificationQuery(List<ClassificationImpl> classifications) {
|
||||
|
@ -111,9 +114,9 @@ public class TestClassificationQuery implements ClassificationQuery {
|
|||
|
||||
if (this.parentId != null) {
|
||||
Boolean classificationWithParent = false;
|
||||
if (classification.getParentClassificationId() != null) {
|
||||
if (classification.getParentClassificationKey() != null) {
|
||||
for (String parent : this.parentId) {
|
||||
if (parent.equals(classification.getParentClassificationId())) {
|
||||
if (parent.equals(classification.getParentClassificationKey())) {
|
||||
classificationWithParent = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,15 +32,21 @@ import pro.taskana.model.ClassificationImpl;
|
|||
|
||||
/**
|
||||
* Integration Test for ClassificationServiceImpl with connection management mode AUTOCOMMIT.
|
||||
*
|
||||
* @author EH
|
||||
*/
|
||||
public class ClassificationServiceImplIntAutoCommitTest {
|
||||
|
||||
static int counter = 0;
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
private ClassificationService classificationService;
|
||||
|
||||
private TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
|
||||
private TaskanaEngine taskanaEngine;
|
||||
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
|
||||
@BeforeClass
|
||||
|
@ -77,14 +83,15 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
ClassificationImpl classification1 = new ClassificationImpl();
|
||||
classificationService.createClassification(classification1);
|
||||
ClassificationImpl classification2 = new ClassificationImpl();
|
||||
classification2.setParentClassificationId(classification0.getId());
|
||||
classification2.setParentClassificationKey(classification0.getId());
|
||||
classificationService.createClassification(classification2);
|
||||
|
||||
Assert.assertEquals(2 + 1, classificationService.getClassificationTree().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifiedClassification() throws ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
public void testModifiedClassification()
|
||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
|
||||
ClassificationImpl classification = new ClassificationImpl();
|
||||
classificationService.createClassification(classification);
|
||||
|
@ -99,19 +106,27 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
ClassificationImpl classification = new ClassificationImpl();
|
||||
classificationService.createClassification(classification);
|
||||
Date today = Date.valueOf(LocalDate.now());
|
||||
List<Classification> list = classificationService.createClassificationQuery().validInDomain(Boolean.TRUE).created(today).validFrom(today).validUntil(Date.valueOf("9999-12-31")).list();
|
||||
List<Classification> list = classificationService.createClassificationQuery()
|
||||
.validInDomain(Boolean.TRUE)
|
||||
.created(today)
|
||||
.validFrom(today)
|
||||
.validUntil(Date.valueOf("9999-12-31"))
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAndClassificationMapper() throws NotAuthorizedException, ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
public void testUpdateAndClassificationMapper()
|
||||
throws NotAuthorizedException, ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
ClassificationImpl classification = new ClassificationImpl();
|
||||
classificationService.createClassification(classification);
|
||||
System.out.println(classification.getId());
|
||||
classification.setDescription("description");
|
||||
classificationService.updateClassification(classification);
|
||||
|
||||
List<Classification> list = classificationService.createClassificationQuery().validUntil(Date.valueOf("9999-12-31")).list();
|
||||
List<Classification> list = classificationService.createClassificationQuery()
|
||||
.validUntil(Date.valueOf("9999-12-31"))
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
list = classificationService.createClassificationQuery().validInDomain(true).list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
|
@ -122,7 +137,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
list = classificationService.createClassificationQuery().validUntil(Date.valueOf("9999-12-31")).list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
|
||||
System.out.println(classification.getParentClassificationId());
|
||||
System.out.println(classification.getParentClassificationKey());
|
||||
|
||||
List<Classification> temp = classificationService.getClassificationTree();
|
||||
List<ClassificationImpl> allClassifications = new ArrayList<>();
|
||||
|
@ -131,7 +146,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperDomainAndCategory() throws NotAuthorizedException, ClassificationAlreadyExistException {
|
||||
public void testFindWithClassificationMapperDomainAndCategory()
|
||||
throws NotAuthorizedException, ClassificationAlreadyExistException {
|
||||
ClassificationImpl classification1 = new ClassificationImpl();
|
||||
classification1.setDomain("domain1");
|
||||
classification1.setCategory("category1");
|
||||
|
@ -145,14 +161,18 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
classification3.setCategory("category2");
|
||||
classificationService.createClassification(classification3);
|
||||
|
||||
List<Classification> list = classificationService.createClassificationQuery().category("category1").domain("domain1").list();
|
||||
List<Classification> list = classificationService.createClassificationQuery()
|
||||
.category("category1")
|
||||
.domain("domain1")
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
list = classificationService.createClassificationQuery().domain("domain1", "domain3").list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperCustomAndCategory() throws NotAuthorizedException, ClassificationAlreadyExistException {
|
||||
public void testFindWithClassificationMapperCustomAndCategory()
|
||||
throws NotAuthorizedException, ClassificationAlreadyExistException {
|
||||
ClassificationImpl classification1 = new ClassificationImpl();
|
||||
classification1.setDescription("DESC1");
|
||||
classification1.setCategory("category1");
|
||||
|
@ -173,7 +193,10 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
classification4.setCategory("category1");
|
||||
classificationService.createClassification(classification4);
|
||||
|
||||
List<Classification> list = classificationService.createClassificationQuery().descriptionLike("DESC1").customFields("custom1").list();
|
||||
List<Classification> list = classificationService.createClassificationQuery()
|
||||
.descriptionLike("DESC1")
|
||||
.customFields("custom1")
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
list = classificationService.createClassificationQuery().customFields("custom2").list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
|
@ -182,7 +205,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperPriorityTypeAndParent() throws NotAuthorizedException, ClassificationAlreadyExistException {
|
||||
public void testFindWithClassificationMapperPriorityTypeAndParent()
|
||||
throws NotAuthorizedException, ClassificationAlreadyExistException {
|
||||
ClassificationImpl classification = new ClassificationImpl();
|
||||
classification.setPriority(Integer.decode("5"));
|
||||
classification.setType("type1");
|
||||
|
@ -190,29 +214,36 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
ClassificationImpl classification1 = new ClassificationImpl();
|
||||
classification1.setPriority(Integer.decode("3"));
|
||||
classification1.setType("type1");
|
||||
classification1.setParentClassificationId(classification.getId());
|
||||
classification1.setParentClassificationKey(classification.getId());
|
||||
classificationService.createClassification(classification1);
|
||||
ClassificationImpl classification2 = new ClassificationImpl();
|
||||
classification2.setPriority(Integer.decode("5"));
|
||||
classification2.setType("type2");
|
||||
classification2.setParentClassificationId(classification.getId());
|
||||
classification2.setParentClassificationKey(classification.getId());
|
||||
classificationService.createClassification(classification2);
|
||||
ClassificationImpl classification3 = new ClassificationImpl();
|
||||
classification3.setPriority(Integer.decode("5"));
|
||||
classification3.setType("type1");
|
||||
classification3.setParentClassificationId(classification1.getId());
|
||||
classification3.setParentClassificationKey(classification1.getId());
|
||||
classificationService.createClassification(classification3);
|
||||
|
||||
List<Classification> list = classificationService.createClassificationQuery().parentClassification(classification.getId()).list();
|
||||
List<Classification> list = classificationService.createClassificationQuery()
|
||||
.parentClassification(classification.getId())
|
||||
.list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
list = classificationService.createClassificationQuery().type("type1").priority(Integer.decode("5")).list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
list = classificationService.createClassificationQuery().priority(Integer.decode("5")).type("type1").parentClassification(classification1.getId()).list();
|
||||
list = classificationService.createClassificationQuery()
|
||||
.priority(Integer.decode("5"))
|
||||
.type("type1")
|
||||
.parentClassification(classification1.getId())
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperServiceLevelNameAndDescription() throws NotAuthorizedException, ClassificationAlreadyExistException {
|
||||
public void testFindWithClassificationMapperServiceLevelNameAndDescription()
|
||||
throws NotAuthorizedException, ClassificationAlreadyExistException {
|
||||
int all = 0;
|
||||
ClassificationImpl classification = new ClassificationImpl();
|
||||
classification.setServiceLevel("P1D");
|
||||
|
@ -249,16 +280,16 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultSettingsWithClassificationMapper() throws NotAuthorizedException, ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
public void testDefaultSettingsWithClassificationMapper()
|
||||
throws NotAuthorizedException, ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
ClassificationImpl classification = new ClassificationImpl();
|
||||
ClassificationImpl classification1 = new ClassificationImpl();
|
||||
classificationService.createClassification(classification);
|
||||
classificationService.createClassification(classification1);
|
||||
classification1.setParentClassificationId(classification.getId());
|
||||
classification1.setParentClassificationKey(classification.getId());
|
||||
classificationService.updateClassification(classification1);
|
||||
|
||||
List<Classification>
|
||||
list = classificationService.createClassificationQuery().parentClassification("").list();
|
||||
List<Classification> list = classificationService.createClassificationQuery().parentClassification("").list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
list = classificationService.createClassificationQuery().validUntil(Date.valueOf("9999-12-31")).list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
|
@ -273,7 +304,10 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
|
||||
list = classificationService.createClassificationQuery().domain("domain1").validInDomain(false).list();
|
||||
Assert.assertEquals(0, list.size());
|
||||
list = classificationService.createClassificationQuery().validFrom(Date.valueOf((LocalDate.now()))).validUntil(Date.valueOf(LocalDate.now().minusDays(1))).list();
|
||||
list = classificationService.createClassificationQuery()
|
||||
.validFrom(Date.valueOf((LocalDate.now())))
|
||||
.validUntil(Date.valueOf(LocalDate.now().minusDays(1)))
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
|
|
|
@ -33,16 +33,22 @@ import pro.taskana.model.ClassificationImpl;
|
|||
|
||||
/**
|
||||
* Integration Test for ClassificationServiceImpl with connection management mode EXPLICIT.
|
||||
*
|
||||
* @author BBR
|
||||
*/
|
||||
|
||||
public class ClassificationServiceImplIntExplicitTest {
|
||||
|
||||
static int counter = 0;
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
private ClassificationService classificationService;
|
||||
|
||||
private TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
|
||||
private TaskanaEngine taskanaEngine;
|
||||
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
|
||||
@BeforeClass
|
||||
|
@ -65,7 +71,8 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testInsertClassification() throws SQLException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
public void testInsertClassification()
|
||||
throws SQLException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
|
@ -77,7 +84,8 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFindAllClassifications() throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
public void testFindAllClassifications()
|
||||
throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
ClassificationImpl classification0 = new ClassificationImpl();
|
||||
|
@ -85,7 +93,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
ClassificationImpl classification1 = new ClassificationImpl();
|
||||
classificationService.createClassification(classification1);
|
||||
ClassificationImpl classification2 = new ClassificationImpl();
|
||||
classification2.setParentClassificationId(classification0.getId());
|
||||
classification2.setParentClassificationKey(classification0.getId());
|
||||
classificationService.createClassification(classification2);
|
||||
|
||||
Assert.assertEquals(2 + 1, classificationService.getClassificationTree().size());
|
||||
|
@ -93,7 +101,8 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testModifiedClassification() throws SQLException, ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
public void testModifiedClassification()
|
||||
throws SQLException, ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
@ -107,18 +116,25 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testInsertAndClassificationMapper() throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
public void testInsertAndClassificationMapper()
|
||||
throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
ClassificationImpl classification = new ClassificationImpl();
|
||||
classificationService.createClassification(classification);
|
||||
Date today = Date.valueOf(LocalDate.now());
|
||||
List<Classification> list = classificationService.createClassificationQuery().validInDomain(Boolean.TRUE).created(today).validFrom(today).validUntil(Date.valueOf("9999-12-31")).list();
|
||||
List<Classification> list = classificationService.createClassificationQuery()
|
||||
.validInDomain(Boolean.TRUE)
|
||||
.created(today)
|
||||
.validFrom(today)
|
||||
.validUntil(Date.valueOf("9999-12-31"))
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAndClassificationMapper() throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
public void testUpdateAndClassificationMapper() throws NotAuthorizedException, SQLException,
|
||||
ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
ClassificationImpl classification = new ClassificationImpl();
|
||||
|
@ -127,7 +143,9 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
classification.setDescription("description");
|
||||
classificationService.updateClassification(classification);
|
||||
|
||||
List<Classification> list = classificationService.createClassificationQuery().validUntil(Date.valueOf("9999-12-31")).list();
|
||||
List<Classification> list = classificationService.createClassificationQuery()
|
||||
.validUntil(Date.valueOf("9999-12-31"))
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
list = classificationService.createClassificationQuery().validInDomain(true).list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
|
@ -138,7 +156,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
list = classificationService.createClassificationQuery().validUntil(Date.valueOf("9999-12-31")).list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
|
||||
System.out.println(classification.getParentClassificationId());
|
||||
System.out.println(classification.getParentClassificationKey());
|
||||
|
||||
List<Classification> allClassifications = classificationService.getClassificationTree();
|
||||
Assert.assertEquals(2, allClassifications.size());
|
||||
|
@ -146,10 +164,11 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperDomainAndCategory() throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
public void testFindWithClassificationMapperDomainAndCategory()
|
||||
throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
ClassificationImpl classification1 = new ClassificationImpl();
|
||||
ClassificationImpl classification1 = new ClassificationImpl();
|
||||
classification1.setDomain("domain1");
|
||||
classification1.setCategory("category1");
|
||||
classificationService.createClassification(classification1);
|
||||
|
@ -162,7 +181,10 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
classification3.setCategory("category2");
|
||||
classificationService.createClassification(classification3);
|
||||
|
||||
List<Classification> list = classificationService.createClassificationQuery().category("category1").domain("domain1").list();
|
||||
List<Classification> list = classificationService.createClassificationQuery()
|
||||
.category("category1")
|
||||
.domain("domain1")
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
list = classificationService.createClassificationQuery().domain("domain1", "domain3").list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
|
@ -170,7 +192,8 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperCustomAndCategory() throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
public void testFindWithClassificationMapperCustomAndCategory()
|
||||
throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
ClassificationImpl classification1 = new ClassificationImpl();
|
||||
|
@ -193,7 +216,10 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
classification4.setCategory("category1");
|
||||
classificationService.createClassification(classification4);
|
||||
|
||||
List<Classification> list = classificationService.createClassificationQuery().descriptionLike("DESC1").customFields("custom1").list();
|
||||
List<Classification> list = classificationService.createClassificationQuery()
|
||||
.descriptionLike("DESC1")
|
||||
.customFields("custom1")
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
list = classificationService.createClassificationQuery().customFields("custom2").list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
|
@ -203,7 +229,8 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperPriorityTypeAndParent() throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
public void testFindWithClassificationMapperPriorityTypeAndParent()
|
||||
throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
ClassificationImpl classification = new ClassificationImpl();
|
||||
|
@ -213,30 +240,37 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
ClassificationImpl classification1 = new ClassificationImpl();
|
||||
classification1.setPriority(Integer.decode("3"));
|
||||
classification1.setType("type1");
|
||||
classification1.setParentClassificationId(classification.getId());
|
||||
classification1.setParentClassificationKey(classification.getId());
|
||||
classificationService.createClassification(classification1);
|
||||
ClassificationImpl classification2 = new ClassificationImpl();
|
||||
classification2.setPriority(Integer.decode("5"));
|
||||
classification2.setType("type2");
|
||||
classification2.setParentClassificationId(classification.getId());
|
||||
classification2.setParentClassificationKey(classification.getId());
|
||||
classificationService.createClassification(classification2);
|
||||
ClassificationImpl classification3 = new ClassificationImpl();
|
||||
classification3.setPriority(Integer.decode("5"));
|
||||
classification3.setType("type1");
|
||||
classification3.setParentClassificationId(classification1.getId());
|
||||
classification3.setParentClassificationKey(classification1.getId());
|
||||
classificationService.createClassification(classification3);
|
||||
|
||||
List<Classification> list = classificationService.createClassificationQuery().parentClassification(classification.getId()).list();
|
||||
List<Classification> list = classificationService.createClassificationQuery()
|
||||
.parentClassification(classification.getId())
|
||||
.list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
list = classificationService.createClassificationQuery().type("type1").priority(Integer.decode("5")).list();
|
||||
Assert.assertEquals(2, list.size());
|
||||
list = classificationService.createClassificationQuery().priority(Integer.decode("5")).type("type1").parentClassification(classification1.getId()).list();
|
||||
list = classificationService.createClassificationQuery()
|
||||
.priority(Integer.decode("5"))
|
||||
.type("type1")
|
||||
.parentClassification(classification1.getId())
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperServiceLevelNameAndDescription() throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
public void testFindWithClassificationMapperServiceLevelNameAndDescription()
|
||||
throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
int all = 0;
|
||||
|
@ -276,14 +310,15 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultSettingsWithClassificationMapper() throws NotAuthorizedException, SQLException, ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
public void testDefaultSettingsWithClassificationMapper() throws NotAuthorizedException, SQLException,
|
||||
ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
ClassificationImpl classification = new ClassificationImpl();
|
||||
ClassificationImpl classification1 = new ClassificationImpl();
|
||||
classificationService.createClassification(classification);
|
||||
classificationService.createClassification(classification1);
|
||||
classification1.setParentClassificationId(classification.getId());
|
||||
classification1.setParentClassificationKey(classification.getId());
|
||||
classificationService.updateClassification(classification1);
|
||||
|
||||
List<Classification> list = classificationService.createClassificationQuery().parentClassification("").list();
|
||||
|
@ -302,7 +337,10 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
|
||||
list = classificationService.createClassificationQuery().domain("domain1").validInDomain(false).list();
|
||||
Assert.assertEquals(0, list.size());
|
||||
list = classificationService.createClassificationQuery().validFrom(Date.valueOf((LocalDate.now()))).validUntil(Date.valueOf(LocalDate.now().minusDays(1))).list();
|
||||
list = classificationService.createClassificationQuery()
|
||||
.validFrom(Date.valueOf((LocalDate.now())))
|
||||
.validUntil(Date.valueOf(LocalDate.now().minusDays(1)))
|
||||
.list();
|
||||
Assert.assertEquals(1, list.size());
|
||||
connection.commit();
|
||||
}
|
||||
|
|
|
@ -44,16 +44,23 @@ import pro.taskana.model.Workbasket;
|
|||
|
||||
/**
|
||||
* Integration Test for TaskServiceImpl transactions with connection management mode AUTOCOMMIT.
|
||||
*
|
||||
* @author EH
|
||||
*/
|
||||
public class TaskServiceImplIntAutocommitTest {
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
private TaskServiceImpl taskServiceImpl;
|
||||
|
||||
private TaskanaEngineConfiguration taskanaEngineConfiguration;
|
||||
|
||||
private TaskanaEngine taskanaEngine;
|
||||
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
|
||||
private ClassificationService classificationService;
|
||||
|
||||
private WorkbasketService workbasketService;
|
||||
|
||||
@BeforeClass
|
||||
|
@ -80,7 +87,8 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
|
||||
@Test
|
||||
public void testStart() throws FileNotFoundException, SQLException, TaskNotFoundException,
|
||||
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException,
|
||||
ClassificationAlreadyExistException {
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setName("workbasket");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
|
@ -93,7 +101,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
task.setClassification(classification);
|
||||
|
||||
task = taskServiceImpl.createTask(task);
|
||||
//skanaEngineImpl.getSqlSession().commit(); // needed so that the change is visible in the other session
|
||||
// skanaEngineImpl.getSqlSession().commit(); // needed so that the change is visible in the other session
|
||||
|
||||
TaskanaEngine te2 = taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
|
||||
|
@ -103,7 +111,8 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
|
||||
@Test(expected = TaskNotFoundException.class)
|
||||
public void testStartTransactionFail()
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setName("sdf");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
|
@ -124,7 +133,8 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
|
||||
@Test
|
||||
public void testCreateTaskInTaskanaWithDefaultDb()
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setName("workbasket");
|
||||
wb = taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
|
@ -142,7 +152,8 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setName("workbasket");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
|
@ -157,17 +168,32 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
|
||||
TaskanaEngineImpl taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
ClassificationQuery classificationQuery = new ClassificationQueryImpl(taskanaEngineImpl)
|
||||
.parentClassification("pId1", "pId2").category("cat1", "cat2").type("oneType").name("1Name", "name2")
|
||||
.descriptionLike("my desc").priority(1, 2, 1).serviceLevel("me", "and", "you");
|
||||
.parentClassification("pId1", "pId2")
|
||||
.category("cat1", "cat2")
|
||||
.type("oneType")
|
||||
.name("1Name", "name2")
|
||||
.descriptionLike("my desc")
|
||||
.priority(1, 2, 1)
|
||||
.serviceLevel("me", "and", "you");
|
||||
|
||||
ObjectReferenceQuery objectReferenceQuery = new ObjectReferenceQueryImpl(taskanaEngineImpl)
|
||||
.company("first comp", "sonstwo gmbh").system("sys").type("type1", "type2")
|
||||
.systemInstance("sysInst1", "sysInst2").value("val1", "val2", "val3");
|
||||
.company("first comp", "sonstwo gmbh")
|
||||
.system("sys")
|
||||
.type("type1", "type2")
|
||||
.systemInstance("sysInst1", "sysInst2")
|
||||
.value("val1", "val2", "val3");
|
||||
|
||||
List<Task> results = taskServiceImpl.createTaskQuery().name("bla", "test").descriptionLike("test")
|
||||
.priority(1, 2, 2).state(TaskState.CLAIMED).workbasketId("asd", "asdasdasd")
|
||||
.owner("test", "test2", "bla").customFields("test").classification(classificationQuery)
|
||||
.objectReference(objectReferenceQuery).list();
|
||||
List<Task> results = taskServiceImpl.createTaskQuery()
|
||||
.name("bla", "test")
|
||||
.descriptionLike("test")
|
||||
.priority(1, 2, 2)
|
||||
.state(TaskState.CLAIMED)
|
||||
.workbasketId("asd", "asdasdasd")
|
||||
.owner("test", "test2", "bla")
|
||||
.customFields("test")
|
||||
.classification(classificationQuery)
|
||||
.objectReference(objectReferenceQuery)
|
||||
.list();
|
||||
|
||||
Assert.assertEquals(0, results.size());
|
||||
}
|
||||
|
@ -181,7 +207,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
dummyWorkbasket = workbasketService.createWorkbasket(dummyWorkbasket);
|
||||
|
||||
Classification dummyClassification = classificationService.newClassification();
|
||||
dummyClassification.setId("1");
|
||||
dummyClassification.setKey("1");
|
||||
dummyClassification.setName("Dummy-Classification");
|
||||
classificationService.createClassification(dummyClassification);
|
||||
|
||||
|
@ -202,7 +228,8 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
taskSummary.setClassificationName(dummyClassification.getName());
|
||||
expectedTaskSumamries.add(taskSummary);
|
||||
|
||||
List<TaskSummary> actualTaskSumamryResult = taskServiceImpl.getTaskSummariesByWorkbasketId(dummyWorkbasket.getId());
|
||||
List<TaskSummary> actualTaskSumamryResult = taskServiceImpl
|
||||
.getTaskSummariesByWorkbasketId(dummyWorkbasket.getId());
|
||||
|
||||
assertThat(actualTaskSumamryResult.size(), equalTo(expectedTaskSumamries.size()));
|
||||
}
|
||||
|
@ -213,7 +240,8 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
}
|
||||
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void shouldThrowWorkbasketNotFoundExceptionByInvalidWorkbasketParameter() throws WorkbasketNotFoundException {
|
||||
public void shouldThrowWorkbasketNotFoundExceptionByInvalidWorkbasketParameter()
|
||||
throws WorkbasketNotFoundException {
|
||||
Workbasket wb = new Workbasket();
|
||||
wb.setName("wb");
|
||||
workbasketService.createWorkbasket(wb);
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
INSERT INTO CLASSIFICATION VALUES ('1', '', 'EXTERN', 'BRIEF','nova-domain', TRUE, CURRENT_TIMESTAMP, 'ROOT', 'DESC', 1, 'P1D', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES ('2', '1','MANUELL', 'BRIEF', 'nova-domain', TRUE, CURRENT_TIMESTAMP, 'CHILD', 'DESC', 1, 'P1D', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES ('3', '1','MASCHINELL', 'BRIEF', '', FALSE, CURRENT_TIMESTAMP, 'ANOTHER CHILD', 'DESC', 1, 'P2D', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES ('4', '2','PROZESS', 'EXCEL-SHEET', '', TRUE, CURRENT_TIMESTAMP, 'GRANDCHILD', 'DESC', 1, 'P1DT4H12S', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000001', 'L10000', '', 'EXTERN', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'OLD-Leistungsfall', 'OLD-Leistungsfall', 1, 'P1D', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '', "2016-12-12", '2017-12-11');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000002', 'L10303', '', 'EXTERN', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'Beratungsprotokoll', 'Beratungsprotokoll', 1, 'P1D', 'VNR,RVNR,KOLVNR, ANR', '', '', '', '', '', '', '', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000003', 'L1050', '', 'EXTERN', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'Widerruf', 'Widerruf', 1, 'P1D', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000004', 'L11010', '', 'EXTERN', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'Dynamikänderung', 'Dynamikänderung', 1, 'P1D', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000005', 'L110102', 'L11010', 'EXTERN', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'Dynamik-Ablehnung', 'Dynamik-Ablehnung', 5, 'P5D', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000006', 'L110105', 'L11010', 'EXTERN', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'Dynamik-Ausschluss', 'Dynamik-Ausschluss', 5, 'P5D', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000007', 'L110105', 'L11010', 'EXTERN', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'Dynamik-Einschluss/Änd.', 'Dynamik-Einschluss/Änd.', 5, 'P5D', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000008', 'L12010', '', 'EXTERN', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'Gewährung-Policendarlehen', 'Gewährung-Policendarlehen', 1, 'P1D', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000009', 'L140101', '', 'EXTERN', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'Zustimmungserklärung', 'Zustimmungserklärung', 2, 'P2D', 'VNR', '', '', '', '', '', '', '', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000010', 'T2100', '', 'MANUAL', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'T-Vertragstermin VERA', 'T-Vertragstermin VERA', 2, 'P2D', 'VNR', '', '', '', '', '', '', '', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000011', 'T6310', '', 'AUTOMATIC', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'T-GUK Honorarrechnung erstellen', 'Generali Unterstützungskasse Honorar wird fällig', 2, 'P2D', 'VNR', '', '', '', '', '', '', '', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000013', 'DOKTYP_DEFAULT', '', 'EXTERN', 'DOCUMENT', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'EP allgemein', 'EP allgemein', 99, 'P2000D', 'VNR', '', '', '', '', '', '', '', CURRENT_TIMESTAMP, '9999-12-31');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000014', 'L10000', '', 'EXTERN', 'TASK', 'GELBAV', TRUE, CURRENT_TIMESTAMP, 'BUZ-Leistungsfall', 'BUZ-Leistungsfall', 1, 'P1D', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '', "2017-12-12", '9999-12-31');
|
||||
|
||||
INSERT INTO CLASSIFICATION VALUES('13', '3', 'MANUELL', '', '', TRUE, CURRENT_TIMESTAMP, 'ANOTHER GRANDCHILD', 'DESC', 3, 'P3DT12H', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
|
||||
INSERT INTO CLASSIFICATION VALUES('14', '4', 'MANUELL', '', '', FALSE, CURRENT_TIMESTAMP, 'BIG GRANDCHILD', 'DESC', 2, 'P2DT12H', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
|
||||
INSERT INTO CLASSIFICATION VALUES('15', '3', 'PROZESS', 'MINDMAP', 'nova-domain', FALSE, CURRENT_TIMESTAMP, 'SMALL GRANDCHILD', 'DESC', 4, 'P5DT12H', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
|
||||
INSERT INTO CLASSIFICATION VALUES('16', '4', 'MANUELL', '', 'nova-domain', TRUE, CURRENT_TIMESTAMP, 'NO GRANDCHILD', 'DESC', 3, 'P3DT', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
|
||||
|
|
Loading…
Reference in New Issue