コード例 #1
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
 public static void testGuessEventTimeShortDescription() {
   final Geocache cache = new Geocache();
   cache.setType(CacheType.EVENT);
   cache.setDescription(StringUtils.EMPTY);
   cache.setShortDescription("text 14:20 text");
   assertThat(cache.guessEventTimeMinutes()).isEqualTo(14 * 60 + 20);
 }
コード例 #2
0
ファイル: LogCacheActivity.java プロジェクト: kozakakos/cgeo
  private void setDefaultValues() {
    date = Calendar.getInstance();
    rating = 0.0;
    if (cache.isEventCache()) {
      final Date eventDate = cache.getHiddenDate();
      boolean expired = DateUtils.daysSince(eventDate.getTime()) > 0;

      if (cache.hasOwnLog(LogType.WILL_ATTEND) || expired) {
        if (cache.hasOwnLog(LogType.ATTENDED)) {
          typeSelected = LogType.NOTE;
        } else {
          typeSelected = LogType.ATTENDED;
        }
      } else {
        typeSelected = LogType.WILL_ATTEND;
      }
    } else {
      if (cache.isFound()) {
        typeSelected = LogType.NOTE;
      } else {
        typeSelected = LogType.FOUND_IT;
      }
    }
    text = null;
    imageCaption = StringUtils.EMPTY;
    imageDescription = StringUtils.EMPTY;
    imageUri = Uri.EMPTY;
  }
コード例 #3
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
 private static void assertTime(final String description, final int hours, final int minutes) {
   final Geocache cache = new Geocache();
   cache.setDescription(description);
   cache.setType(CacheType.EVENT);
   final int minutesAfterMidnight = hours * 60 + minutes;
   assertThat(cache.guessEventTimeMinutes()).isEqualTo(minutesAfterMidnight);
 }
コード例 #4
0
ファイル: SearchResult.java プロジェクト: hakan42/cgeo
  /**
   * @param excludeDisabled
   * @param excludeMine
   * @param cacheType
   * @return
   */
  public SearchResult filterSearchResults(
      final boolean excludeDisabled, final boolean excludeMine, final CacheType cacheType) {

    SearchResult result = new SearchResult(this);
    result.geocodes.clear();
    final ArrayList<Geocache> includedCaches = new ArrayList<Geocache>();
    final Set<Geocache> caches = DataStore.loadCaches(geocodes, LoadFlags.LOAD_CACHE_OR_DB);
    int excluded = 0;
    for (Geocache cache : caches) {
      // Is there any reason to exclude the cache from the list?
      final boolean excludeCache =
          (excludeDisabled && cache.isDisabled())
              || (excludeMine && (cache.isOwner() || cache.isFound()))
              || (!cacheType.contains(cache));
      if (excludeCache) {
        excluded++;
      } else {
        includedCaches.add(cache);
      }
    }
    result.addAndPutInCache(includedCaches);
    // decrease maximum number of caches by filtered ones
    result.setTotalCountGC(result.getTotalCountGC() - excluded);
    GCVote.loadRatings(includedCaches);
    return result;
  }
コード例 #5
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
 public static void testInventory() {
   final Geocache cache = new Geocache();
   final Trackable trackable = new Trackable();
   final List<Trackable> inventory = new ArrayList<>(Collections.singletonList(trackable));
   cache.setInventory(inventory);
   assertThat(cache.getInventory()).isEqualTo(inventory);
   assertThat(cache.getInventoryItems()).isEqualTo(inventory.size());
 }
コード例 #6
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
  public static void testCanBeAddedToCalendar() {
    final Date today = new Date();
    final Geocache cacheToday = new MockedEventCache(today);
    assertThat(cacheToday.canBeAddedToCalendar()).isTrue();

    final Date yesterday = new Date(today.getTime() - 86400 * 1000);
    final MockedEventCache cacheYesterday = new MockedEventCache(yesterday);
    assertThat(cacheYesterday.canBeAddedToCalendar()).isFalse();
  }
コード例 #7
0
 private void setCoordsModificationVisibility(final IConnector con, final Geocache cache) {
   if (cache != null
       && (cache.getType() == CacheType.MYSTERY || cache.getType() == CacheType.MULTI)) {
     coordinatesGroup.setVisibility(View.VISIBLE);
     modifyBoth.setVisibility(con.supportsOwnCoordinates() ? View.VISIBLE : View.GONE);
   } else {
     coordinatesGroup.setVisibility(View.GONE);
     modifyBoth.setVisibility(View.GONE);
   }
 }
コード例 #8
0
        @Override
        protected Void doInBackground(final Void... params) {
          final Waypoint waypoint = new Waypoint(name, type, own);
          waypoint.setGeocode(geocode);
          waypoint.setPrefix(prefix);
          waypoint.setLookup(lookup);
          waypoint.setCoords(coordsToSave);
          waypoint.setNote(noteText);
          waypoint.setVisited(visited);
          waypoint.setId(waypointId);

          final Geocache cache = DataStore.loadCache(geocode, LoadFlags.LOAD_WAYPOINTS);
          if (cache == null) {
            finishHandler.sendEmptyMessage(SAVE_ERROR);
            return null;
          }
          final Waypoint oldWaypoint = cache.getWaypointById(waypointId);
          if (cache.addOrChangeWaypoint(waypoint, true)) {
            DataStore.saveCache(cache, EnumSet.of(SaveFlag.DB));
            if (!StaticMapsProvider.hasAllStaticMapsForWaypoint(geocode, waypoint)) {
              StaticMapsProvider.removeWpStaticMaps(oldWaypoint, geocode);
              if (Settings.isStoreOfflineWpMaps()) {
                StaticMapsProvider.storeWaypointStaticMap(cache, waypoint).subscribe();
              }
            }
            if (modifyLocal.isChecked() || modifyBoth.isChecked()) {
              if (!cache.hasUserModifiedCoords()) {
                final Waypoint origWaypoint =
                    new Waypoint(
                        CgeoApplication.getInstance()
                            .getString(R.string.cache_coordinates_original),
                        WaypointType.ORIGINAL,
                        false);
                origWaypoint.setCoords(cache.getCoords());
                cache.addOrChangeWaypoint(origWaypoint, false);
                cache.setUserModifiedCoords(true);
              }
              cache.setCoords(waypoint.getCoords());
              DataStore.saveChangedCache(cache);
            }
            if (modifyBoth.isChecked() && waypoint.getCoords() != null) {
              finishHandler.sendEmptyMessage(UPLOAD_START);

              if (cache.supportsOwnCoordinates()) {
                final boolean result = uploadModifiedCoords(cache, waypoint.getCoords());
                finishHandler.sendEmptyMessage(result ? SUCCESS : UPLOAD_ERROR);
              } else {
                showToast(getString(R.string.waypoint_coordinates_couldnt_be_modified_on_website));
                finishHandler.sendEmptyMessage(UPLOAD_NOT_POSSIBLE);
              }
            } else {
              finishHandler.sendEmptyMessage(SUCCESS);
            }
          } else {
            finishHandler.sendEmptyMessage(SAVE_ERROR);
          }
          return null;
        }
コード例 #9
0
  public void testCountEqual() {
    Geocache[] pts =
        new Geocache[] {
          new Geocache(1, 2), new Geocache(3, 4), new Geocache(50, 60), new Geocache(1, 2)
        };
    Geocache origin = new Geocache(0, 0);
    Geocache p12 = new Geocache(1, 2);
    assertTrue(p12.equals(pts[0]));
    assertFalse(p12.equals(origin));

    assertEquals(0, StaticMethodsAreEasy.countEqual(pts, origin));
    assertEquals(2, StaticMethodsAreEasy.countEqual(pts, p12));
  }
コード例 #10
0
ファイル: LogCacheActivity.java プロジェクト: kozakakos/cgeo
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    final boolean voteAvailable =
        Settings.isGCvoteLogin()
            && (typeSelected == LogType.FOUND_IT
                || typeSelected == LogType.ATTENDED
                || typeSelected == LogType.WEBCAM_PHOTO_TAKEN)
            && StringUtils.isNotBlank(cache.getGuid())
            && cache.supportsGCVote();
    menu.findItem(SUBMENU_VOTE).setVisible(voteAvailable);

    return true;
  }
コード例 #11
0
ファイル: LogCacheActivity.java プロジェクト: kozakakos/cgeo
 private void updateLogPasswordBox(LogType type) {
   if (type == LogType.FOUND_IT && cache.isLogPasswordRequired()) {
     logPasswordBox.setVisibility(View.VISIBLE);
   } else {
     logPasswordBox.setVisibility(View.GONE);
   }
 }
コード例 #12
0
 public static void startActivityEditWaypoint(
     final Context context, final Geocache cache, final int waypointId) {
   EditWaypointActivity_.intent(context)
       .geocode(cache.getGeocode())
       .waypointId(waypointId)
       .start();
 }
コード例 #13
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
  private void assertWaypointsParsed(final String note, final int expectedWaypoints) {
    recordMapStoreFlags();

    try {
      setMapStoreFlags(false, false);

      final Geocache cache = new Geocache();
      final String geocode = "Test" + System.nanoTime();
      cache.setGeocode(geocode);
      cache.setWaypoints(new ArrayList<Waypoint>(), false);
      for (int i = 0; i < 2; i++) {
        cache.setPersonalNote(note);
        cache.parseWaypointsFromNote();
        final List<Waypoint> waypoints = cache.getWaypoints();
        assertThat(waypoints).isNotNull();
        assertThat(waypoints).hasSize(expectedWaypoints);
        final Waypoint waypoint = waypoints.get(0);
        assertThat(waypoint.getCoords()).isEqualTo(new Geopoint("N51 13.888 E007 03.444"));
        //            assertThat(waypoint.getNote()).isEqualTo("Test");
        assertThat(waypoint.getName())
            .isEqualTo(
                CgeoApplication.getInstance().getString(R.string.cache_personal_note) + " 1");
        cache.store(StoredList.TEMPORARY_LIST.id, null);
      }
      removeCacheCompletely(geocode);
    } finally {
      restoreMapStoreFlags();
    }
  }
コード例 #14
0
ファイル: LogCacheActivity.java プロジェクト: kozakakos/cgeo
  private void saveLog(final boolean force) {
    final String log = currentLogText();

    // Do not erase the saved log if the user has removed all the characters
    // without using "Clear". This may be a manipulation mistake, and erasing
    // again will be easy using "Clear" while retyping the text may not be.
    if (force || (StringUtils.isNotEmpty(log) && !StringUtils.equals(log, text))) {
      cache.logOffline(this, log, date, typeSelected);
    }
    text = log;
  }
コード例 #15
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
  public static void testMergeLivemapBMSearched() {
    final Geocache bmsearched = new Geocache();
    bmsearched.setGeocode("GC12345");

    final Geocache livemap = new Geocache();
    livemap.setGeocode("GC12345");
    livemap.setCoords(new Geopoint(40.0, 8.0), 12);

    livemap.gatherMissingFrom(bmsearched);

    assertThat(livemap.getCoords()).as("merged coordinates").isEqualTo(new Geopoint(40.0, 8.0));
    assertThat(livemap.getCoordZoomLevel()).as("merged zoomlevel").isEqualTo(12);
  }
コード例 #16
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
  public static void testGetPossibleLogTypes() throws Exception {
    final Geocache gcCache = new Geocache();
    gcCache.setGeocode("GC123");
    gcCache.setType(CacheType.WEBCAM);
    assertThat(gcCache.getPossibleLogTypes())
        .as("possible GC cache log types")
        .contains(LogType.WEBCAM_PHOTO_TAKEN);
    assertThat(gcCache.getPossibleLogTypes())
        .as("possible GC cache log types")
        .contains(LogType.NEEDS_MAINTENANCE);

    final Geocache ocCache = new Geocache();
    ocCache.setGeocode("OC1234");
    ocCache.setType(CacheType.TRADITIONAL);
    assertThat(ocCache.getPossibleLogTypes())
        .as("traditional cache possible log types")
        .doesNotContain(LogType.WEBCAM_PHOTO_TAKEN);
    assertThat(ocCache.getPossibleLogTypes())
        .as("OC cache possible log types")
        .doesNotContain(LogType.NEEDS_MAINTENANCE);
  }
コード例 #17
0
ファイル: LogCacheActivity.java プロジェクト: kozakakos/cgeo
 private void updateImageButton() {
   final Button imageButton = (Button) findViewById(R.id.image_btn);
   if (cache.supportsLogImages()) {
     imageButton.setVisibility(View.VISIBLE);
     imageButton.setText(
         StringUtils.isNotBlank(imageUri.getPath())
             ? res.getString(R.string.log_image_edit)
             : res.getString(R.string.log_image_attach));
   } else {
     imageButton.setVisibility(View.GONE);
   }
 }
コード例 #18
0
ファイル: LogCacheActivity.java プロジェクト: kozakakos/cgeo
 private String getPostButtonText() {
   if (!postButton.isEnabled()) {
     return res.getString(R.string.log_post_not_possible);
   }
   if (typeSelected != LogType.FOUND_IT || !Settings.isGCvoteLogin() || !cache.supportsGCVote()) {
     return res.getString(R.string.log_post);
   }
   if (rating == 0) {
     return res.getString(R.string.log_post_no_rate);
   }
   return res.getString(R.string.log_post_rate) + " " + ratingTextValue(rating) + "*";
 }
コード例 #19
0
ファイル: LogCacheActivity.java プロジェクト: kozakakos/cgeo
  private void clearLog() {
    cache.clearOfflineLog();

    setDefaultValues();

    setType(typeSelected);
    setDate(date);

    final EditText logView = (EditText) findViewById(R.id.log);
    logView.setText(StringUtils.EMPTY);
    final EditText logPasswordView = (EditText) findViewById(R.id.log_password);
    logPasswordView.setText(StringUtils.EMPTY);

    updateImageButton();

    showToast(res.getString(R.string.info_log_cleared));
  }
コード例 #20
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
  public static void testEquality() {
    final Geocache one = new Geocache();
    final Geocache two = new Geocache();

    // identity
    assertThat(one.equals(one)).isTrue();

    // different objects without geocode shall not be equal
    assertThat(one.equals(two)).isFalse();

    one.setGeocode("geocode");
    two.setGeocode("geocode");

    // different objects with same geocode shall be equal
    assertThat(one.equals(two)).isTrue();
  }
コード例 #21
0
 /**
  * Suffix the waypoint type with a running number to get a default name.
  *
  * @param type type to create a new default name for
  * @return
  */
 private String getDefaultWaypointName(final WaypointType type) {
   final ArrayList<String> wpNames = new ArrayList<>();
   for (final Waypoint waypoint : cache.getWaypoints()) {
     wpNames.add(waypoint.getName());
   }
   // try final and trailhead without index
   if (type == WaypointType.FINAL || type == WaypointType.TRAILHEAD) {
     if (!wpNames.contains(type.getL10n())) {
       return type.getL10n();
     }
   }
   // for other types add an index by default, which is highest found index + 1
   int max = 0;
   for (int i = 0; i < 30; i++) {
     if (wpNames.contains(type.getL10n() + " " + i)) {
       max = i;
     }
   }
   return type.getL10n() + " " + (max + 1);
 }
コード例 #22
0
  private int getDefaultWaypointType() {
    // potentially restore saved instance state
    if (waypointTypeSelectorPosition >= 0) {
      return waypointTypeSelectorPosition;
    }

    // when editing, use the existing type
    if (waypoint != null) {
      return POSSIBLE_WAYPOINT_TYPES.indexOf(waypoint.getWaypointType());
    }

    // make default for new waypoint depend on cache type
    switch (cache.getType()) {
      case MYSTERY:
        return POSSIBLE_WAYPOINT_TYPES.indexOf(WaypointType.FINAL);
      case MULTI:
        return POSSIBLE_WAYPOINT_TYPES.indexOf(WaypointType.STAGE);
      default:
        return POSSIBLE_WAYPOINT_TYPES.indexOf(WaypointType.WAYPOINT);
    }
  }
コード例 #23
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
 public static void testGeocodeUppercase() {
   final Geocache cache = new Geocache();
   cache.setGeocode("gc1234");
   assertThat(cache.getGeocode()).isEqualTo("GC1234");
 }
コード例 #24
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
  public static void testAddInventoryItem() {
    final Geocache cache = new Geocache();
    assertThat(cache.getInventory()).isNull();
    assertThat(cache.getInventoryItems()).isEqualTo(0);

    // 1st TB
    final Trackable trackable1 = new Trackable();
    trackable1.setGeocode("TB1234");
    trackable1.setName("FOO");
    trackable1.forceSetBrand(TrackableBrand.TRAVELBUG);

    cache.addInventoryItem(trackable1);
    assertThat(cache.getInventory()).hasSize(1);
    assertThat(cache.getInventoryItems()).isEqualTo(1);
    assertThat(cache.getInventory().get(0).getGeocode()).isEqualTo("TB1234");
    assertThat(cache.getInventory().get(0).getName()).isEqualTo("FOO");
    assertThat(cache.getInventory().get(0).getDistance()).isEqualTo(-1F);
    assertThat(cache.getInventory().get(0).getOwner()).isNull();
    assertThat(cache.getInventory().get(0).getBrand()).isEqualTo(TrackableBrand.TRAVELBUG);

    // TB to be updated
    final Trackable trackable2 = new Trackable();
    trackable2.setGeocode("TB1234");
    trackable2.setName("BAR");
    trackable2.setDistance(100);
    trackable2.forceSetBrand(TrackableBrand.TRAVELBUG);
    cache.addInventoryItem(trackable2);

    assertThat(cache.getInventory()).hasSize(1);
    assertThat(cache.getInventoryItems()).isEqualTo(1);
    assertThat(cache.getInventory().get(0).getGeocode()).isEqualTo("TB1234");
    assertThat(cache.getInventory().get(0).getName()).isEqualTo("BAR");
    assertThat(cache.getInventory().get(0).getDistance()).isEqualTo(100F);
    assertThat(cache.getInventory().get(0).getOwner()).isNull();
    assertThat(cache.getInventory().get(0).getBrand()).isEqualTo(TrackableBrand.TRAVELBUG);

    // TB to be added
    final Trackable trackable3 = new Trackable();
    trackable3.setGeocode("GK6666");
    trackable3.forceSetBrand(TrackableBrand.GEOKRETY);
    cache.addInventoryItem(trackable3);

    assertThat(cache.getInventory()).hasSize(2);
    assertThat(cache.getInventoryItems()).isEqualTo(2);
    assertThat(cache.getInventory().get(0).getGeocode()).isEqualTo("TB1234");
    assertThat(cache.getInventory().get(0).getName()).isEqualTo("BAR");
    assertThat(cache.getInventory().get(0).getDistance()).isEqualTo(100F);
    assertThat(cache.getInventory().get(0).getOwner()).isNull();
    assertThat(cache.getInventory().get(0).getBrand()).isEqualTo(TrackableBrand.TRAVELBUG);

    assertThat(cache.getInventory().get(1).getGeocode()).isEqualTo("GK6666");
    assertThat(cache.getInventory().get(1).getName()).isEqualTo("");
    assertThat(cache.getInventory().get(1).getDistance()).isEqualTo(-1F);
    assertThat(cache.getInventory().get(1).getOwner()).isNull();
    assertThat(cache.getInventory().get(1).getBrand()).isEqualTo(TrackableBrand.GEOKRETY);
  }
コード例 #25
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
  public static void testMergeInventory() {
    final Geocache cache = new Geocache();

    final List<Trackable> inventory1 = new ArrayList<>(4);

    // TB to be updated
    final Trackable trackable1 = new Trackable();
    trackable1.setGeocode("TB1234");
    trackable1.setName("TB 1234");
    trackable1.forceSetBrand(TrackableBrand.TRAVELBUG);
    inventory1.add(trackable1);

    // TB to be updated
    final Trackable trackable2 = new Trackable();
    trackable2.setGeocode("GK1234");
    trackable2.setName("GK 1234");
    trackable2.forceSetBrand(TrackableBrand.GEOKRETY);
    inventory1.add(trackable2);

    // TB to be removed
    final Trackable trackable3 = new Trackable();
    trackable3.setGeocode("GK6666");
    trackable3.forceSetBrand(TrackableBrand.GEOKRETY);
    inventory1.add(trackable3);

    // TB to be untouched
    final Trackable trackable4 = new Trackable();
    trackable4.setGeocode("UN0000");
    trackable4.forceSetBrand(TrackableBrand.UNKNOWN);
    inventory1.add(trackable4);

    cache.setInventory(inventory1);
    assertThat(cache.getInventory()).hasSize(4);
    assertThat(cache.getInventoryItems()).isEqualTo(4);

    // new TB
    final List<Trackable> inventory2 = new ArrayList<>(3);
    final Trackable trackable5 = new Trackable();
    trackable5.setGeocode("SW1234");
    trackable5.setName("SW 1234");
    trackable5.setDistance(100F);
    trackable5.forceSetBrand(TrackableBrand.SWAGGIE);
    inventory2.add(trackable5);

    // TB updater
    final Trackable trackable6 = new Trackable();
    trackable6.setGeocode("GK1234");
    trackable6.setDistance(200F);
    trackable6.forceSetBrand(TrackableBrand.GEOKRETY);
    inventory2.add(trackable6);

    // new TB
    final Trackable trackable7 = new Trackable();
    trackable7.setGeocode("GK4321");
    trackable7.setName("GK 4321");
    trackable7.setDistance(300F);
    trackable7.forceSetBrand(TrackableBrand.GEOKRETY);
    inventory2.add(trackable7);

    cache.mergeInventory(inventory2);

    assertThat(cache.getInventory()).hasSize(5);
    assertThat(cache.getInventoryItems()).isEqualTo(5);

    assertThat(cache.getInventory().get(0)).isEqualTo(trackable1);
    assertThat(cache.getInventory().get(0).getGeocode()).isEqualTo("TB1234");
    assertThat(cache.getInventory().get(0).getName()).isEqualTo("TB 1234");
    assertThat(cache.getInventory().get(0).getDistance()).isEqualTo(-1F);
    assertThat(cache.getInventory().get(0).getOwner()).isNull();
    assertThat(cache.getInventory().get(0).getBrand()).isEqualTo(TrackableBrand.TRAVELBUG);

    assertThat(cache.getInventory().get(1)).isEqualTo(trackable2);
    assertThat(cache.getInventory().get(1).getGeocode()).isEqualTo("GK1234");
    assertThat(cache.getInventory().get(1).getName()).isEqualTo("GK 1234");
    assertThat(cache.getInventory().get(1).getDistance()).isEqualTo(200F);
    assertThat(cache.getInventory().get(1).getOwner()).isNull();
    assertThat(cache.getInventory().get(1).getBrand()).isEqualTo(TrackableBrand.GEOKRETY);

    assertThat(cache.getInventory().get(2)).isEqualTo(trackable4);
    assertThat(cache.getInventory().get(2).getGeocode()).isEqualTo("UN0000");
    assertThat(cache.getInventory().get(2).getName()).isEqualTo("");
    assertThat(cache.getInventory().get(2).getDistance()).isEqualTo(-1F);
    assertThat(cache.getInventory().get(2).getOwner()).isNull();
    assertThat(cache.getInventory().get(2).getBrand()).isEqualTo(TrackableBrand.UNKNOWN);

    assertThat(cache.getInventory().get(3)).isEqualTo(trackable5);
    assertThat(cache.getInventory().get(3).getGeocode()).isEqualTo("SW1234");
    assertThat(cache.getInventory().get(3).getName()).isEqualTo("SW 1234");
    assertThat(cache.getInventory().get(3).getDistance()).isEqualTo(100F);
    assertThat(cache.getInventory().get(3).getOwner()).isNull();
    assertThat(cache.getInventory().get(3).getBrand()).isEqualTo(TrackableBrand.SWAGGIE);

    assertThat(cache.getInventory().get(4)).isEqualTo(trackable7);
    assertThat(cache.getInventory().get(4).getGeocode()).isEqualTo("GK4321");
    assertThat(cache.getInventory().get(4).getName()).isEqualTo("GK 4321");
    assertThat(cache.getInventory().get(4).getDistance()).isEqualTo(300F);
    assertThat(cache.getInventory().get(4).getOwner()).isNull();
    assertThat(cache.getInventory().get(4).getBrand()).isEqualTo(TrackableBrand.GEOKRETY);
  }
コード例 #26
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
 public static void testInventoryItems() {
   final Geocache cache = new Geocache();
   cache.setInventoryItems(5);
   assertThat(cache.getInventoryItems()).isEqualTo(5);
 }
コード例 #27
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
 private static Geocache createEventCache(final Calendar calendar) {
   final Geocache cache = new Geocache();
   cache.setType(CacheType.EVENT);
   cache.setHidden(calendar.getTime());
   return cache;
 }
コード例 #28
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
  public static void testMergePopupLivemap() {
    final Geocache livemap = new Geocache();
    livemap.setGeocode("GC12345");
    livemap.setCoords(new Geopoint(40.0, 8.0), 12);
    livemap.setFound(true);

    final Geocache popup = new Geocache();
    popup.setGeocode("GC12345");
    popup.setType(CacheType.MULTI);

    popup.gatherMissingFrom(livemap);

    assertThat(popup.getType()).as("merged type").isEqualTo(CacheType.MULTI);
    assertThat(popup.getCoords()).as("merged coordinates").isEqualTo(new Geopoint(40.0, 8.0));
    assertThat(popup.isFound()).overridingErrorMessage("merged found").isTrue();
    assertThat(popup.getCoordZoomLevel()).as("merged zoomlevel").isEqualTo(12);
  }
コード例 #29
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
 private static void assertNoTime(final String description) {
   final Geocache cache = new Geocache();
   cache.setDescription(description);
   cache.setType(CacheType.EVENT);
   assertThat(cache.guessEventTimeMinutes()).isEqualTo(-1);
 }
コード例 #30
0
ファイル: GeocacheTest.java プロジェクト: schwabe/cgeo
 public static void testNameForSorting() {
   final Geocache cache = new Geocache();
   cache.setName("GR8 01-01");
   assertThat(cache.getNameForSorting()).isEqualTo("GR000008 000001-000001");
 }