Package edu.wpi.cs.wpisuitetng.modules.core.models

Examples of edu.wpi.cs.wpisuitetng.modules.core.models.User


   * @throws java.lang.Exception
   */
  @Before
  public void setUp() throws Exception
  {
    fake = new User("fake","fake","fake", 0);
    uniqueFake = new User("asdf","asdf","asdf", 0);
    fakeList = new User[1];
    doubleFakeList = new User[2];
    fakeList[0] = fake;
    doubleFakeList[0] = fake;
    doubleFakeList[1] = fake;
View Full Code Here


  @Test
  public void testDBSession() throws WPISuiteException
  {
    Data db = DataStore.getDataStore();
    User[] arr = new User[1];
    db.save(new User("andrew", "ahurle", "p", 0));
    User me = db.retrieve(User.class, "username", "ahurle").toArray(arr)[0];
    User me2 = db.retrieve(User.class, "username", "ahurle").toArray(arr)[0];
    db.delete(me);
    System.out.println("equal: " + (me == me2));
    assertEquals(me, me2);
  }
View Full Code Here

        // TODO Auto-generated method stub
       
      }
     
    };
    u = new User("ted", "tdude", "nothing", 1);
  }
View Full Code Here

  User u2;
 
  @Before
  public void setUp()
  {
    this.u1 = new User("Prometheus", "twack", null, 0);
    this.ses1 = new Session(u1, ssid1);
   
    this.u2 = new User("Bob", "caveman", null, 1);
    this.ses2 = new Session(u2, ssid2);
  }
View Full Code Here

  public void save(Session s, Defect model) {
    db.save(model, s.getProject());
  }

  private void ensureRole(Session session, Role role) throws WPISuiteException {
    User user = (User) db.retrieve(User.class, "username", session.getUsername()).get(0);
    if(!user.getRole().equals(role)) {
      throw new UnauthorizedException();
    }
  }
View Full Code Here

  User u2;
 
  @Before
  public void setUp()
  {
    this.u1 = new User("Tyler", "twack", "jayms", 2);
    this.u2 = new User("Mike", "mpdelladonna", "yams", 3);
    this.u2.setRole(Role.ADMIN);
   
    this.man = new SessionManager();
  }
View Full Code Here

  @Before
  public void setUp()
  {
    test = new UserManager(MockDataStore.getMockDataStore());
    testWithRealDB = new UserManager(DataStore.getDataStore());
    temp = new User("test","test","test",0);
    secondUser = new User ("Sam", "sammy","trouty", 1);
    conflict = new User("steve", "steve",null, 0);
    tempSession = new Session(temp, mockSsid);
    admin = new User("adam","adam","password",4);
    admin.setRole(Role.ADMIN);
    adminSession = new Session(admin, mockSsid);
    json = new Gson();
  }
View Full Code Here

 
 
 
  @Test
  public void testMakeEntity() {
    User u = null;
   
    String jsonUser = temp.toJSON();
    jsonUser = jsonUser.substring(0, jsonUser.length() - 1);
    jsonUser += ", \"password\":\"abcde\"}";
    System.out.println(jsonUser);
   
    try {
      u = test.makeEntity(new Session(temp, mockSsid), jsonUser);
    } catch (WPISuiteException e) {
      fail("unexpected exception");
    }
   
    assertTrue(u.equals(temp));
  }
View Full Code Here

   */
  public void testUpdate() throws WPISuiteException
  {
    Session ses = null;
    String updateString = "{ \"idNum\": 99, \"role\":\"ADMIN\",  \"username\": \"zach\", \"name\": \"zach\" }";
    User newTemp = this.test.update(adminSession, temp, updateString);
   
    // TODO: find a way to retrieve the User from storage to run assertions on.
   
    assertEquals(99, newTemp.getIdNum());
    assertEquals(newTemp.getRole(), Role.ADMIN);
    assertTrue(newTemp.getName().equals("zach"));
  }
View Full Code Here

  public void deserializeUserFull()
  {
    String jsonUser ="{\"name\":\"Tyler\", \"username\":\"twack\", \"idNum\":2, password:\"abcde\", \"role\":\"ADMIN\"}";
    Gson deserializer = this.gson.create();
   
    User inflated = deserializer.fromJson(jsonUser, User.class);
   
    assertEquals(2, inflated.getIdNum());
    assertTrue(inflated.getName().equals("Tyler"));
    assertTrue(inflated.getUsername().equals("twack"));
    assertTrue(inflated.getRole().equals(Role.ADMIN));
   
    assertTrue(inflated.matchPassword("abcde"));
    assertFalse(inflated.matchPassword(null));
  }
View Full Code Here

TOP

Related Classes of edu.wpi.cs.wpisuitetng.modules.core.models.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.