Package edu.wpi.cs.wpisuitetng.database

Examples of edu.wpi.cs.wpisuitetng.database.Data


   * @throws WPISuiteException
   */
  @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


    testWithRealDB.deleteAll(new Session(temp, mockSsid));
  }

  @Test(expected = WPISuiteException.class)
  public void testSaveFail() throws WPISuiteException {
    new UserManager(new Data(){

      @Override
      public <T> boolean save(T aModel) {
        // TODO Auto-generated method stub
        return false;
View Full Code Here

    ).save(null, null);
  }

  @Test
  public void testDeleteEntityFail() throws WPISuiteException {
    new UserManager(new Data(){
      @Override
      public <T> boolean save(T aTNG) {return false;}
      @Override
      public List<Model> retrieve(Class anObjectQueried,String aFieldName, Object theGivenValue) {
        List<Model> a = new ArrayList<Model>();
View Full Code Here

  }
 
  @Test
  public void testDeleteEntity() throws WPISuiteException
  {
    new UserManager(new Data(){
      @Override
      public <T> boolean save(T aTNG) {return false;}
      @Override
      public List<Model> retrieve(Class anObjectQueried,String aFieldName, Object theGivenValue) {
        List<Model> a = new ArrayList<Model>();
View Full Code Here

    db.delete(me);
  }
 
  @Test
  public void testDelete() throws WPISuiteException{
    Data db = DataStore.getDataStore();
    User[] arr = new User[1];
    User firstUser = new User("Ryan", "rchamer", "password", 0);
    db.save(firstUser);
    db.delete(firstUser);
    User me = db.retrieve(User.class, "username", "rchamer").toArray(arr)[0];
    assertEquals(me, null);
  }
View Full Code Here

    assertEquals(me, null);
  }
 
  @Test
  public void testUpdate() throws WPISuiteException{
    Data db = DataStore.getDataStore();
    User[] arr = new User[2];
    User firstUser = new User("Ryan", "rchamer", "password", 0);
    db.save(firstUser);
    db.update(User.class, "username", "rchamer", "name", "Mjolnir");
    User Mjolnir = db.retrieve(User.class, "username", "rchamer").toArray(arr)[0];
    assertEquals(firstUser, Mjolnir);
    db.delete(Mjolnir);
   
   
  }
View Full Code Here

   
  }
 
  @Test
  public void testRetrieveAll(){
    Data db = DataStore.getDataStore();
    User firstUser = new User("Brian", "bgaffey", "password", 0);
    db.save(firstUser);
    User secondUser = new User("Gaffey", "gafftron", "password", 0);
    db.save(secondUser);
    List<User> retrievedList = db.retrieveAll(firstUser);
   
    int initCount = retrievedList.size();
    assertTrue(retrievedList.contains(firstUser));
    assertTrue(retrievedList.contains(secondUser));
   
    db.delete(firstUser);
    retrievedList = db.retrieveAll(firstUser);
   
    assertEquals(initCount - 1, retrievedList.size());
    assertTrue(retrievedList.contains(secondUser));
    assertFalse(retrievedList.contains(firstUser));
   
    db.deleteAll(firstUser);
  }
View Full Code Here

    db.deleteAll(firstUser);
  }
 
  @Test
  public void testDeleteAll() throws WPISuiteException{
    Data db = DataStore.getDataStore();
    User[] arr = new User[2];
    User firstUser = new User("Brian", "bgaffey", "password", 0);
    db.save(firstUser);
    User secondUser = new User("Gaffey", "gafftron", "password", 0);
    db.save(secondUser);
    List<User> retrievedList = db.retrieveAll(firstUser);
   
    int initCount = retrievedList.size();
    assertTrue(retrievedList.contains(firstUser));
    assertTrue(retrievedList.contains(secondUser));
   
    retrievedList = db.deleteAll(firstUser);
    User me1 = db.retrieve(User.class, "username", "bgaffey").toArray(arr)[0];
    User me2 = db.retrieve(User.class, "username", "gafftron").toArray(arr)[0];
    assertEquals(initCount, retrievedList.size());
    assertEquals(me1, null);
    assertEquals(me2, null);
  }
View Full Code Here

    assertEquals(me2, null);
  }
 
  @Test
  public void testRetrieveWithProjects() throws WPISuiteException{
    Data db = DataStore.getDataStore();
    User[] arr = new User[2];
    User firstUser = new User("Brian", "bgaffey", "password", 0);
    User secondUser = new User("Alex", "alex", "password1", 1);
    Project myProject = new Project("myProject", "0");
    Project notMyProject = new Project("notMyProject", "1");
    db.save(firstUser);
    db.save(myProject);
//    User result = db.retrieve(User.class, "username", "bgaffey", myProject).toArray(arr)[0];
  //  assertEquals(firstUser, result);
    db.deleteAll(firstUser);
    db.deleteAll(myProject)
  }
View Full Code Here

    db.deleteAll(myProject)
  }
 
  @Test
  public void testOrRetrieve() throws WPISuiteException, IllegalAccessException, InvocationTargetException{
    Data db = DataStore.getDataStore();
   
    User[] arr = new User[2];
    User firstUser = new User("Ryan", "rchamer", "password", 0);
    User secondUser = new User("Bryan", "bgaffey", "pword", 1);
    List<User> both = new ArrayList<User>();
    both.add(firstUser);
    both.add(secondUser);
    db.deleteAll(firstUser);
    db.save(firstUser);
    db.save(secondUser);
    String[] list = new String[2];
    list[0] = "Username";
    list[1] = "Name";
    List<Object> objlist = new ArrayList<Object>();
    objlist.add("rchamer");
    objlist.add("Bryan");
    List<Model> me = db.orRetrieve(firstUser.getClass(), list, objlist);
    assertEquals(me, both);
  }
View Full Code Here

TOP

Related Classes of edu.wpi.cs.wpisuitetng.database.Data

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.