public static void testTerrainFilter() {
    final Geocache easy = new Geocache();
    easy.setTerrain(1.5f);

    final Geocache hard = new Geocache();
    hard.setTerrain(5f);

    final AbstractRangeFilter easyFilter = new TerrainFilter(1);

    assertTrue(easyFilter.accepts(easy));
    assertFalse(easyFilter.accepts(hard));
  }
Exemplo n.º 2
0
  private static void parseCoreCache(final JSONObject response, final Geocache cache)
      throws JSONException {
    cache.setGeocode(response.getString(CACHE_CODE));
    cache.setName(response.getString(CACHE_NAME));
    // not used: names
    setLocation(cache, response.getString(CACHE_LOCATION));
    cache.setType(getCacheType(response.getString(CACHE_TYPE)));

    final String status = response.getString(CACHE_STATUS);
    cache.setDisabled(status.equalsIgnoreCase(CACHE_STATUS_DISABLED));
    cache.setArchived(status.equalsIgnoreCase(CACHE_STATUS_ARCHIVED));

    cache.setSize(getCacheSize(response));
    cache.setDifficulty((float) response.getDouble(CACHE_DIFFICULTY));
    cache.setTerrain((float) response.getDouble(CACHE_TERRAIN));

    if (!response.isNull(CACHE_IS_FOUND)) {
      cache.setFound(response.getBoolean(CACHE_IS_FOUND));
    }
  }
Exemplo n.º 3
0
  private static void parseCoreCache(final ObjectNode response, final Geocache cache) {
    cache.setGeocode(response.get(CACHE_CODE).asText());
    cache.setName(response.get(CACHE_NAME).asText());
    // not used: names
    setLocation(cache, response.get(CACHE_LOCATION).asText());
    cache.setType(getCacheType(response.get(CACHE_TYPE).asText()));

    final String status = response.get(CACHE_STATUS).asText();
    cache.setDisabled(status.equalsIgnoreCase(CACHE_STATUS_DISABLED));
    cache.setArchived(status.equalsIgnoreCase(CACHE_STATUS_ARCHIVED));

    cache.setSize(getCacheSize(response));
    cache.setDifficulty((float) response.get(CACHE_DIFFICULTY).asDouble());
    cache.setTerrain((float) response.get(CACHE_TERRAIN).asDouble());

    cache.setInventoryItems(response.get(CACHE_TRACKABLES_COUNT).asInt());

    if (response.has(CACHE_IS_FOUND)) {
      cache.setFound(response.get(CACHE_IS_FOUND).asBoolean());
    }
    cache.setHidden(parseDate(response.get(CACHE_HIDDEN).asText()));
  }