Package edu.wpi.cs.wpisuitetng.database

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


  }
 
  @Test
  public void testAndRetrieve() 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", "rchamer", "pword", 1);
    List<User> first = new ArrayList<User>();
    first.add(firstUser);
    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("Ryan");
    List<Model> me = db.andRetrieve(firstUser.getClass(), list, objlist);
    assertEquals(me, first);
  }
View Full Code Here


    assertEquals(me, first);
  }
 
  @Test
  public void testComplexRetrieve() 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", "rchamer", "pword", 1);
    User thirdUser = new User("Tyler", "twack", "word", 2);
    List<User> first = new ArrayList<User>();
    db.deleteAll(firstUser);
    first.add(firstUser);
    first.add(thirdUser);
    db.deleteAll(firstUser);
    db.save(firstUser);
    db.save(secondUser);
    db.save(thirdUser);
    String[] list = new String[2];
    list[0] = "Username";
    list[1] = "Name";
    List<Object> objlist = new ArrayList<Object>();
    objlist.add("rchamer");
    objlist.add("Ryan");
   
    String[] orList = new String[2];
    orList[0] = "idNum";
    orList[1] = "Name";
    List<Object> orObjList = new ArrayList<Object>();
    orObjList.add(0);
    orObjList.add("Tyler");
   
    List<Model> me = db.complexRetrieve(firstUser.getClass(), list, objlist, firstUser.getClass(), orList, orObjList);
    assertEquals(me, first);
  }
View Full Code Here

    assertEquals(initCount + 2, myList.length);
  }

  @Test(expected = WPISuiteException.class)
  public void testSaveFail() throws WPISuiteException {
    new ProjectManager(new Data(){
      @Override
      public <T> boolean save(T aTNG) {return false;}
      @Override
      public List<Model> retrieve(Class anObjectQueried,String aFieldName, Object theGivenValue) {return null;}
      @Override
View Full Code Here

    ).save(null, null);
  }

  @Test(expected = WPISuiteException.class)
  public void testDeleteEntityFail() throws WPISuiteException {
    new ProjectManager(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
  @Ignore //TODO: this test does not account for permissions
  public void testDeleteEntity() throws WPISuiteException
  {
    new ProjectManager(new Data(){

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

public class Db4oDatabaseTest {
 

  @Test
  public void testSaveandRetrieve() throws WPISuiteException {
    Data db = DataStore.getDataStore();
    User[] arr = new User[1];
    User firstUser = new User("Ryan", "rchamer", "password", 0);
    db.save(firstUser);
    User me = db.retrieve(User.class, "username", "rchamer").toArray(arr)[0];
    assertEquals(me, firstUser);
    db.delete(me);
  }
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.