TSK-1762: fixed some code smells
This commit is contained in:
parent
746eaeba6e
commit
23919eb0a1
|
@ -37,6 +37,10 @@ public class TaskanaConfigurationInitializer {
|
|||
private static final String TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY =
|
||||
"taskana.classification.categories";
|
||||
|
||||
private TaskanaConfigurationInitializer() {
|
||||
throw new IllegalStateException("utility class");
|
||||
}
|
||||
|
||||
public static <T> Optional<T> parseProperty(
|
||||
Properties props, String key, CheckedFunction<String, T, Exception> function) {
|
||||
String property = props.getProperty(key, "");
|
||||
|
@ -54,29 +58,6 @@ public class TaskanaConfigurationInitializer {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
static List<String> splitStringAndTrimElements(String str, String separator) {
|
||||
return splitStringAndTrimElements(str, separator, UnaryOperator.identity());
|
||||
}
|
||||
|
||||
static List<String> splitStringAndTrimElements(
|
||||
String str, String separator, UnaryOperator<String> modifier) {
|
||||
return Arrays.stream(str.split(Pattern.quote(separator)))
|
||||
.filter(s -> !s.isEmpty())
|
||||
.map(String::trim)
|
||||
.map(modifier)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
static CustomHoliday createCustomHolidayFromPropsEntry(String customHolidayEntry)
|
||||
throws WrongCustomHolidayFormatException {
|
||||
List<String> parts =
|
||||
splitStringAndTrimElements(customHolidayEntry, TASKANA_CUSTOM_HOLIDAY_DAY_MONTH_SEPARATOR);
|
||||
if (parts.size() == 2) {
|
||||
return CustomHoliday.of(Integer.valueOf(parts.get(0)), Integer.valueOf(parts.get(1)));
|
||||
}
|
||||
throw new WrongCustomHolidayFormatException(customHolidayEntry);
|
||||
}
|
||||
|
||||
public static Map<String, List<String>> configureClassificationCategoriesForType(
|
||||
Properties props, List<String> classificationTypes) {
|
||||
Function<String, List<String>> getClassificationCategoriesForType =
|
||||
|
@ -187,6 +168,29 @@ public class TaskanaConfigurationInitializer {
|
|||
}
|
||||
}
|
||||
|
||||
static List<String> splitStringAndTrimElements(String str, String separator) {
|
||||
return splitStringAndTrimElements(str, separator, UnaryOperator.identity());
|
||||
}
|
||||
|
||||
static List<String> splitStringAndTrimElements(
|
||||
String str, String separator, UnaryOperator<String> modifier) {
|
||||
return Arrays.stream(str.split(Pattern.quote(separator)))
|
||||
.filter(s -> !s.isEmpty())
|
||||
.map(String::trim)
|
||||
.map(modifier)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
static CustomHoliday createCustomHolidayFromPropsEntry(String customHolidayEntry)
|
||||
throws WrongCustomHolidayFormatException {
|
||||
List<String> parts =
|
||||
splitStringAndTrimElements(customHolidayEntry, TASKANA_CUSTOM_HOLIDAY_DAY_MONTH_SEPARATOR);
|
||||
if (parts.size() == 2) {
|
||||
return CustomHoliday.of(Integer.valueOf(parts.get(0)), Integer.valueOf(parts.get(1)));
|
||||
}
|
||||
throw new WrongCustomHolidayFormatException(customHolidayEntry);
|
||||
}
|
||||
|
||||
private static void setFieldValue(Object instance, Field field, Object value) {
|
||||
final Optional<Method> hasSetterMethod =
|
||||
Arrays.stream(instance.getClass().getMethods())
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
|
||||
public class WorkingTimeCalculatorTest {
|
||||
class WorkingTimeCalculatorTest {
|
||||
|
||||
private final WorkingTimeCalculator calculator;
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
private boolean addClassificationNameToSelectClauseForOrdering = false;
|
||||
private boolean addAttachmentClassificationNameToSelectClauseForOrdering = false;
|
||||
private boolean addWorkbasketNameToSelectClauseForOrdering = false;
|
||||
private boolean joinWithUserInfo;
|
||||
|
||||
// region id
|
||||
private String[] taskId;
|
||||
|
@ -182,6 +183,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
private String[] ownerLongNameNotIn;
|
||||
private String[] ownerLongNameLike;
|
||||
private String[] ownerLongNameNotLike;
|
||||
// endregion
|
||||
// region primaryObjectReference
|
||||
private ObjectReference[] objectReferences;
|
||||
// endregion
|
||||
|
@ -327,7 +329,6 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
private WildcardSearchField[] wildcardSearchFieldIn;
|
||||
private String wildcardSearchValueLike;
|
||||
// endregion
|
||||
private boolean joinWithUserInfo;
|
||||
|
||||
TaskQueryImpl(InternalTaskanaEngine taskanaEngine) {
|
||||
this.taskanaEngine = taskanaEngine;
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
package acceptance.task;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import pro.taskana.common.api.BaseQuery.SortDirection;
|
||||
import pro.taskana.common.test.security.JaasExtension;
|
||||
|
||||
/**
|
||||
* Acceptance test for the usecase of adding/removing an attachment of a task and update the result
|
||||
* correctly.
|
||||
*/
|
||||
@ExtendWith(JaasExtension.class)
|
||||
class QueryTaskByClassificationNameAccTest extends AbstractAccTest {
|
||||
|
||||
private static SortDirection asc = SortDirection.ASCENDING;
|
||||
private static SortDirection desc = SortDirection.DESCENDING;
|
||||
}
|
|
@ -481,7 +481,7 @@ public class TimeIntervalReportFilterParameter
|
|||
Optional.ofNullable(inWorkingDays)
|
||||
.ifPresent(
|
||||
bool -> {
|
||||
if (bool) {
|
||||
if (Boolean.TRUE.equals(bool)) {
|
||||
builder.inWorkingDays();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -109,13 +109,8 @@ class WorkbasketControllerIntTest {
|
|||
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(parameters))
|
||||
.isTrue();
|
||||
assertThat(response.getBody().getRequiredLink(IanaLinkRelations.SELF).getHref())
|
||||
.endsWith(parameters);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -203,13 +198,8 @@ class WorkbasketControllerIntTest {
|
|||
assertThat(response.getBody().getLink(IanaLinkRelations.LAST)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.NEXT)).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.PREV)).isNotNull();
|
||||
assertThat(
|
||||
response
|
||||
.getBody()
|
||||
.getRequiredLink(IanaLinkRelations.SELF)
|
||||
.getHref()
|
||||
.endsWith(parameters))
|
||||
.isTrue();
|
||||
assertThat(response.getBody().getRequiredLink(IanaLinkRelations.SELF).getHref())
|
||||
.endsWith(parameters);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue