Ejemplo n.º 1
0
  public static void testMergeLivemapStored() {
    final Geocache stored = new Geocache();
    stored.setGeocode("GC12345");
    stored.setDetailed(true);
    stored.setDisabled(true);
    stored.setType(CacheType.TRADITIONAL);
    stored.setCoords(new Geopoint(40.0, 8.0));
    saveFreshCacheToDB(stored);

    final Geocache livemap = new Geocache();
    livemap.setGeocode("GC12345");
    livemap.setType(CacheType.MULTI, 12);
    livemap.setCoords(new Geopoint(41.0, 9.0), 12);

    livemap.gatherMissingFrom(stored);

    assertThat(livemap.isDetailed()).as("merged detailed").isTrue();
    assertThat(livemap.isDisabled()).as("merged disabled").isTrue();
    assertThat(livemap.getType()).as("merged type").isEqualTo(CacheType.TRADITIONAL);
    assertThat(livemap.getCoords())
        .as("merged coordinates")
        .isEqualToComparingFieldByField(new Geopoint(40.0, 8.0));
    assertThat(livemap.getCoordZoomLevel())
        .as("merged zoomlevel")
        .isEqualTo(stored.getCoordZoomLevel());
  }
Ejemplo n.º 2
0
  public static void testMergeLivemap() {
    final Geocache previous = new Geocache();
    previous.setGeocode("GC12345");
    previous.setDetailed(true);
    previous.setDisabled(true);
    previous.setType(CacheType.TRADITIONAL);
    previous.setCoords(new Geopoint(40.0, 8.0));
    removeCacheCompletely(previous.getGeocode());

    final Geocache livemap = new Geocache();
    livemap.setGeocode("GC12345");
    livemap.setType(CacheType.MULTI, 12);
    livemap.setCoords(new Geopoint(41.0, 9.0), 12);

    livemap.gatherMissingFrom(previous);

    assertThat(livemap.isDetailed()).as("merged detailed").isTrue();
    assertThat(livemap.isDisabled()).as("merged disabled").isTrue();
    assertThat(livemap.getType()).as("merged type").isEqualTo(CacheType.TRADITIONAL);
    assertThat(livemap.getCoords())
        .as("merged coordinates")
        .isEqualToComparingFieldByField(new Geopoint(40.0, 8.0));
    assertThat(livemap.getCoordZoomLevel())
        .as("merged zoomlevel")
        .isEqualTo(previous.getCoordZoomLevel());
  }
Ejemplo n.º 3
0
  public static void testMergeDownloadedStored() {
    final Geocache stored = new Geocache();
    stored.setGeocode("GC12345");
    stored.setDetailed(true);
    stored.setDisabled(true);
    stored.setType(CacheType.TRADITIONAL);
    stored.setCoords(new Geopoint(40.0, 8.0));
    stored.setDescription("Test1");
    stored.setAttributes(Collections.singletonList("TestAttribute"));
    stored.setShortDescription("Short");
    stored.setHint("Hint");
    saveFreshCacheToDB(stored);

    final Geocache download = new Geocache();
    download.setGeocode("GC12345");
    download.setDetailed(true);
    download.setDisabled(false);
    download.setType(CacheType.MULTI);
    download.setCoords(new Geopoint(41.0, 9.0));
    download.setDescription("Test2");
    download.setAttributes(Collections.<String>emptyList());

    download.gatherMissingFrom(stored);

    assertThat(download.isDetailed()).as("merged detailed").isTrue();
    assertThat(download.isDisabled()).as("merged disabled").isFalse();
    assertThat(download.getType()).as("merged download").isEqualTo(CacheType.MULTI);
    assertThat(download.getCoords()).as("merged coordinates").isEqualTo(new Geopoint(41.0, 9.0));
    assertThat(download.getDescription()).as("merged description").isEqualTo("Test2");
    assertThat(download.getShortDescription()).as("merged short description").isEmpty();
    assertThat(download.getAttributes()).as("merged attributes").isEmpty();
    assertThat(download.getHint()).as("merged hint").isEmpty();
  }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
  public static void testMergeLivemapZoomout() {
    final Geocache livemapFirst = new Geocache();
    livemapFirst.setGeocode("GC12345");
    livemapFirst.setType(CacheType.TRADITIONAL, 12);
    livemapFirst.setCoords(new Geopoint(40.0, 8.0), 12);

    final Geocache livemapSecond = new Geocache();
    livemapSecond.setGeocode("GC12345");
    livemapSecond.setType(CacheType.MULTI, 11);
    livemapSecond.setCoords(new Geopoint(41.0, 9.0), 11);

    livemapSecond.gatherMissingFrom(livemapFirst);

    assertThat(livemapSecond.getType()).as("merged type").isEqualTo(CacheType.TRADITIONAL);
    assertThat(livemapSecond.getCoords())
        .as("merged coordinates")
        .isEqualTo(new Geopoint(40.0, 8.0));
    assertThat(livemapSecond.getCoordZoomLevel()).as("merged zoomlevel").isEqualTo(12);
  }
Ejemplo n.º 7
0
  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);
  }
Ejemplo n.º 8
0
  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);
  }
Ejemplo n.º 9
0
 private static Geocache createEventCache(final Calendar calendar) {
   final Geocache cache = new Geocache();
   cache.setType(CacheType.EVENT);
   cache.setHidden(calendar.getTime());
   return cache;
 }
Ejemplo n.º 10
0
 private static void assertNoTime(final String description) {
   final Geocache cache = new Geocache();
   cache.setDescription(description);
   cache.setType(CacheType.EVENT);
   assertThat(cache.guessEventTimeMinutes()).isEqualTo(-1);
 }