Search in sources :

Example 6 with MailTemplate

use of org.rembx.jeeshop.user.model.MailTemplate in project jeeshop by remibantos.

the class MailTemplatesCT method modify_ShouldModify.

@Test
public void modify_ShouldModify() {
    MailTemplate detachedMailTemplateToModify = new MailTemplate("TestNewsletter2", "fr_FR", "test2 content", "Test2 Subject");
    detachedMailTemplateToModify.setId(testMailTemplate.firstMailTemplate().getId());
    service.modify(detachedMailTemplateToModify);
}
Also used : TestMailTemplate(org.rembx.jeeshop.user.test.TestMailTemplate) MailTemplate(org.rembx.jeeshop.user.model.MailTemplate) Test(org.junit.jupiter.api.Test)

Example 7 with MailTemplate

use of org.rembx.jeeshop.user.model.MailTemplate in project jeeshop by remibantos.

the class MailTemplatesCT method modifyUnknown_ShouldThrowNotFoundException.

@Test
public void modifyUnknown_ShouldThrowNotFoundException() {
    MailTemplate detachedMailTemplate = new MailTemplate();
    detachedMailTemplate.setId(9999L);
    try {
        service.modify(detachedMailTemplate);
        fail("should have thrown ex");
    } catch (WebApplicationException e) {
        assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
    }
}
Also used : WebApplicationException(org.rembx.jeeshop.rest.WebApplicationException) TestMailTemplate(org.rembx.jeeshop.user.test.TestMailTemplate) MailTemplate(org.rembx.jeeshop.user.model.MailTemplate) Test(org.junit.jupiter.api.Test)

Example 8 with MailTemplate

use of org.rembx.jeeshop.user.model.MailTemplate in project jeeshop by remibantos.

the class TestMailTemplate method getInstance.

public static TestMailTemplate getInstance() {
    if (instance != null)
        return instance;
    EntityManager entityManager = Persistence.createEntityManagerFactory(UserPersistenceUnit.NAME).createEntityManager();
    entityManager.getTransaction().begin();
    orderConfirmationTpl = new MailTemplate(Mails.orderValidated.name(), "fr_FR", "<html><body>Hello ${gender} ${firstname} ${lastname}. Your order has been registered...</body></html>", "Order Confirmation");
    entityManager.persist(orderConfirmationTpl);
    entityManager.getTransaction().commit();
    instance = new TestMailTemplate();
    entityManager.close();
    return instance;
}
Also used : EntityManager(javax.persistence.EntityManager) MailTemplate(org.rembx.jeeshop.user.model.MailTemplate)

Example 9 with MailTemplate

use of org.rembx.jeeshop.user.model.MailTemplate in project jeeshop by remibantos.

the class TestMailTemplate method getInstance.

public static TestMailTemplate getInstance() {
    if (instance != null)
        return instance;
    EntityManager entityManager = Persistence.createEntityManagerFactory(UserPersistenceUnit.NAME).createEntityManager();
    entityManager.getTransaction().begin();
    mailTemplate1 = new MailTemplate("Newsletter1", "fr_FR", "<html><body>bla bla...</body></html>", "Hello Subject");
    userRegistrationMailTpl = new MailTemplate(Mails.userRegistration.name(), "fr_FR", "<html><body>Welcome ${gender} ${firstname} ${lastname}</body></html>", "New Registration Subject");
    ressetPasswordMailTpl = new MailTemplate(Mails.userResetPassword.name(), "fr_FR", "<html><body>Here is the link to reset your password</body></html>", "Reset Password Subject");
    changePasswordMailTpl = new MailTemplate(Mails.userChangePassword.name(), "fr_FR", "<html><body>Hello there, your password has changed!</body></html>", "Change Password Subject");
    entityManager.persist(mailTemplate1);
    entityManager.persist(userRegistrationMailTpl);
    entityManager.persist(ressetPasswordMailTpl);
    entityManager.persist(changePasswordMailTpl);
    entityManager.getTransaction().commit();
    instance = new TestMailTemplate();
    entityManager.close();
    return instance;
}
Also used : EntityManager(javax.persistence.EntityManager) MailTemplate(org.rembx.jeeshop.user.model.MailTemplate)

Example 10 with MailTemplate

use of org.rembx.jeeshop.user.model.MailTemplate in project jeeshop by remibantos.

the class MailTemplatesCT method delete_shouldRemove.

@Test
public void delete_shouldRemove() {
    entityManager.getTransaction().begin();
    MailTemplate mailTemplate = new MailTemplate("TestNewsletter3", "fr_FR", "test content 3", "Test Subject3");
    entityManager.persist(mailTemplate);
    entityManager.getTransaction().commit();
    entityManager.getTransaction().begin();
    service.delete(mailTemplate.getId());
    entityManager.getTransaction().commit();
    assertThat(entityManager.find(MailTemplate.class, mailTemplate.getId())).isNull();
}
Also used : TestMailTemplate(org.rembx.jeeshop.user.test.TestMailTemplate) MailTemplate(org.rembx.jeeshop.user.model.MailTemplate) Test(org.junit.jupiter.api.Test)

Aggregations

MailTemplate (org.rembx.jeeshop.user.model.MailTemplate)14 Test (org.junit.jupiter.api.Test)6 TestMailTemplate (org.rembx.jeeshop.user.test.TestMailTemplate)6 WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)5 RolesAllowed (javax.annotation.security.RolesAllowed)3 Configuration (freemarker.template.Configuration)2 Template (freemarker.template.Template)2 StringWriter (java.io.StringWriter)2 EntityManager (javax.persistence.EntityManager)2 Transactional (javax.transaction.Transactional)2 JPAQueryFactory (com.querydsl.jpa.impl.JPAQueryFactory)1 User (org.rembx.jeeshop.user.model.User)1