예제 #1
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());
  }
예제 #2
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());
  }
예제 #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();
  }