use of org.onebusaway.users.model.UserPropertiesV1 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());
}
use of org.onebusaway.users.model.UserPropertiesV1 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV1ImplTest method createUser.
private User createUser() {
User user = new User();
user.setProperties(new UserPropertiesV1());
return user;
}
use of org.onebusaway.users.model.UserPropertiesV1 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV1Impl method resetUser.
@Override
public void resetUser(User user) {
user.setProperties(new UserPropertiesV1());
_userDao.saveOrUpdateUser(user);
}
use of org.onebusaway.users.model.UserPropertiesV1 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV1Impl method setLastSelectedStopIds.
@Override
public void setLastSelectedStopIds(User user, List<String> stopIds) {
if (stopIds.isEmpty())
return;
String stopId = stopIds.get(0);
UserPropertiesV1 properties = getProperties(user);
if (!properties.isRememberPreferencesEnabled())
return;
if (!stopId.equals(properties.getLastSelectedStopId())) {
properties.setLastSelectedStopId(stopId);
_userDao.saveOrUpdateUser(user);
}
}
use of org.onebusaway.users.model.UserPropertiesV1 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV1Impl method deleteStopBookmarks.
@Override
public void deleteStopBookmarks(User user, int index) {
UserPropertiesV1 properties = getProperties(user);
// either way.
if (!properties.isRememberPreferencesEnabled())
_log.warn("Attempt to delete bookmark for stateless user. They shouldn't have bookmarks in the first place. User=" + user.getId());
List<String> bookmarkedStopIds = properties.getBookmarkedStopIds();
bookmarkedStopIds.remove(index);
_userDao.saveOrUpdateUser(user);
}
Aggregations