This commit is contained in:
parent
78c8db25b9
commit
87e0ddff25
|
@ -1044,6 +1044,24 @@ class TaskanaConfigurationTest {
|
|||
Map.entry("TYPE_A", List.of("A", "B")), Map.entry("TYPE_B", List.of("C", "D"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_OrderClassificationCategoriesByTypeOrder() {
|
||||
TaskanaConfiguration configuration =
|
||||
new Builder(TestContainerExtension.createDataSourceForH2(), false, "TASKANA")
|
||||
.classificationTypes(List.of("type_a", "type_c", "type_b"))
|
||||
.classificationCategoriesByType(
|
||||
Map.ofEntries(
|
||||
Map.entry("type_a", Collections.emptyList()),
|
||||
Map.entry("type_b", Collections.emptyList()),
|
||||
Map.entry("type_c", Collections.emptyList())))
|
||||
.build();
|
||||
|
||||
List<String> expectedKeysOrder = Arrays.asList("TYPE_A", "TYPE_C", "TYPE_B");
|
||||
List<String> actualKeysOrder =
|
||||
new ArrayList<>(configuration.getClassificationCategoriesByType().keySet());
|
||||
assertThat(actualKeysOrder).containsExactlyElementsOf(expectedKeysOrder);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_FillAllTaskanaRoles_When_RoleMapIsIncomplete() {
|
||||
TaskanaConfiguration configuration =
|
||||
|
|
|
@ -16,9 +16,11 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -153,10 +155,14 @@ public class TaskanaConfiguration {
|
|||
// classification configuration
|
||||
this.classificationTypes = Collections.unmodifiableList(builder.classificationTypes);
|
||||
this.classificationCategoriesByType =
|
||||
Collections.unmodifiableMap(
|
||||
builder.classificationCategoriesByType.entrySet().stream()
|
||||
.collect(
|
||||
Collectors.toUnmodifiableMap(
|
||||
Entry::getKey, e -> Collections.unmodifiableList(e.getValue())));
|
||||
Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
e -> Collections.unmodifiableList(e.getValue()),
|
||||
(oldValue, newValue) -> oldValue,
|
||||
LinkedHashMap::new)));
|
||||
// working time configuration
|
||||
this.useWorkingTimeCalculation = builder.useWorkingTimeCalculation;
|
||||
this.workingTimeSchedule =
|
||||
|
@ -1360,7 +1366,13 @@ public class TaskanaConfiguration {
|
|||
e.getValue().stream()
|
||||
.map(String::toUpperCase)
|
||||
.collect(Collectors.toList())))
|
||||
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));
|
||||
.sorted(Comparator.comparingInt(e -> classificationTypes.indexOf(e.getKey())))
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
Map.Entry::getValue,
|
||||
(oldValue, newValue) -> oldValue,
|
||||
LinkedHashMap::new));
|
||||
roleMap =
|
||||
Arrays.stream(TaskanaRole.values())
|
||||
.map(role -> Pair.of(role, roleMap.getOrDefault(role, Set.of())))
|
||||
|
|
Loading…
Reference in New Issue