Search in sources :

Example 6 with Bookmark

use of org.onebusaway.users.model.properties.Bookmark in project onebusaway-application-modules by camsys.

the class UserPropertiesMigrationImplTest method testV2ToV1Migration.

@Test
public void testV2ToV1Migration() {
    UserPropertiesV2 v2 = new UserPropertiesV2();
    v2.setDefaultLocationLat(47.0);
    v2.setDefaultLocationLon(-122.0);
    v2.setDefaultLocationName("Seattle");
    v2.setRememberPreferencesEnabled(true);
    Bookmark b1 = new Bookmark(0, null, Arrays.asList("1_29214"), new RouteFilter());
    Bookmark b2 = new Bookmark(1, null, Arrays.asList("1_75403", "1_75414"), new RouteFilter());
    v2.setBookmarks(Arrays.asList(b1, b2));
    UserPropertiesV2 result = _service.migrate(v2, UserPropertiesV2.class);
    assertTrue(v2 == result);
    UserPropertiesV1 v1 = _service.migrate(v2, UserPropertiesV1.class);
    assertTrue(v1.isRememberPreferencesEnabled());
    assertNull(v1.getLastSelectedStopId());
    assertEquals(47.0, v1.getDefaultLocationLat(), 0.0);
    assertEquals(-122.0, v1.getDefaultLocationLon(), 0.0);
    assertEquals("Seattle", v1.getDefaultLocationName());
    assertEquals(Arrays.asList("1_29214", "1_75403", "1_75414"), v1.getBookmarkedStopIds());
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2) RouteFilter(org.onebusaway.users.model.properties.RouteFilter) UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1) Test(org.junit.Test)

Example 7 with Bookmark

use of org.onebusaway.users.model.properties.Bookmark in project onebusaway-application-modules by camsys.

the class UserPropertiesMigrationImplTest method testV2ToV3Migration.

@Test
public void testV2ToV3Migration() {
    UserPropertiesV2 v2 = new UserPropertiesV2();
    v2.setDefaultLocationLat(47.0);
    v2.setDefaultLocationLon(-122.0);
    v2.setDefaultLocationName("Seattle");
    v2.setRememberPreferencesEnabled(true);
    Bookmark b1 = new Bookmark(0, null, Arrays.asList("1_29214"), new RouteFilter());
    Bookmark b2 = new Bookmark(1, null, Arrays.asList("1_75403", "1_75414"), new RouteFilter());
    v2.setBookmarks(Arrays.asList(b1, b2));
    UserPropertiesV2 result = _service.migrate(v2, UserPropertiesV2.class);
    assertTrue(v2 == result);
    UserPropertiesV3 v3 = _service.migrate(v2, UserPropertiesV3.class);
    assertTrue(v3.isRememberPreferencesEnabled());
    assertEquals(47.0, v3.getDefaultLocationLat(), 0.0);
    assertEquals(-122.0, v3.getDefaultLocationLon(), 0.0);
    assertEquals("Seattle", v3.getDefaultLocationName());
    List<Bookmark> bookmarks = v3.getBookmarks();
    assertEquals(2, bookmarks.size());
    Bookmark bookmark = bookmarks.get(0);
    assertEquals(0, bookmark.getId());
    assertNull(bookmark.getName());
    assertEquals(Arrays.asList("1_29214"), bookmark.getStopIds());
    assertTrue(bookmark.getRouteFilter().getRouteIds().isEmpty());
    bookmark = bookmarks.get(1);
    assertEquals(1, bookmark.getId());
    assertNull(bookmark.getName());
    assertEquals(Arrays.asList("1_75403", "1_75414"), bookmark.getStopIds());
    assertTrue(bookmark.getRouteFilter().getRouteIds().isEmpty());
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) UserPropertiesV3(org.onebusaway.users.model.properties.UserPropertiesV3) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2) RouteFilter(org.onebusaway.users.model.properties.RouteFilter) Test(org.junit.Test)

Example 8 with Bookmark

use of org.onebusaway.users.model.properties.Bookmark in project onebusaway-application-modules by camsys.

the class UserPropertiesMigrationImplTest method testV1ToV2Migration.

@Test
public void testV1ToV2Migration() {
    UserPropertiesV1 v1 = new UserPropertiesV1();
    v1.setDefaultLocationLat(47.0);
    v1.setDefaultLocationLon(-122.0);
    v1.setDefaultLocationName("Seattle");
    v1.setLastSelectedStopId("1_29214");
    v1.setRememberPreferencesEnabled(true);
    v1.setBookmarkedStopIds(Arrays.asList("1_29214", "1_75403"));
    UserPropertiesV1 result = _service.migrate(v1, UserPropertiesV1.class);
    assertTrue(v1 == result);
    UserPropertiesV2 v2 = _service.migrate(v1, UserPropertiesV2.class);
    assertTrue(v2.isRememberPreferencesEnabled());
    assertEquals(47.0, v2.getDefaultLocationLat(), 0.0);
    assertEquals(-122.0, v2.getDefaultLocationLon(), 0.0);
    assertEquals("Seattle", v2.getDefaultLocationName());
    List<Bookmark> bookmarks = v2.getBookmarks();
    assertEquals(2, bookmarks.size());
    Bookmark bookmark = bookmarks.get(0);
    assertEquals(0, bookmark.getId());
    assertNull(bookmark.getName());
    assertEquals(Arrays.asList("1_29214"), bookmark.getStopIds());
    assertTrue(bookmark.getRouteFilter().getRouteIds().isEmpty());
    bookmark = bookmarks.get(1);
    assertEquals(1, bookmark.getId());
    assertNull(bookmark.getName());
    assertEquals(Arrays.asList("1_75403"), bookmark.getStopIds());
    assertTrue(bookmark.getRouteFilter().getRouteIds().isEmpty());
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2) UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1) Test(org.junit.Test)

Example 9 with Bookmark

use of org.onebusaway.users.model.properties.Bookmark in project onebusaway-application-modules by camsys.

the class UserPropertiesMigrationImplTest method testV3ToV2Migration.

@Test
public void testV3ToV2Migration() {
    UserPropertiesV3 v3 = new UserPropertiesV3();
    v3.setDefaultLocationLat(47.0);
    v3.setDefaultLocationLon(-122.0);
    v3.setDefaultLocationName("Seattle");
    v3.setRememberPreferencesEnabled(true);
    Bookmark b1 = new Bookmark(0, null, Arrays.asList("1_29214"), new RouteFilter());
    Bookmark b2 = new Bookmark(1, null, Arrays.asList("1_75403", "1_75414"), new RouteFilter());
    v3.setBookmarks(Arrays.asList(b1, b2));
    UserPropertiesV3 result = _service.migrate(v3, UserPropertiesV3.class);
    assertTrue(v3 == result);
    UserPropertiesV2 v2 = _service.migrate(v3, UserPropertiesV2.class);
    assertTrue(v2.isRememberPreferencesEnabled());
    assertEquals(47.0, v2.getDefaultLocationLat(), 0.0);
    assertEquals(-122.0, v2.getDefaultLocationLon(), 0.0);
    assertEquals("Seattle", v2.getDefaultLocationName());
    List<Bookmark> bookmarks = v2.getBookmarks();
    assertEquals(2, bookmarks.size());
    Bookmark bookmark = bookmarks.get(0);
    assertEquals(0, bookmark.getId());
    assertNull(bookmark.getName());
    assertEquals(Arrays.asList("1_29214"), bookmark.getStopIds());
    assertTrue(bookmark.getRouteFilter().getRouteIds().isEmpty());
    bookmark = bookmarks.get(1);
    assertEquals(1, bookmark.getId());
    assertNull(bookmark.getName());
    assertEquals(Arrays.asList("1_75403", "1_75414"), bookmark.getStopIds());
    assertTrue(bookmark.getRouteFilter().getRouteIds().isEmpty());
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) UserPropertiesV3(org.onebusaway.users.model.properties.UserPropertiesV3) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2) RouteFilter(org.onebusaway.users.model.properties.RouteFilter) Test(org.junit.Test)

Example 10 with Bookmark

use of org.onebusaway.users.model.properties.Bookmark in project onebusaway-application-modules by camsys.

the class UserPropertiesMigrationImpl method getV2Properties.

private UserPropertiesV2 getV2Properties(UserPropertiesV1 v1) {
    UserPropertiesV2 v2 = new UserPropertiesV2();
    v2.setRememberPreferencesEnabled(v1.isRememberPreferencesEnabled());
    v2.setDefaultLocationLat(v1.getDefaultLocationLat());
    v2.setDefaultLocationLon(v1.getDefaultLocationLon());
    v2.setDefaultLocationName(v1.getDefaultLocationName());
    int index = 0;
    for (String stopId : v1.getBookmarkedStopIds()) {
        Bookmark bookmark = new Bookmark(index++, null, Arrays.asList(stopId), new RouteFilter());
        v2.getBookmarks().add(bookmark);
    }
    return v2;
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2) RouteFilter(org.onebusaway.users.model.properties.RouteFilter)

Aggregations

Bookmark (org.onebusaway.users.model.properties.Bookmark)18 UserPropertiesV2 (org.onebusaway.users.model.properties.UserPropertiesV2)9 UserPropertiesV3 (org.onebusaway.users.model.properties.UserPropertiesV3)6 Test (org.junit.Test)4 RouteFilter (org.onebusaway.users.model.properties.RouteFilter)4 UserPropertiesV4 (org.onebusaway.users.model.properties.UserPropertiesV4)4 BookmarkBean (org.onebusaway.users.client.model.BookmarkBean)3 UserPropertiesV1 (org.onebusaway.users.model.UserPropertiesV1)3