@@ -106,9 +106,8 @@ public void onError(ObjectServerError error) {
106106
107107 @ Test
108108 @ RunTestInLooperThread (emulateMainThread = true )
109- @ Ignore ("See https://github.com/realm/ros/issues/437" )
110109 public void getPermissions_updatedWithNewRealms () {
111- PermissionManager pm = user .getPermissionManager ();
110+ final PermissionManager pm = user .getPermissionManager ();
112111 looperThread .closeAfterTest (pm );
113112 pm .getPermissions (new PermissionManager .PermissionsCallback () {
114113 @ Override
@@ -132,6 +131,7 @@ public void onError(SyncSession session, ObjectServerError error) {
132131 permissions .addChangeListener (new RealmChangeListener <RealmResults <Permission >>() {
133132 @ Override
134133 public void onChange (RealmResults <Permission > permissions ) {
134+ RealmLog .error (String .format ("2ndCallback: Size: %s, Permissions: %s" , permissions .size (), Arrays .toString (permissions .toArray ())));
135135 Permission p = permissions .where ().endsWith ("path" , "tests2" ).findFirst ();
136136 if (p != null ) {
137137 assertTrue (p .mayRead ());
@@ -152,8 +152,8 @@ public void onError(ObjectServerError error) {
152152
153153 @ Test
154154 @ RunTestInLooperThread (emulateMainThread = true )
155- @ Ignore ("See https://github.com/realm/ros/issues/437" )
156155 public void getPermissions_updatedWithNewRealms_stressTest () {
156+ final int TEST_SIZE = 10 ;
157157 final PermissionManager pm = user .getPermissionManager ();
158158 looperThread .closeAfterTest (pm );
159159 pm .getPermissions (new PermissionManager .PermissionsCallback () {
@@ -162,8 +162,8 @@ public void onSuccess(RealmResults<Permission> permissions) {
162162 assertTrue (permissions .isLoaded ());
163163 assertInitialPermissions (permissions );
164164
165- for (int i = 0 ; i < 10 ; i ++) {
166- SyncConfiguration configNew = new SyncConfiguration .Builder (user , "realm://127.0.0.1:9080 /~/test" + i ).build ();
165+ for (int i = 0 ; i < TEST_SIZE ; i ++) {
166+ SyncConfiguration configNew = new SyncConfiguration .Builder (user , "realm://" + Constants . HOST + " /~/test" + i ).build ();
167167 Realm newRealm = Realm .getInstance (configNew );
168168 looperThread .closeAfterTest (newRealm );
169169 }
@@ -173,8 +173,8 @@ public void onSuccess(RealmResults<Permission> permissions) {
173173 permissions .addChangeListener (new RealmChangeListener <RealmResults <Permission >>() {
174174 @ Override
175175 public void onChange (RealmResults <Permission > permissions ) {
176- RealmLog .error (Arrays .toString (permissions .toArray ())); // FIXME Debug output for CI. Remove before release.
177- Permission p = permissions .where ().endsWith ("path" , "test9" ).findFirst ();
176+ RealmLog .error (String . format ( "Size: %s, Permissions: %s" , permissions . size (), Arrays .toString (permissions .toArray ())));
177+ Permission p = permissions .where ().endsWith ("path" , "test" + ( TEST_SIZE - 1 ) ).findFirst ();
178178 if (p != null ) {
179179 assertTrue (p .mayRead ());
180180 assertTrue (p .mayWrite ());
@@ -243,7 +243,7 @@ public void onError(ObjectServerError error) {
243243
244244 @ Test
245245 @ RunTestInLooperThread (emulateMainThread = true )
246- @ Ignore ("See https://github.com/realm/ros/issues/432 " )
246+ @ Ignore ("Wait for default permission Realm support " )
247247 public void getPermissions_addTaskAfterClientReset () {
248248 final PermissionManager pm = user .getPermissionManager ();
249249 looperThread .closeAfterTest (pm );
@@ -428,7 +428,7 @@ public void onError(ObjectServerError error) {
428428
429429 @ Test
430430 @ RunTestInLooperThread (emulateMainThread = true )
431- @ Ignore ("See https://github.com/realm/ros/issues/432 " )
431+ @ Ignore ("See https://github.com/realm/ros/issues/520 " )
432432 public void getDefaultPermissions_returnLoadedResults () {
433433 PermissionManager pm = user .getPermissionManager ();
434434 looperThread .closeAfterTest (pm );
@@ -449,7 +449,7 @@ public void onError(ObjectServerError error) {
449449
450450 @ Test
451451 @ RunTestInLooperThread (emulateMainThread = true )
452- @ Ignore ("See https://github.com/realm/ros/issues/432 " )
452+ @ Ignore ("See https://github.com/realm/ros/issues/520 " )
453453 public void getDefaultPermissions_noLongerValidWhenPermissionManagerIsClosed () {
454454 final PermissionManager pm = user .getPermissionManager ();
455455 pm .getDefaultPermissions (new PermissionManager .PermissionsCallback () {
@@ -481,6 +481,7 @@ public void getDefaultPermissions_updatedWithNewRealms() {
481481
482482 @ Test
483483 @ RunTestInLooperThread (emulateMainThread = true )
484+ @ Ignore ("See https://github.com/realm/ros/issues/520" )
484485 public void getDefaultPermissions_closed () throws IOException {
485486 PermissionManager pm = user .getPermissionManager ();
486487 pm .close ();
@@ -716,7 +717,6 @@ public void onError(ObjectServerError error) {
716717
717718 @ Test
718719 @ RunTestInLooperThread (emulateMainThread = true )
719- @ Ignore ("See https://github.com/realm/ros/issues/426" )
720720 public void applyPermissions_withUsername () {
721721 String user1Username = TestHelper .getRandomEmail ();
722722 String user2Username = TestHelper .getRandomEmail ();
@@ -831,7 +831,6 @@ public void onError(ObjectServerError error) {
831831
832832 @ Test
833833 @ RunTestInLooperThread (emulateMainThread = true )
834- @ Ignore ("See https://github.com/realm/ros/issues/430" )
835834 public void makeOffer_noManageAccessThrows () {
836835 // User 2 creates a Realm
837836 SyncUser user2 = UserFactory .createUniqueUser ();
@@ -1208,19 +1207,7 @@ public void onChange(Progress progress) {
12081207 * states and fail if neither of these can be verified.
12091208 */
12101209 private void assertInitialPermissions (RealmResults <Permission > permissions ) {
1211- // For a new user, the PermissionManager should contain 1 entry for the __permission Realm, but we are
1212- // creating the __management Realm at the same time, so this might be here as well.
1213- permissions = permissions .sort ("path" );
1214- if (permissions .size () == 1 ) {
1215- // FIXME It is very unpredictable which Permission is returned. This needs to be fixed.
1216- Permission permission = permissions .first ();
1217- assertTrue (permission .getPath ().endsWith ("__permission" ) || permission .getPath ().endsWith ("__management" ));
1218- } else if (permissions .size () == 2 ) {
1219- assertTrue ("Failed: " + permissions .get (0 ).toString (), permissions .get (0 ).getPath ().endsWith ("__management" ));
1220- assertTrue ("Failed: " + permissions .get (1 ).toString (), permissions .get (1 ).getPath ().endsWith ("__permission" ));
1221- } else {
1222- fail ("Permission Realm contains unknown permissions: " + Arrays .toString (permissions .toArray ()));
1223- }
1210+ assertEquals ("Could not find __permissions Realm" , 1 , permissions .where ().endsWith ("path" , "__permission" ).count ());
1211+ assertEquals ("Could not find __management Realm" , 1 , permissions .where ().endsWith ("path" , "__management" ).count ());
12241212 }
1225-
12261213}
0 commit comments