Java Code Examples for io.reactivex.observers.TestObserver#assertResult()
The following examples show how to use
io.reactivex.observers.TestObserver#assertResult() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Modern_Testing.java From Reactive-Programming-With-Java-9 with MIT License | 6 votes |
@Test public void test_just_new() { Observable<Integer> observable = Observable.just(12, 34, 6); TestObserver<Integer> testObserver = new TestObserver<>(); observable.subscribe(testObserver); List<Integer> list = new ArrayList(); testObserver.assertComplete(); testObserver.assertResult(12, 34, 6); testObserver.assertValueCount(3); testObserver.assertNoErrors(); testObserver.assertValueAt(2, (value) -> { // TODO Auto-generated method stub return value == 34; }); }
Example 2
Source File: JWKServiceTest.java From graviteeio-access-management with Apache License 2.0 | 6 votes |
@Test public void testFilter_noneMatch() { OKPKey okpSig = new OKPKey(); okpSig.setKty("OKP"); okpSig.setKid("okpSig"); okpSig.setCrv("Ed25519"); JWKSet okpSet = new JWKSet(); okpSet.setKeys(Arrays.asList(okpSig)); TestObserver testObserver = jwkService.filter(okpSet, JWKFilter.CURVE_KEY_ENCRYPTION()).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult(); }
Example 3
Source File: RealRxPermissionTest.java From RxPermission with Apache License 2.0 | 5 votes |
@Test @TargetApi(M) public void requestGranted() { doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE); final TestObserver<Permission> o = rxPermission.request(READ_PHONE_STATE) .test(); rxPermission.onRequestPermissionsResult(permissionGranted(), FALSE_ARRAY, FALSE_ARRAY, READ_PHONE_STATE); o.assertResult(Permission.granted(READ_PHONE_STATE)); }
Example 4
Source File: JWKServiceTest.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
@Test public void testGetClientKeys_fromJksProperty() { JWK jwk = Mockito.mock(JWK.class); JWKSet jwkSet = new JWKSet(); jwkSet.setKeys(Arrays.asList(jwk)); Client client = new Client(); client.setJwks(jwkSet); TestObserver testObserver = jwkService.getKeys(client).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult(client.getJwks()); }
Example 5
Source File: JWKServiceTest.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
@Test public void testGetClientKeys_noKeys() { TestObserver testObserver = jwkService.getKeys(new Client()).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult();//Expect empty result }
Example 6
Source File: JWKServiceTest.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
@Test public void testGetKey_ok() { JWK jwk = Mockito.mock(JWK.class); JWKSet jwkSet = new JWKSet(); jwkSet.setKeys(Arrays.asList(jwk)); when(jwk.getKid()).thenReturn("expectedKid"); TestObserver testObserver = jwkService.getKey(jwkSet,"expectedKid").test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult(jwk); }
Example 7
Source File: JWKServiceTest.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
@Test public void testGetKey_noKFound() { JWK jwk = Mockito.mock(JWK.class); JWKSet jwkSet = new JWKSet(); jwkSet.setKeys(Arrays.asList(jwk)); when(jwk.getKid()).thenReturn("notTheExpectedOne"); TestObserver testObserver = jwkService.getKey(jwkSet,"expectedKid").test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult();//Expect empty result }
Example 8
Source File: JWKServiceTest.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
@Test public void testGetKey_noKid() { JWK jwk = Mockito.mock(JWK.class); JWKSet jwkSet = new JWKSet(); jwkSet.setKeys(Arrays.asList(jwk)); TestObserver testObserver = jwkService.getKey(jwkSet,null).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult();//Expect empty result }
Example 9
Source File: SearchInteractorTest.java From marvel with MIT License | 5 votes |
@Test public void testLoadCharacters() throws Exception { TestObserver<CharactersResponse> testSubscriber = new TestObserver<>(); // call interactor with some random params interactor.loadCharacter("query", "privateKey", "publicKey", 1) .subscribe(testSubscriber); // it must return the expectedResult with no error testSubscriber.assertNoErrors(); testSubscriber.assertResult(expectedResult); }
Example 10
Source File: RealRxPermissionTest.java From RxPermission with Apache License 2.0 | 5 votes |
@Test @TargetApi(M) public void requestEachSeveralPermissionsOneRevoked() { final String[] permissions = { READ_PHONE_STATE, CAMERA }; doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE); doReturn(false).when(rxPermission).isGranted(CAMERA); doReturn(true).when(rxPermission).isRevokedByPolicy(CAMERA); final TestObserver<Permission> o = rxPermission.requestEach(permissions) .test(); rxPermission.onRequestPermissionsResult(permissionGranted(), FALSE_ARRAY, FALSE_ARRAY, READ_PHONE_STATE); o.assertResult(Permission.granted(READ_PHONE_STATE), Permission.revokedByPolicy(CAMERA)); }
Example 11
Source File: JWEServiceTest.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
@Test public void encryptIdToken_noEncryption() { String jwt = "JWT"; TestObserver testObserver = jweService.encryptIdToken(jwt, new Client()).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult(jwt); }
Example 12
Source File: JWKServiceTest.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
@Test public void testFilter_AES_no_192_keys() { OCTKey oct128 = new OCTKey(); oct128.setKty("oct"); oct128.setKid("octEnc128"); oct128.setUse("enc"); oct128.setK("d8unGeXwCEDFsYBiaWuyKg");//128bits (16 bytes) OCTKey oct256 = new OCTKey(); oct256.setKty("oct"); oct256.setKid("octEnc256"); oct256.setUse("enc"); oct256.setK("RlrxxWClnDX_dpa47lvC29vBiB-ZDCg-b8n70Ugefyo");//256bits (32 bytes) OCTKey octSig = new OCTKey(); octSig.setKty("oct"); octSig.setKid("octSig"); octSig.setUse("sig"); JWKSet jwkSet = new JWKSet(); jwkSet.setKeys(Arrays.asList(oct128, oct256, octSig)); TestObserver testObserver = jwkService.filter(jwkSet, JWKFilter.OCT_KEY_ENCRYPTION(JWEAlgorithm.A192KW)).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult(); testObserver = jwkService.filter(jwkSet, JWKFilter.OCT_KEY_ENCRYPTION(JWEAlgorithm.A192GCMKW)).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult(); }
Example 13
Source File: RealRxPermissionTest.java From RxPermission with Apache License 2.0 | 5 votes |
@Test @TargetApi(M) public void requestEachSeveralPermissionsGranted() { final String[] permissions = { READ_PHONE_STATE, CAMERA }; doReturn(false).when(rxPermission).isGranted(anyString()); final int[] result = { PERMISSION_GRANTED, PERMISSION_GRANTED }; final TestObserver<Permission> o = rxPermission.requestEach(permissions) .test(); rxPermission.onRequestPermissionsResult(result, FALSE_ARRAY_2, FALSE_ARRAY_2, permissions); o.assertResult(Permission.granted(READ_PHONE_STATE), Permission.granted(CAMERA)); }
Example 14
Source File: JWEServiceTest.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
@Test public void encryptUserinfo_noEncryption() { String jwt = "JWT"; TestObserver testObserver = jweService.encryptUserinfo(jwt, new Client()).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult(jwt); }
Example 15
Source File: JWKServiceTest.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
@Test public void testFilter_AES_no_128_keys() { OCTKey oct192 = new OCTKey(); oct192.setKty("oct"); oct192.setKid("octEnc192"); oct192.setUse("enc"); oct192.setK("G9jUYv3b0-0wZWCGxAnIUH6gI0kjeXj4");//192bits (24 bytes) OCTKey oct256 = new OCTKey(); oct256.setKty("oct"); oct256.setKid("octEnc256"); oct256.setUse("enc"); oct256.setK("RlrxxWClnDX_dpa47lvC29vBiB-ZDCg-b8n70Ugefyo");//256bits (32 bytes) OCTKey octSig = new OCTKey(); octSig.setKty("oct"); octSig.setKid("octSig"); octSig.setUse("sig"); JWKSet jwkSet = new JWKSet(); jwkSet.setKeys(Arrays.asList(oct192, oct256, octSig)); TestObserver testObserver = jwkService.filter(jwkSet, JWKFilter.OCT_KEY_ENCRYPTION(JWEAlgorithm.A128KW)).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult(); testObserver = jwkService.filter(jwkSet, JWKFilter.OCT_KEY_ENCRYPTION(JWEAlgorithm.A128GCMKW)).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult(); }
Example 16
Source File: JWKServiceTest.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
@Test public void testFilter_AES_notMatchingAlgorithm() { TestObserver testObserver = jwkService.filter(JWK_SET, JWKFilter.OCT_KEY_ENCRYPTION(JWEAlgorithm.parse("none"))).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult(); }
Example 17
Source File: RealRxPermissionTest.java From RxPermission with Apache License 2.0 | 5 votes |
@Test @TargetApi(M) public void requestEachGranted() { doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE); final TestObserver<Permission> o = rxPermission.requestEach(READ_PHONE_STATE) .test(); rxPermission.onRequestPermissionsResult(permissionGranted(), FALSE_ARRAY, FALSE_ARRAY, READ_PHONE_STATE); o.assertResult(Permission.granted(READ_PHONE_STATE)); }
Example 18
Source File: RealRxPermissionTest.java From RxPermission with Apache License 2.0 | 5 votes |
@Test @TargetApi(M) public void requestDeniedNotShown() { doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE); final TestObserver<Permission> o = rxPermission.request(READ_PHONE_STATE) .test(); rxPermission.onRequestPermissionsResult(permissionDenied(), FALSE_ARRAY, FALSE_ARRAY, READ_PHONE_STATE); o.assertResult(Permission.deniedNotShown(READ_PHONE_STATE)); }
Example 19
Source File: RealRxPermissionTest.java From RxPermission with Apache License 2.0 | 5 votes |
@Test @TargetApi(M) public void requestDeniedAnyOtherTime() { doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE); final TestObserver<Permission> o = rxPermission.request(READ_PHONE_STATE) .test(); rxPermission.onRequestPermissionsResult(permissionDenied(), TRUE_ARRAY, TRUE_ARRAY, READ_PHONE_STATE); o.assertResult(Permission.denied(READ_PHONE_STATE)); }
Example 20
Source File: JWKServiceTest.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
private void testFilter_expectEmptyResult(JWKSet jwkSet) { TestObserver testObserver = jwkService.filter(jwkSet,null).test(); testObserver.assertNoErrors(); testObserver.assertComplete(); testObserver.assertResult();//Expect empty result }