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);
  }
 /**
  * Deletes <tt>CapitalMarketsOrder</tt> from cache matching <tt>objectId</tt>.
  *
  * @param objectId the remote object id.
  */
 public static void deleteAllInCacheWithObjectIdPredicate(String objectId) {
   com.anypresence.sdk.APSDKSetup.getCacheManager()
       .deleteAllInCacheWithObjectIdPredicate(CapitalMarketsOrder.class, objectId);
 }
 /**
  * Deletes <tt>CapitalMarketsOrder</tt> from cache matching <tt>scope</tt>.
  *
  * @param scope the scope.
  */
 public static void deleteAllInCacheWithScopePredicate(String scope) {
   com.anypresence.sdk.APSDKSetup.getCacheManager()
       .deleteAllInCacheWithScopePredicate(CapitalMarketsOrder.class, scope);
 }
 /**
  * Fetches <tt>CapitalMarketsOrder</tt> from cache with latest request.
  *
  * @param scope the scope to perform the query.
  * @param params a map of parameters.
  * @param offset offset for the query, or <tt>null</tt> for no offset.
  * @param limit max results to return back, <tt>null</tt> for no limit.
  * @return a list of <tt>CapitalMarketsOrder</tt>;
  */
 public static List<CapitalMarketsOrder> fetchInCacheWithLatestAPCachedRequestPredicate(
     String scope, Map<String, String> params, Integer offset, Integer limit) {
   return com.anypresence.sdk.APSDKSetup.getCacheManager()
       .fetchInCacheWithLatestAPCachedRequestPredicate(
           CapitalMarketsOrder.class, scope, params, offset, limit);
 }
 /**
  * Fetches <tt>CapitalMarketsOrder</tt> from cache with predicates.
  *
  * @see
  *     com.anypresence.anypresence_inc.citi_mobile_challenge.dao.CapitalMarketsOrderDao.Properties
  * @param predicates hash of predicates
  * @return a list of <tt>CapitalMarketsOrder</tt>
  */
 public static List<CapitalMarketsOrder> fetchInCacheWithPredicates(
     Map<String, String> predicates) {
   return com.anypresence.sdk.APSDKSetup.getCacheManager()
       .fetchInCacheWithPredicates(CapitalMarketsOrder.class, predicates);
 }
 /**
  * Fetches <tt>CapitalMarketsOrder</tt> from cache by searching for requests matching the exact
  * scope and parameters provided.
  *
  * <p>Example:
  *
  * <pre>{@code
  * Map<String,String> params = new HashMap<String,String>();
  * params.put("name", "test");
  * CapitalMarketsOrder.queryInBackground("all", params, new APCallback<List<CapitalMarketsOrder>>() {
  *
  *     public void finished(List<CapitalMarketsOrder> objects, Throwable ex) {
  *         if (ex == null) {
  *             Log.i(TAG, "Objects fetched!");
  *         } else {
  *             Log.e(TAG, "Unable to fetch objects!", ex);
  *         }
  *     }
  * });
  * // Get the cached objects from the above query.
  * CapitalMarketsOrder.fetchInCacheWithParameterPredicate("all", params);
  * }</pre>
  *
  * @param scope the scope
  * @param params the parameter
  * @return a list of <tt>CapitalMarketsOrder</tt>;
  */
 public static List<CapitalMarketsOrder> fetchInCacheWithParameterPredicate(
     String scope, Map<String, String> params) {
   return com.anypresence.sdk.APSDKSetup.getCacheManager()
       .fetchInCacheWithParameterPredicate(CapitalMarketsOrder.class, scope, params);
 }
 /**
  * Fetches <tt>CapitalMarketsOrder</tt> from cache with provided request.
  *
  * @param request instance of
  *     <tt>com.anypresence.anypresence_inc.citi_mobile_challenge.dao.APCachedRequest</tt>.
  * @return a list of <tt>CapitalMarketsOrder</tt>;
  */
 public static List<CapitalMarketsOrder> fetchInCacheWithAPCachedRequestPredicate(
     IAPCachedRequest request) {
   return com.anypresence.sdk.APSDKSetup.getCacheManager()
       .fetchInCacheWithAPCachedRequestPredicate(CapitalMarketsOrder.class, request);
 }
 /**
  * Fetches <tt>CapitalMarketsOrder</tt> from cache with provided remote object id.
  *
  * @param objectId the remote object id.
  * @return a list of <tt>CapitalMarketsOrder</tt>;
  */
 public static List<CapitalMarketsOrder> fetchInCacheWithObjectIdPredicate(String objectId) {
   return com.anypresence.sdk.APSDKSetup.getCacheManager()
       .fetchInCacheWithObjectIdPredicate(CapitalMarketsOrder.class, objectId);
 }
 /** Saves object into cache with provided <tt>APCachedRequest</tt>. */
 public void saveInCacheWithRequest(IAPCachedRequest request) {
   com.anypresence.sdk.APSDKSetup.getCacheManager()
       .saveInCacheWithRequest(CapitalMarketsOrder.class, this, request);
 }
 /** Saves object into cache with provided scope. */
 public void saveInCache(String scope) {
   com.anypresence.sdk.APSDKSetup.getCacheManager()
       .saveInCache(CapitalMarketsOrder.class, this, scope);
 }
 /** Updates object in cache if the object id is not null. */
 public void updateInCache() {
   com.anypresence.sdk.APSDKSetup.getCacheManager().updateInCache(CapitalMarketsOrder.class, this);
 }
 /**
  * Loads all <tt>CapitalMarketsOrder</tt> objects in local cache.
  *
  * @return list of <tt>CapitalMarketsOrder</tt>
  */
 public static List<CapitalMarketsOrder> loadAllInCache() {
   return com.anypresence.sdk.APSDKSetup.getCacheManager()
       .loadAllInCache(CapitalMarketsOrder.class);
 }