NCMBRole extends NCMBBase { public void createRoleInBackground(final DoneCallback callback) { NCMBRoleService roleService = (NCMBRoleService) NCMB.factory(NCMB.ServiceType.ROLE); try { roleService.createRoleInBackground(getRoleName(), new ExecuteServiceCallback() { @Override public void done(JSONObject json, NCMBException e) { if (e != null) { if (callback != null) { callback.done(e); } } else { if (json != null) { mFields = json; } if (callback != null) { callback.done(null); } } } }); } catch (NCMBException e) { if (callback != null) { callback.done(e); } } } NCMBRole();  NCMBRole(String name);   NCMBRole(JSONObject params); static NCMBQuery<NCMBRole> getQuery(); String getRoleName(); void setRoleName(String name); void addUser(List<NCMBUser> users); void addUserInBackground(List<NCMBUser> users, final DoneCallback callback); void removeUser(List<NCMBUser> users); void removeUserInBackground(List<NCMBUser> users, final DoneCallback callback); void addRole(List<NCMBRole> roles); void addRoleInBackground(List<NCMBRole> roles, final DoneCallback callback); void removeRole(List<NCMBRole> roles); void removeRoleInBackground(List<NCMBRole> roles, final DoneCallback callback); void createRole(); void createRoleInBackground(final DoneCallback callback); void fetchObject(); void fetchObjectInBackground(final FetchCallback callback); void deleteObject(); void deleteObjectInBackground(final DoneCallback callback);  }
@Test public void createRoleInBackground() throws Exception { NCMBRole role = new NCMBRole(); role.setRoleName("dummyRoleName"); role.createRoleInBackground(new DoneCallback() { @Override public void done(NCMBException e) { if (e != null) { Assert.fail(e.getMessage()); } callbackFlag = true; } }); Robolectric.flushBackgroundThreadScheduler(); ShadowLooper.runUiThreadTasks(); Assert.assertEquals("dummyObjectId", role.getObjectId()); Robolectric.flushBackgroundThreadScheduler(); ShadowLooper.runUiThreadTasks(); Assert.assertTrue(callbackFlag); }