1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.core.logic;
20
21 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
22 import static org.mockito.Mockito.mock;
23 import static org.mockito.Mockito.when;
24
25 import java.util.List;
26 import java.util.stream.Stream;
27 import org.apache.syncope.common.lib.scim.SCIMConf;
28 import org.apache.syncope.common.lib.to.UserTO;
29 import org.apache.syncope.core.logic.scim.SCIMConfManager;
30 import org.apache.syncope.core.spring.security.AuthDataAccessor;
31 import org.apache.syncope.ext.scimv2.api.data.SCIMPatchOperation;
32 import org.apache.syncope.ext.scimv2.api.data.SCIMPatchPath;
33 import org.junit.jupiter.api.BeforeAll;
34 import org.junit.jupiter.api.TestInstance;
35 import org.junit.jupiter.params.ParameterizedTest;
36 import org.junit.jupiter.params.provider.MethodSource;
37
38 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
39 class SCIMDataBinderTest {
40
41 private SCIMDataBinder dataBinder;
42
43 private static Stream<String> getValue() {
44 return Stream.of("True", "False");
45 }
46
47 @BeforeAll
48 void setup() {
49 SCIMConfManager scimConfManager = mock(SCIMConfManager.class);
50 when(scimConfManager.get()).thenReturn(new SCIMConf());
51 UserLogic userLogic = mock(UserLogic.class);
52 AuthDataAccessor authDataAccessor = mock(AuthDataAccessor.class);
53 dataBinder = new SCIMDataBinder(scimConfManager, userLogic, authDataAccessor);
54 }
55
56 @ParameterizedTest
57 @MethodSource("getValue")
58 void toUserUpdate(final String value) {
59 SCIMPatchOperation operation = new SCIMPatchOperation();
60 SCIMPatchPath scimPatchPath = new SCIMPatchPath();
61 scimPatchPath.setAttribute("active");
62 operation.setPath(scimPatchPath);
63 operation.setValue(List.of(value));
64 assertDoesNotThrow(() -> dataBinder.toUserUpdate(new UserTO(), List.of(), operation));
65 }
66 }