Package com.gnizr.db.dao

Examples of com.gnizr.db.dao.TagAssertion


  protected IDataSet getDataSet() throws Exception {
    return new FlatXmlDataSet(TestTagAssertionDBDao.class.getResourceAsStream("/dbunit/tagassertiondbdao/TestTagAssertionDBDao-input.xml"));
  }

  public void testGetTagAssertion() throws Exception{
    TagAssertion asrt = dao.getTagAssertion((1));
    assertNotNull(asrt);
    assertEquals((100),asrt.getSubject().getId());
    assertEquals((1),asrt.getProperty().getId());
    assertEquals((101),asrt.getObject().getId());
    assertEquals((1),asrt.getUser().getId());
  }
View Full Code Here


    assertEquals((101),asrt.getObject().getId());
    assertEquals((1),asrt.getUser().getId());
  }
 
  public void testDeleteTagAssertion() throws Exception{
    TagAssertion asrt = dao.getTagAssertion((1));
    assertNotNull(asrt);
    assertTrue(dao.deleteTagAssertion(asrt.getId()));
    asrt = dao.getTagAssertion((1));
    assertNull(asrt);
    assertNull(dao.getTagAssertion((1000000)));
  }
View Full Code Here

    assertNull(asrt);
    assertNull(dao.getTagAssertion((1000000)));
  }
 
  public void testCreateTagAssertion() throws Exception{
    TagAssertion asrt = new TagAssertion();
    asrt.setSubject(new UserTag((104)));
    asrt.setProperty(new TagProperty((1)));
    asrt.setObject(new UserTag((103)));
    asrt.setUser(new User((1)));
    int id = dao.createTagAssertion(asrt);
    assertNotNull(id);
    assertTrue((id >0));
   
    int id2 = dao.createTagAssertion(asrt);
    assertNotNull(id);
    assertTrue((id >0));
    assertEquals(id,id2);
   
    TagAssertion asrtCopy = dao.getTagAssertion(id);
    assertEquals(asrt.getSubject().getId(),asrtCopy.getSubject().getId());
    assertEquals(asrt.getProperty().getId(),asrtCopy.getProperty().getId());
    assertEquals(asrt.getObject().getId(),asrtCopy.getObject().getId());
    assertEquals(asrt.getUser().getId(),asrtCopy.getUser().getId());
    assertTrue(dao.deleteTagAssertion(id));
  }
View Full Code Here

    assertEquals(asrt.getUser().getId(),asrtCopy.getUser().getId());
    assertTrue(dao.deleteTagAssertion(id));
  }
 
  public void testUpdateTagAssertion() throws Exception{
    TagAssertion asrt = dao.getTagAssertion((1));
    assertNotNull(asrt);
    assertEquals((1),asrt.getProperty().getId());
    asrt.setProperty(new TagProperty((3)));
    assertTrue(dao.updateTagAssertion(asrt));
    asrt = dao.getTagAssertion((1));
    assertEquals((3),asrt.getProperty().getId());
  }
View Full Code Here

 
  public void testFindTagAssertionUser() throws Exception{
    List<TagAssertion> assertions = dao.findTagAssertion(new User((1)));
    assertEquals(2,assertions.size());
   
    TagAssertion ta1 = assertions.get(0);
    assertEquals(100,ta1.getSubject().getId());
    assertEquals(101,ta1.getObject().getId());
    assertEquals(1,ta1.getProperty().getId());
    assertEquals(1,ta1.getSubject().getTag().getId());
    assertEquals(2,ta1.getObject().getTag().getId());
    assertEquals("cnn",ta1.getSubject().getTag().getLabel());
    assertEquals("news",ta1.getObject().getTag().getLabel());
    assertEquals("hchen1",ta1.getUser().getUsername());
    assertEquals("hchen1",ta1.getSubject().getUser().getUsername());
    assertEquals("hchen1",ta1.getObject().getUser().getUsername());
  }
View Full Code Here

    assertEquals(0, result.size());
  }
 
  public void testCreateTagAssertionBatch() throws Exception{
    TagAssertion[] ta = new TagAssertion[1];
    ta[0] = new TagAssertion(new UserTag(100),new TagProperty(1),new UserTag(103),new User(1));
   
    boolean isOkay = dao.createTagAssertion(ta);
    assertTrue(isOkay);
   
    List<TagAssertion> result = dao.findTagAssertion(new User(1),new UserTag(100),new TagProperty(1),new UserTag(103));
View Full Code Here

    assertEquals(1,result.size());
  }
 
  public void testCreateTagAssertionBatch2() throws Exception{
    TagAssertion[] ta = new TagAssertion[3];
    ta[0] = new TagAssertion(new UserTag(100),new TagProperty(1),new UserTag(103),new User(1));
    ta[1] = new TagAssertion(new UserTag(101),new TagProperty(1),new UserTag(103),new User(1));
    ta[2] = new TagAssertion(new UserTag(100),new TagProperty(1),new UserTag(103),new User(1));
   
    boolean isOkay = dao.createTagAssertion(ta);
    assertTrue(isOkay);
   
    List<TagAssertion> result = dao.findTagAssertion(new User(1),new UserTag(100),new TagProperty(1),new UserTag(103));
View Full Code Here

  public void testFillIdTagAssertion() throws Exception{
    User user = new User("hchen1");
    UserTag subject = new UserTag("hchen1","webwork");
    TagProperty property = new TagProperty(3);
    UserTag object = new UserTag(2);
    TagAssertion asrt = new TagAssertion(subject,property,object,user);
    GnizrDaoUtil.fillId(tagAssertionDao, tagPrptDao, tagDao, userDao,asrt);
    assertEquals((1),asrt.getUser().getId());
    assertEquals((1),asrt.getSubject().getId());
    assertEquals((2),asrt.getObject().getId());
    assertEquals((3),asrt.getProperty().getId());
  }
View Full Code Here

  public void testFillObjectTagAssertion() throws Exception{
    User u = new User((1));
    UserTag s = new UserTag((1));
    UserTag o = new UserTag((2));
    TagProperty p = new TagProperty((3));
    TagAssertion ta = new TagAssertion(s,p,o,u);
    GnizrDaoUtil.fillObject(tagAssertionDao, tagPrptDao, tagDao, userDao,ta);
    assertEquals("hchen1",ta.getUser().getUsername());
    assertEquals("webwork",ta.getSubject().getTag().getLabel());
    assertEquals("wii",ta.getObject().getTag().getLabel());
    assertEquals("narrower",ta.getProperty().getName());
  }
View Full Code Here

    boolean isOkay = false;
    List<TagAssertion> tagAssertion = new ArrayList<TagAssertion>();
    try {
      UserTag[] objectTag = createUserTag(user, tags2add);
      for(int i = 0; i < objectTag.length; i++){
        TagAssertion ta = new TagAssertion();
        ta.setUser(user);
        ta.setSubject(subjectTag);
        ta.setProperty(prpt);
        ta.setObject(objectTag[i]);
        tagAssertion.add(ta);
      }
      int size = tagAssertion.size();
      isOkay = tagAsrtDao.createTagAssertion(tagAssertion.toArray(new TagAssertion[size]));
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.gnizr.db.dao.TagAssertion

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.