Search in sources :

Example 6 with UserPropertiesV2

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

the class UserDaoImplTest method testTransitionUserIndex.

@Test
public void testTransitionUserIndex() {
    User userA = new User();
    userA.setCreationTime(new Date());
    userA.setProperties(new UserPropertiesV2());
    UserIndex index = new UserIndex();
    index.setId(new UserIndexKey("test", "A"));
    index.setUser(userA);
    userA.getUserIndices().add(index);
    _dao.saveOrUpdateUser(userA);
    User userB = new User();
    userB.setCreationTime(new Date());
    userB.setProperties(new UserPropertiesV2());
    _dao.saveOrUpdateUser(userB);
    assertEquals(1, _dao.getUserForId(userA.getId()).getUserIndices().size());
    assertEquals(0, _dao.getUserForId(userB.getId()).getUserIndices().size());
    index.setUser(userB);
    userA.getUserIndices().remove(index);
    userB.getUserIndices().add(index);
    _dao.saveOrUpdateUsers(userA, userB);
    assertEquals(0, _dao.getUserForId(userA.getId()).getUserIndices().size());
    assertEquals(1, _dao.getUserForId(userB.getId()).getUserIndices().size());
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) UserIndexKey(org.onebusaway.users.model.UserIndexKey) User(org.onebusaway.users.model.User) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2) Date(java.util.Date) Test(org.junit.Test)

Example 7 with UserPropertiesV2

use of org.onebusaway.users.model.properties.UserPropertiesV2 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 8 with UserPropertiesV2

use of org.onebusaway.users.model.properties.UserPropertiesV2 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 9 with UserPropertiesV2

use of org.onebusaway.users.model.properties.UserPropertiesV2 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 10 with UserPropertiesV2

use of org.onebusaway.users.model.properties.UserPropertiesV2 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)

Aggregations

UserPropertiesV2 (org.onebusaway.users.model.properties.UserPropertiesV2)21 Bookmark (org.onebusaway.users.model.properties.Bookmark)9 Test (org.junit.Test)8 UserPropertiesV1 (org.onebusaway.users.model.UserPropertiesV1)4 RouteFilter (org.onebusaway.users.model.properties.RouteFilter)4 Date (java.util.Date)3 User (org.onebusaway.users.model.User)3 UserPropertiesV3 (org.onebusaway.users.model.properties.UserPropertiesV3)3 UserIndex (org.onebusaway.users.model.UserIndex)2 UserIndexKey (org.onebusaway.users.model.UserIndexKey)2 UserProperties (org.onebusaway.users.model.UserProperties)2 Calendar (java.util.Calendar)1 BookmarkBean (org.onebusaway.users.client.model.BookmarkBean)1 UserRole (org.onebusaway.users.model.UserRole)1 UserPropertiesV4 (org.onebusaway.users.model.properties.UserPropertiesV4)1