public void setup() { APSDKSetup.setDBStoreType(DBStoreType.IN_MEMORY); com.anypresence.rails_droid.RemoteRailsConfig.DEBUG = true; if (context == null) { context = Robolectric.buildActivity(MyActivity.class).attach().create().get(); APSetup.setBaseUrl("http://localhost"); APSetup.setup(); Config.TEST_MODE = true; APSetup.setupOrm(context); } }
@Test public void shouldBeAbleDeleteFromCache() throws com.anypresence.sdk.acl.UnauthorizedException, RemoteRequestException, InterruptedException, ClassNotFoundException { APSetup.setBaseUrl("http://localhost"); APSetup.setup(); Config.getInstance().setStrictQueryFieldCheck(false); APSDKSetup.setDBStoreType(DBStoreType.IN_MEMORY); Config.DEBUG_MODE = true; RemoteRailsConfig.getInstance().setInlineMode(true); lock = new CountDownLatch(1); IRestClient client = getTestRestClient(); RestClientFactory.registerJSONRestClientImplementation(client); com.anypresence.sdk.citi_mobile_challenge.models.RetailBankingLogin.queryInBackground( "all", null, new APFutureCallback< List<com.anypresence.sdk.citi_mobile_challenge.models.RetailBankingLogin>>() { @Override public void finished( List<com.anypresence.sdk.citi_mobile_challenge.models.RetailBankingLogin> arg0, Throwable ex) { objects = arg0; lock.countDown(); } }); lock.await(); Assert.assertTrue(objects.size() == 2); // Delete one object in cache objects.get(0).deleteInCache(); Assert.assertTrue( com.anypresence.sdk.citi_mobile_challenge.models.RetailBankingLogin.loadAllInCache().size() == 1); // Delete all objects in the cache com.anypresence.sdk.APObject.deleteAllInCache(); Assert.assertTrue( com.anypresence.sdk.citi_mobile_challenge.models.RetailBankingLogin.loadAllInCache().size() == 0); }