Search in sources :

Example 26 with User

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

the class UsersCT method notActivatedTestUser.

private User notActivatedTestUser() {
    User user = new User("reset1@test.com", "password", "John", "Doe", "+33616161616", null, new Date(), "fr_FR", null);
    user.setGender("M.");
    final UUID actionToken = UUID.randomUUID();
    user.setActionToken(actionToken);
    user.setActivated(false);
    entityManager.getTransaction().begin();
    entityManager.persist(user);
    entityManager.getTransaction().commit();
    return user;
}
Also used : TestUser(org.rembx.jeeshop.user.test.TestUser) User(org.rembx.jeeshop.user.model.User) UUID(java.util.UUID) Date(java.util.Date)

Example 27 with User

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

the class UsersCT method modifyUnknownUser_ShouldThrowNotFoundException.

@Test
public void modifyUnknownUser_ShouldThrowNotFoundException() {
    User detachedUser = new User("test3@test.com", "test", "John", "Doe", "+33616161616", null, new Date(), "fr_FR", null);
    detachedUser.setId(9999L);
    try {
        service.modify(sessionContextMock, detachedUser);
        fail("should have thrown ex");
    } catch (WebApplicationException e) {
        assertThat(e.getResponse().getStatusInfo()).isEqualTo(Response.Status.NOT_FOUND);
    }
}
Also used : TestUser(org.rembx.jeeshop.user.test.TestUser) User(org.rembx.jeeshop.user.model.User) WebApplicationException(org.rembx.jeeshop.rest.WebApplicationException) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 28 with User

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

the class DefaultPaymentTransactionEngine method sendOrderConfirmationMail.

protected void sendOrderConfirmationMail(Order order) {
    User user = order.getUser();
    MailTemplate mailTemplate = mailTemplateFinder.findByNameAndLocale(orderValidated.name(), user.getPreferredLocale());
    if (mailTemplate == null) {
        LOG.warn("orderValidated e-mail template does not exist. Configure this missing template to allow user e-mail notification");
        return;
    }
    try {
        Template mailContentTpl = new Template(orderValidated.name(), mailTemplate.getContent(), new Configuration(Configuration.VERSION_2_3_21));
        final StringWriter mailBody = new StringWriter();
        mailContentTpl.process(order, mailBody);
        mailer.sendMail(mailTemplate.getSubject(), user.getLogin(), mailBody.toString());
    } catch (Exception e) {
        LOG.error("Unable to send mail " + orderValidated + " to user " + user.getLogin(), e);
    }
}
Also used : User(org.rembx.jeeshop.user.model.User) Configuration(freemarker.template.Configuration) StringWriter(java.io.StringWriter) MailTemplate(org.rembx.jeeshop.user.model.MailTemplate) MailTemplate(org.rembx.jeeshop.user.model.MailTemplate) Template(freemarker.template.Template)

Aggregations

User (org.rembx.jeeshop.user.model.User)28 Test (org.junit.jupiter.api.Test)18 TestUser (org.rembx.jeeshop.user.test.TestUser)18 Date (java.util.Date)9 WebApplicationException (org.rembx.jeeshop.rest.WebApplicationException)9 RolesAllowed (javax.annotation.security.RolesAllowed)4 BasicUserPrincipal (org.apache.http.auth.BasicUserPrincipal)3 Address (org.rembx.jeeshop.user.model.Address)3 UUID (java.util.UUID)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 Order (org.rembx.jeeshop.order.model.Order)2 JPAQueryFactory (com.querydsl.jpa.impl.JPAQueryFactory)1 Configuration (freemarker.template.Configuration)1 Template (freemarker.template.Template)1 StringWriter (java.io.StringWriter)1 Discount (org.rembx.jeeshop.catalog.model.Discount)1 Product (org.rembx.jeeshop.catalog.model.Product)1 SKU (org.rembx.jeeshop.catalog.model.SKU)1 MailTemplate (org.rembx.jeeshop.user.model.MailTemplate)1