1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.fit.core.wa;
20
21 import static org.junit.jupiter.api.Assertions.assertFalse;
22 import static org.junit.jupiter.api.Assertions.assertNotNull;
23 import static org.junit.jupiter.api.Assertions.assertThrows;
24
25 import java.io.Serializable;
26 import java.util.Collection;
27 import java.util.List;
28 import java.util.UUID;
29 import org.apache.syncope.common.lib.Attr;
30 import org.apache.syncope.common.lib.SyncopeClientException;
31 import org.apache.syncope.fit.AbstractITCase;
32 import org.junit.jupiter.api.Test;
33
34 public class WAConfigITCase extends AbstractITCase {
35
36 private static Attr runTest(final List<String> initialValue, final List<String> updatedValue) {
37 Attr config = new Attr.Builder(UUID.randomUUID().toString()).values(initialValue).build();
38 WA_CONFIG_SERVICE.set(config);
39
40 assertFalse(WA_CONFIG_SERVICE.list().isEmpty());
41
42 config = WA_CONFIG_SERVICE.get(config.getSchema());
43 assertNotNull(config);
44
45 config = new Attr.Builder(config.getSchema()).values(updatedValue).build();
46 WA_CONFIG_SERVICE.set(config);
47
48 Attr updatedTO = WA_CONFIG_SERVICE.get(config.getSchema());
49 updatedTO.getValues().stream().allMatch(((Collection) updatedValue)::contains);
50 return updatedTO;
51 }
52
53 private static <T extends Serializable> void deleteEntry(final Attr configTO) {
54 WA_CONFIG_SERVICE.delete(configTO.getSchema());
55 assertThrows(SyncopeClientException.class, () -> WA_CONFIG_SERVICE.get(configTO.getSchema()));
56 }
57
58 @Test
59 public void verify() {
60 deleteEntry(runTest(List.of("v1", "v2"), List.of("newValue")));
61 deleteEntry(runTest(List.of("12345"), List.of("98765")));
62 deleteEntry(runTest(List.of("123.45"), List.of("987.65")));
63 deleteEntry(runTest(List.of("1", "2", "3"), List.of("4", "5", "6")));
64 }
65 }