Package com.alvazan.test.db

Examples of com.alvazan.test.db.Activity


  }
 
  @Test
  public void testActivityHasNullAccount() {
    //Activity has null reference to account
    Activity act = new Activity("act1");
    act.setName("asdfsdf");
    act.setNumTimes(3);
   
    mgr.put(act);
    mgr.flush();
   
    Activity activityResult = mgr.find(Activity.class, act.getId());
    Assert.assertEquals(act.getName(), activityResult.getName());
    Assert.assertEquals(act.getNumTimes(), activityResult.getNumTimes());   
  }
View Full Code Here


    Assert.assertEquals(act.getNumTimes(), activityResult.getNumTimes());   
  }
 
  @Test
  public void testGetReference() {
    Activity activity = readWriteBasic(mgr);
   
    Activity reference = mgr.getReference(Activity.class, activity.getId());
   
    //Any calls to reference causes call to database(or cache) to fill the object in
    Assert.assertEquals(activity.getName(), reference.getName());
    Assert.assertEquals(activity.getNumTimes(), reference.getNumTimes());
  }
View Full Code Here

    Assert.assertEquals(activity.getNumTimes(), reference.getNumTimes());
  }
 
  @Test
  public void testWriteReadProxy() {
    Activity activity = readWriteBasic(mgr);
   
    //This is the proxy object
    Account account = activity.getAccount();
    //This will cause a load from the database
    Assert.assertEquals(ACCOUNT_NAME, account.getName());
  }
View Full Code Here

  public void testWriteActivityAccountNoSavedYet() {
    Account acc = new Account();
    acc.setName(ACCOUNT_NAME);
    acc.setUsers(5.0f);
   
    Activity act = new Activity("act1");
    act.setAccount(acc);
    act.setName("asdfsdf");
    act.setNumTimes(3);
   
    try {
      mgr.put(act);
      Assert.fail("Should have failed since account has no pk during activity save");
    } catch(ChildWithNoPkException e) {
View Full Code Here

    }
  }

  @Test
  public void testNotfound() {
    Activity act = mgr.find(Activity.class, "asdf");
    Assert.assertNull(act);
  }
View Full Code Here

    Account acc2 = new Account();
    acc2.setName("account2");
    acc2.setUsers(5.0f);
    mgr.put(acc2);
   
    Activity act1 = new Activity("act1");
    act1.setAccount(acc);
    act1.setName("asdfsdf");
    act1.setNumTimes(3);
    mgr.put(act1);
   
    Activity act2 = new Activity("act2");
    act2.setAccount(acc);
    act2.setName("dean");
    mgr.put(act2);
   
    Activity act3 = new Activity("act3");
    act3.setAccount(null);
    act3.setName("no account");
    mgr.put(act3);
   
    Activity act4 = new Activity("act4");
    act4.setAccount(acc2);
    act4.setName("prevAcc2");   
    mgr.put(act4);
    mgr.flush();
   
    Activity actX = mgr.find(Activity.class, act3.getId());
    actX.setNumTimes(9);
    actX.setAccount(acc);
    mgr.put(actX);
   
    Activity act = mgr.find(Activity.class, act4.getId());
    act.setNumTimes(2);
    mgr.put(act);
    mgr.flush();
   
    List<Activity> activities = Activity.findByAccount(mgr, acc);
    Assert.assertEquals(3, activities.size());
View Full Code Here

    Account acc = new Account("acc1");
    acc.setName(ACCOUNT_NAME);
    acc.setUsers(5.0f);
    mgr.fillInWithKey(acc);
   
    Activity act = new Activity("act1");
    act.setAccount(acc);
    act.setName("asdfsdf");
    act.setNumTimes(3);
   
    mgr.put(act);
   
    mgr.flush();
   
    Activity activityResult = mgr.find(Activity.class, act.getId());
    Account theProxy = activityResult.getAccount();
    try {
      theProxy.getName();
      Assert.fail("Account was never saved so above line should fail");
    } catch(RowNotFoundException e) {
      log.info("this is expected");
View Full Code Here

    acc.setName(ACCOUNT_NAME);
    acc.setUsers(5.0f);
   
    mgr.put(acc);
   
    Activity act = new Activity("act1");
    act.setAccount(acc);
    act.setName("asdfsdf");
    act.setNumTimes(3);
   
    mgr.put(act);
   
    mgr.flush();
   
    Account accountResult = mgr.find(Account.class, acc.getId());
    Assert.assertEquals(ACCOUNT_NAME, accountResult.getName());
    Assert.assertEquals(acc.getUsers(), accountResult.getUsers());
   
    Activity activityResult = mgr.find(Activity.class, act.getId());
    Assert.assertEquals(act.getName(), activityResult.getName());
    Assert.assertEquals(act.getNumTimes(), activityResult.getNumTimes());
    Assert.assertEquals(acc.getId(), activityResult.getAccount().getId());
   
    return activityResult;
  }
View Full Code Here

  @Test
  public void testWriteRead() {
    //let's use TWO entities that share the same columnFamily AND use the same key in both to make sure
    //the prefix stuff works just fine...
   
    Activity act1 = new Activity("myid");
    act1.setName("myname");
    mgr.put(act1);
   
    PartitionedSingleTrade trade = new PartitionedSingleTrade();
    trade.setId("myid");
    trade.setNumber(89);
    mgr.put(trade);

    //throw an a guy with Long key types as well...
    TimeSeriesData d = new TimeSeriesData();
    d.setKey(897L);
    d.setSomeName("qwer");
    mgr.put(d);
    mgr.flush();
   
    //unfortunately, the two rows are written as one (ie. MERGED) so
    //to really TEST this out, we remove the trade row to make sure we still have the Activity
    //row
    mgr.remove(trade);
    mgr.flush();
   
    NoSqlEntityManager mgr2 = factory.createEntityManager();
   
    PartitionedSingleTrade r = mgr2.find(PartitionedSingleTrade.class, trade.getId());
    Assert.assertNull(r);
   
    Activity act = mgr2.find(Activity.class, act1.getId());
    Assert.assertNotNull(act);
    Assert.assertEquals(act1.getName(), act.getName());
   
    TimeSeriesData d2 = mgr2.find(TimeSeriesData.class, d.getKey());
    Assert.assertEquals(d.getSomeName(), d2.getSomeName());
  }
View Full Code Here

        List<Activity> zero = Activity.findByBigInt(mgr, bigInt1);
        Assert.assertEquals(0, zero.size());
    }

  private void setupRecords() {
    Activity act = new Activity("act1");
    act.setName("hello");
    act.setMyFloat(5.65f);
    act.setUniqueColumn("notunique");
    act.setNumTimes(5);
    act.setIsCool(true);
    BigInteger bigInt = BigInteger.valueOf(Long.MAX_VALUE+87);
    act.setBigInt(bigInt);
    time = LocalDateTime.now();
    act.setDate(time);
    uid = new UUID();
    act.setUniqueId(uid);
    mgr.put(act);
   
    //Everything is null for this activity so queries above should not find him...
    Activity act2 = new Activity("act2");
    act2.setNumTimes(58);
    mgr.put(act2);
   
    mgr.flush();
  }
View Full Code Here

TOP

Related Classes of com.alvazan.test.db.Activity

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.