Пример #1
0
 public static void testGetAllLogs() {
   final String geoCode = "OC10CB8";
   final Geocache cache = OkapiClient.getCache(geoCode);
   final int defaultLogCount = 10;
   assert cache != null; // eclipse null analysis
   assertThat(cache.getLogs().size()).isGreaterThan(defaultLogCount);
 }
Пример #2
0
 public static void testShortDescription() {
   final String geoCode = "OC10C06";
   final Geocache cache = OkapiClient.getCache(geoCode);
   assert cache != null; // eclipse null analysis
   assertThat(cache.getShortDescription())
       .isEqualTo("Nur in der fünften Jahreszeit kann er sprechen");
 }
Пример #3
0
  public static void testOCWillAttendLogs() {
    final String geoCode = "OC6465";

    removeCacheCompletely(geoCode);
    final Geocache cache = OkapiClient.getCache(geoCode);
    assertThat(cache).as("Cache from OKAPI").isNotNull();
    assertThat(cache.getLogCounts().get(LogType.WILL_ATTEND)).isGreaterThan(0);
  }
Пример #4
0
 public static void testOCSearchMustWorkWithoutOAuthAccessTokens() {
   final String geoCode = "OC1234";
   final Geocache cache = OkapiClient.getCache(geoCode);
   assertThat(cache)
       .overridingErrorMessage(
           "You must have a valid OKAPI key installed for running this test (but you do not need to set credentials in the app).")
       .isNotNull();
   assertThat(cache.getName()).isEqualTo("Wupper-Schein");
 }
Пример #5
0
 @Override
 public boolean login(final Handler handler, final Context fromActivity) {
   if (supportsPersonalization()) {
     userInfo = OkapiClient.getUserInfo(this);
   } else {
     userInfo = new UserInfo(StringUtils.EMPTY, 0, UserInfoStatus.NOT_SUPPORTED);
   }
   return userInfo.getStatus() == UserInfoStatus.SUCCESSFUL;
 }
Пример #6
0
  @Override
  public boolean removeFromWatchlist(Geocache cache) {
    final boolean removed = OkapiClient.setWatchState(cache, false, this);

    if (removed) {
      cgData.saveChangedCache(cache);
    }

    return removed;
  }
Пример #7
0
  @Override
  public boolean addToWatchlist(Geocache cache) {
    final boolean added = OkapiClient.setWatchState(cache, true, this);

    if (added) {
      cgData.saveChangedCache(cache);
    }

    return added;
  }
Пример #8
0
  public static void testOCCacheWithWaypoints() {
    final String geoCode = "OCDDD2";
    removeCacheCompletely(geoCode);
    Geocache cache = OkapiClient.getCache(geoCode);
    assertThat(cache).as("Cache from OKAPI").isNotNull();
    // cache should be stored to DB (to listID 0) when loaded above
    cache = DataStore.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY);
    assert cache != null;
    assertThat(cache).isNotNull();
    assertThat(cache.getWaypoints()).hasSize(3);

    // load again
    cache.refreshSynchronous(null);
    assertThat(cache.getWaypoints()).hasSize(3);
  }
Пример #9
0
 public static void testGetOCCache() {
   final String geoCode = "OU0331";
   Geocache cache = OkapiClient.getCache(geoCode);
   assertThat(cache).as("Cache from OKAPI").isNotNull();
   assertEquals("Unexpected geo code", geoCode, cache.getGeocode());
   assertThat(cache.getName()).isEqualTo("Oshkosh Municipal Tank");
   assertThat(cache.isDetailed()).isTrue();
   // cache should be stored to DB (to listID 0) when loaded above
   cache = DataStore.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY);
   assert cache != null;
   assertThat(cache).isNotNull();
   assertThat(cache.getGeocode()).isEqualTo(geoCode);
   assertThat(cache.getName()).isEqualTo("Oshkosh Municipal Tank");
   assertThat(cache.isDetailed()).isTrue();
   assertThat(cache.getOwnerDisplayName()).isNotEmpty();
   assertThat(cache.getOwnerUserId()).isEqualTo(cache.getOwnerDisplayName());
 }
Пример #10
0
  @Override
  public SearchResult searchByCenter(Geopoint center) {

    return new SearchResult(OkapiClient.getCachesAround(center, this));
  }
Пример #11
0
 @Override
 public SearchResult searchByViewport(Viewport viewport, String[] tokens) {
   return new SearchResult(OkapiClient.getCachesBBox(viewport, this));
 }
Пример #12
0
 public boolean retrieveUserInfo() {
   userInfo = OkapiClient.getUserInfo(this);
   return userInfo.isRetrieveSuccessful();
 }
Пример #13
0
 @Override
 public SearchResult searchByFinder(
     @NonNull final String username, final @NonNull RecaptchaReceiver recaptchaReceiver) {
   return new SearchResult(OkapiClient.getCachesByFinder(username, this));
 }
Пример #14
0
 @Override
 public SearchResult searchByCenter(
     @NonNull final Geopoint center, final @NonNull RecaptchaReceiver recaptchaReceiver) {
   return new SearchResult(OkapiClient.getCachesAround(center, this));
 }
Пример #15
0
 @Override
 public SearchResult searchByViewport(@NonNull final Viewport viewport, final MapTokens tokens) {
   return new SearchResult(OkapiClient.getCachesBBox(viewport, this));
 }
Пример #16
0
 @Override
 public SearchResult searchByKeyword(
     final @NonNull String name, final @NonNull RecaptchaReceiver recaptchaReceiver) {
   final Geopoint currentPos = CgeoApplication.getInstance().currentGeo().getCoords();
   return new SearchResult(OkapiClient.getCachesNamed(currentPos, name, this));
 }