88import org .mockito .Mockito ;
99
1010import java .text .ParseException ;
11+ import java .util .HashMap ;
1112
1213import ch .iterate .hub .client .ApiException ;
14+ import ch .iterate .hub .client .model .TrustedUserDto ;
1315import ch .iterate .hub .workflows .exceptions .AccessException ;
1416import ch .iterate .hub .workflows .exceptions .SecurityFailure ;
1517import com .nimbusds .jose .JOSEException ;
1618
19+ import static org .junit .jupiter .api .Assertions .assertEquals ;
1720import static org .mockito .ArgumentMatchers .any ;
1821import static org .mockito .Mockito .times ;
1922
@@ -22,10 +25,15 @@ class CachingWoTServiceTest {
2225 @ Test
2326 void testGetTrustLevelsPerUserId () throws AccessException , SecurityFailure , ApiException {
2427 final WoTService proxyMock = Mockito .mock (WoTService .class );
28+ final HashMap <String , Integer > trustLevels = new HashMap <String , Integer >() {{
29+ put ("alkdajf" , 5 );
30+ put ("lakdjfa" , 42 );
31+ }};
32+ Mockito .when (proxyMock .getTrustLevelsPerUserId (any ())).thenReturn (trustLevels );
2533 final CachingWoTService service = new CachingWoTService (proxyMock );
26- service .getTrustLevelsPerUserId (null );
34+ assertEquals ( trustLevels , service .getTrustLevelsPerUserId (null ) );
2735 Mockito .verify (proxyMock , times (1 )).getTrustLevelsPerUserId (any ());
28- service .getTrustLevelsPerUserId (null );
36+ assertEquals ( trustLevels , service .getTrustLevelsPerUserId (null ) );
2937 Mockito .verify (proxyMock , times (1 )).getTrustLevelsPerUserId (any ());
3038 }
3139
@@ -42,10 +50,12 @@ void testVerify() throws AccessException, SecurityFailure, ApiException {
4250 @ Test
4351 void testSign () throws AccessException , SecurityFailure , ParseException , JOSEException , ApiException {
4452 final WoTService proxyMock = Mockito .mock (WoTService .class );
53+ final TrustedUserDto trustedUser = new TrustedUserDto ();
54+ Mockito .when (proxyMock .sign (any (), any ())).thenReturn (trustedUser );
4555 final CachingWoTService service = new CachingWoTService (proxyMock );
46- service .sign (null , null );
56+ assertEquals ( trustedUser , service .sign (null , null ) );
4757 Mockito .verify (proxyMock , times (1 )).sign (any (), any ());
48- service .sign (null , null );
58+ assertEquals ( trustedUser , service .sign (null , null ) );
4959 Mockito .verify (proxyMock , times (2 )).sign (any (), any ());
5060 }
5161}
0 commit comments