Search in sources :

Example 46 with User

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

the class UserPropertiesServiceV1ImplTest method testAddStopBookmark.

@Test
public void testAddStopBookmark() throws BookmarkException {
    User user = createUser();
    _service.addStopBookmark(user, "bookmkark", Arrays.asList("1"), new RouteFilter());
    List<String> bookmarks = getProperties(user).getBookmarkedStopIds();
    assertEquals(1, bookmarks.size());
    assertTrue(bookmarks.contains("1"));
}
Also used : User(org.onebusaway.users.model.User) RouteFilter(org.onebusaway.users.model.properties.RouteFilter) Test(org.junit.Test)

Example 47 with User

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

the class UserPropertiesServiceV1ImplTest method testMergeUsers03.

@Test
public void testMergeUsers03() throws BookmarkException {
    User userA = createUser();
    _service.setLastSelectedStopIds(userA, Arrays.asList("A"));
    _service.setDefaultLocation(userA, "here", 47.0, -122.0);
    _service.addStopBookmark(userA, "bookmark a", Arrays.asList("A", "C"), new RouteFilter());
    User userB = createUser();
    _service.setLastSelectedStopIds(userB, Arrays.asList("B"));
    _service.setDefaultLocation(userB, "there", 48.0, -123.0);
    _service.addStopBookmark(userB, "bookmark b", Arrays.asList("B", "A"), new RouteFilter());
    _service.mergeProperties(userA, userB);
    UserPropertiesV1 props = getProperties(userB);
    List<String> bookmarks = props.getBookmarkedStopIds();
    assertEquals(4, bookmarks.size());
    assertEquals("B", bookmarks.get(0));
    assertEquals("A", bookmarks.get(1));
    assertEquals("A", bookmarks.get(2));
    assertEquals("C", bookmarks.get(3));
    assertEquals("there", props.getDefaultLocationName());
    assertEquals(48.0, props.getDefaultLocationLat(), 0.0);
    assertEquals(-123.0, props.getDefaultLocationLon(), 0.0);
    assertEquals("B", props.getLastSelectedStopId());
}
Also used : User(org.onebusaway.users.model.User) RouteFilter(org.onebusaway.users.model.properties.RouteFilter) UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1) Test(org.junit.Test)

Example 48 with User

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

the class UserPropertiesServiceV1ImplTest method testMergeUsers01.

@Test
public void testMergeUsers01() throws BookmarkException {
    User userA = createUser();
    _service.setLastSelectedStopIds(userA, Arrays.asList("A"));
    _service.addStopBookmark(userA, "bookmark a", Arrays.asList("A", "C"), new RouteFilter());
    User userB = createUser();
    _service.setDefaultLocation(userB, "here", 47.0, -122.0);
    _service.addStopBookmark(userB, "bookmark b", Arrays.asList("C", "B"), new RouteFilter());
    _service.mergeProperties(userA, userB);
    UserPropertiesV1 props = getProperties(userB);
    List<String> bookmarks = props.getBookmarkedStopIds();
    assertEquals(4, bookmarks.size());
    assertEquals("C", bookmarks.get(0));
    assertEquals("B", bookmarks.get(1));
    assertEquals("A", bookmarks.get(2));
    assertEquals("C", bookmarks.get(3));
    assertEquals("here", props.getDefaultLocationName());
    assertEquals(47.0, props.getDefaultLocationLat(), 0.0);
    assertEquals(-122.0, props.getDefaultLocationLon(), 0.0);
    assertEquals("A", props.getLastSelectedStopId());
}
Also used : User(org.onebusaway.users.model.User) RouteFilter(org.onebusaway.users.model.properties.RouteFilter) UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1) Test(org.junit.Test)

Example 49 with User

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

the class UserPropertiesServiceV1ImplTest method testMergeUsers02.

@Test
public void testMergeUsers02() throws BookmarkException {
    User userA = createUser();
    _service.setLastSelectedStopIds(userA, Arrays.asList("A"));
    _service.setDefaultLocation(userA, "here", 47.0, -122.0);
    _service.addStopBookmark(userA, "bookmark A", Arrays.asList("A", "C"), new RouteFilter());
    User userB = createUser();
    _service.mergeProperties(userA, userB);
    UserPropertiesV1 props = getProperties(userB);
    List<String> bookmarks = props.getBookmarkedStopIds();
    assertEquals(2, bookmarks.size());
    assertEquals("A", bookmarks.get(0));
    assertEquals("C", bookmarks.get(1));
    assertEquals("here", props.getDefaultLocationName());
    assertEquals(47.0, props.getDefaultLocationLat(), 0.0);
    assertEquals(-122.0, props.getDefaultLocationLon(), 0.0);
    assertEquals("A", props.getLastSelectedStopId());
}
Also used : User(org.onebusaway.users.model.User) RouteFilter(org.onebusaway.users.model.properties.RouteFilter) UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1) Test(org.junit.Test)

Example 50 with User

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

the class ApiKeyAction method searchAPIKey.

public String searchAPIKey() {
    // Check if key already exists
    UserIndexKey userKey = new UserIndexKey(UserIndexTypes.API_KEY, key);
    UserIndex userIndexForId = userService.getUserIndexForId(userKey);
    if (userIndexForId == null) {
        addActionMessage("Key '" + key + "' does not exist");
    } else {
        User user = userIndexForId.getUser();
        UserBean bean = userService.getUserAsBean(user);
        minApiReqInt = bean.getMinApiRequestInterval();
        contactName = bean.getContactName();
        contactCompany = bean.getContactCompany();
        contactEmail = bean.getContactEmail();
        contactDetails = bean.getContactDetails();
        addActionMessage("Key '" + key + "' found");
    }
    return SUCCESS;
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) UserIndexKey(org.onebusaway.users.model.UserIndexKey) User(org.onebusaway.users.model.User) UserBean(org.onebusaway.users.client.model.UserBean)

Aggregations

User (org.onebusaway.users.model.User)56 UserIndex (org.onebusaway.users.model.UserIndex)23 UserIndexKey (org.onebusaway.users.model.UserIndexKey)16 Test (org.junit.Test)13 Date (java.util.Date)9 UserBean (org.onebusaway.users.client.model.UserBean)8 UserPropertiesV1 (org.onebusaway.users.model.UserPropertiesV1)7 ArrayList (java.util.ArrayList)5 IOException (java.io.IOException)4 SQLException (java.sql.SQLException)4 List (java.util.List)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)4 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)4 Criteria (org.hibernate.Criteria)4 HibernateException (org.hibernate.HibernateException)4 Session (org.hibernate.Session)4 UserDetail (org.onebusaway.admin.model.ui.UserDetail)4 RouteFilter (org.onebusaway.users.model.properties.RouteFilter)4 UserRole (org.onebusaway.users.model.UserRole)3