This repository was archived by the owner on Jan 31, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
algoliasearch/src/test/java/com/algolia/search/saas Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 30
30
import org .json .JSONArray ;
31
31
import org .json .JSONObject ;
32
32
import org .junit .Test ;
33
+ import org .mockito .internal .util .reflection .Whitebox ;
34
+ import org .robolectric .util .concurrent .RoboExecutorService ;
33
35
34
36
import java .util .ArrayList ;
35
37
import java .util .List ;
@@ -51,6 +53,9 @@ public class BrowseIteratorTest extends PowerMockTestCase {
51
53
public void setUp () throws Exception {
52
54
super .setUp ();
53
55
client = new Client (Helpers .app_id , Helpers .api_key );
56
+ // WARNING: Robolectric cannot work with custom executors in `AsyncTask`, so we substitute the client's
57
+ // executor with a Robolectric-compliant one.
58
+ Whitebox .setInternalState (client , "searchExecutorService" , new RoboExecutorService ());
54
59
indexName = Helpers .safeIndexName ("àlgol?à-android" );
55
60
index = client .initIndex (indexName );
56
61
Original file line number Diff line number Diff line change 27
27
import org .json .JSONObject ;
28
28
import org .junit .Test ;
29
29
import org .mockito .internal .util .reflection .Whitebox ;
30
+ import org .robolectric .util .concurrent .RoboExecutorService ;
30
31
31
32
import java .util .ArrayList ;
32
33
import java .util .Arrays ;
@@ -65,6 +66,10 @@ public class IndexTest extends PowerMockTestCase {
65
66
public void setUp () throws Exception {
66
67
super .setUp ();
67
68
client = new Client (Helpers .app_id , Helpers .api_key );
69
+ // WARNING: Robolectric cannot work with custom executors in `AsyncTask`, so we substitute the client's
70
+ // executor with a Robolectric-compliant one.
71
+ Whitebox .setInternalState (client , "searchExecutorService" , new RoboExecutorService ());
72
+
68
73
indexName = Helpers .safeIndexName ("àlgol?à-android" );
69
74
index = client .initIndex (indexName );
70
75
You can’t perform that action at this time.
0 commit comments