/** 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());
 }
  /** 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);
  }
  /** 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);
  }
  @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);
  }
  /** 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());
  }