コード例 #1
0
  /** Test of save method with update purpose, of class MessagTemplateDAOImpl. */
  @Test
  public void testUpdate() {
    System.out.println("test MessageTemplateDAO update");
    String alttemplate = "altered template";
    Date altdate = new Date();

    MessageTemplate fromdb1 =
        (MessageTemplateImpl)
            mtDao
                .getSessionFactory()
                .getCurrentSession()
                .get(MessageTemplateImpl.class, mt5.getId());
    fromdb1.setDateCreated(altdate);
    fromdb1.setMessageType(type);
    fromdb1.setNotificationType(nt2);
    fromdb1.setTemplate(alttemplate);

    mtDao.save(fromdb1);

    MessageTemplate fromdb =
        (MessageTemplateImpl)
            mtDao
                .getSessionFactory()
                .getCurrentSession()
                .get(MessageTemplateImpl.class, fromdb1.getId());

    Assert.assertNotNull(fromdb);
    Assert.assertEquals(mt5, fromdb);
    Assert.assertEquals(nt2, fromdb.getNotificationType());
    Assert.assertEquals(alttemplate, fromdb.getTemplate());
    Assert.assertEquals(altdate, fromdb.getDateCreated());
  }
コード例 #2
0
  /** Test of save method, of class MessagTemplateDAOImpl. */
  @Test
  public void testGetTemplateByLangNotifMType() {
    System.out.println("getTemplateByLangNotifMType");

    mtDao.getSessionFactory().getCurrentSession().save(mt2);

    MessageTemplate result = mtDao.getTemplateByLangNotifMType(l1, nt2, type);
    Assert.assertNotNull(result);
    Assert.assertEquals(mt2, result);
  }
コード例 #3
0
  /** Test of delete method, of class MessagTemplateDAOImpl. */
  @Test
  public void testDelete() {
    System.out.println("test MessageTemplate delete");

    mtDao.delete(mt4);

    MessageTemplate fromdb =
        (MessageTemplate)
            mtDao
                .getSessionFactory()
                .getCurrentSession()
                .get(MessageTemplateImpl.class, mt4.getId());
    Assert.assertNull(fromdb);
  }
コード例 #4
0
  /** Test of save method, of class MessagTemplateDAOImpl. */
  @Test
  public void testSave() {
    System.out.print("test save MessageTemplate Object");

    mtDao.save(mt1);

    MessageTemplate fromdb =
        (MessageTemplate)
            mtDao
                .getSessionFactory()
                .getCurrentSession()
                .get(MessageTemplateImpl.class, mt1.getId());
    Assert.assertNotNull(fromdb);
  }
コード例 #5
0
  @After
  public void tearDown() {

    mtDao.delete(mt1);
    mtDao.delete(mt2);
    mtDao.delete(mt3);
    mtDao.delete(mt4);
    mtDao.delete(mt5);
    ntDao.delete(nt1);
    ntDao.delete(nt2);
    ntDao.delete(nt3);
    lDao.delete(l1);
    lDao.delete(l2);
  }
コード例 #6
0
 /** Test of getById method, of class MessagTemplateDAOImpl. */
 @Test
 public void testGetById() {
   System.out.println("test MessageTemplate getById");
   MessageTemplate mt = (MessageTemplate) mtDao.getById(mt3.getId());
   Assert.assertNotNull(mt);
   Assert.assertEquals(mt3, mt);
   Assert.assertEquals(mt3.getId(), mt.getId());
   Assert.assertEquals(mt3.getLanguage(), mt.getLanguage());
   Assert.assertEquals(mt3.getTemplate(), mt.getTemplate());
 }
コード例 #7
0
  @Before
  public void setUp() {

    nt1.setId(401L);
    nt1.setName("some name");

    nt2.setId(402L);
    nt2.setName("second name");
    nt2.setDescription("for second test");

    nt3.setId(407L);
    nt3.setName("third name");
    nt3.setDescription("for third test");

    l1.setId(90000000001l);
    l1.setCode("sk");

    l2.setId(90000000002l);
    l2.setCode("ch");

    mtDao = coreManager.createMessageTemplateDAO();
    lDao = coreManager.createLanguageDAO();
    ntDao = coreManager.createNotificationTypeDAO();

    mt1.setId(90000000003l);
    mt1.setNotificationType(nt1);
    mt1.setLanguage(l1);
    mt1.setMessageType(type);
    mt1.setTemplate("test template for test 1");

    mt2.setId(90000000004l);
    mt2.setNotificationType(nt2);
    mt2.setLanguage(l1);
    mt2.setMessageType(type);
    mt2.setTemplate(template);

    mt3.setId(90000000005l);
    mt3.setNotificationType(nt3);
    mt3.setLanguage(l1);
    mt3.setMessageType(type);
    mt3.setTemplate(template);

    mt4.setId(90000000006l);
    mt4.setNotificationType(nt1);
    mt4.setLanguage(l1);
    mt4.setMessageType(type);
    mt4.setTemplate("template for message 4");

    mt5.setId(90000000007l);
    mt5.setNotificationType(nt3);
    mt5.setLanguage(l1);
    mt5.setMessageType(type);
    mt5.setTemplate("template for message 5");

    lDao.save(l1);
    lDao.save(l2);
    ntDao.save(nt1);
    ntDao.save(nt2);
    ntDao.save(nt3);
    mtDao.save(mt3);
    mtDao.save(mt4);
    mtDao.save(mt5);
  }