Search in sources :

Example 6 with Mailing

use of com.gitblit.models.Mailing in project gitblit by gitblit.

the class TicketServiceTest method testNotifier.

@Test
public void testNotifier() throws Exception {
    Change kernel = new Change("james");
    kernel.setField(Field.title, "Sample ticket");
    kernel.setField(Field.body, "this **is** my sample body\n\n- I hope\n- you really\n- *really* like it");
    kernel.setField(Field.status, Status.New);
    kernel.setField(Field.type, Type.Proposal);
    kernel.comment("this is a sample comment on a kernel change");
    Patchset patchset = new Patchset();
    patchset.insertions = 100;
    patchset.deletions = 10;
    patchset.number = 1;
    patchset.rev = 25;
    patchset.tip = "50f57913f816d04a16b7407134de5d8406421f37";
    kernel.patchset = patchset;
    TicketModel ticket = service.createTicket(getRepository(), 0L, kernel);
    Change merge = new Change("james");
    merge.setField(Field.mergeSha, patchset.tip);
    merge.setField(Field.mergeTo, "master");
    merge.setField(Field.status, Status.Merged);
    ticket = service.updateTicket(getRepository(), ticket.number, merge);
    ticket.repository = getRepository().name;
    TicketNotifier notifier = service.createNotifier();
    Mailing mailing = notifier.queueMailing(ticket);
    assertNotNull(mailing);
}
Also used : TicketNotifier(com.gitblit.tickets.TicketNotifier) Patchset(com.gitblit.models.TicketModel.Patchset) TicketModel(com.gitblit.models.TicketModel) Change(com.gitblit.models.TicketModel.Change) Mailing(com.gitblit.models.Mailing) Test(org.junit.Test)

Example 7 with Mailing

use of com.gitblit.models.Mailing in project gitblit by gitblit.

the class MailTest method testSendMail.

@Test
public void testSendMail() throws Exception {
    FileSettings settings = new FileSettings("mailtest.properties");
    MailService mail = new MailService(settings);
    Mailing mailing = Mailing.newPlain();
    mailing.setRecipients(settings.getStrings(Keys.mail.adminAddresses));
    Message message = mail.createMessage(mailing);
    message.setSubject("Test");
    message.setText("Lägger till andra stycket i ny fil. UTF-8 encoded");
    mail.queue(message);
    mail.run();
    assertTrue("mail queue is not empty!", mail.hasEmptyQueue());
}
Also used : MailService(com.gitblit.service.MailService) Message(javax.mail.Message) FileSettings(com.gitblit.FileSettings) Mailing(com.gitblit.models.Mailing) Test(org.junit.Test)

Aggregations

Mailing (com.gitblit.models.Mailing)7 IOException (java.io.IOException)2 Message (javax.mail.Message)2 Test (org.junit.Test)2 FileSettings (com.gitblit.FileSettings)1 TicketModel (com.gitblit.models.TicketModel)1 Change (com.gitblit.models.TicketModel.Change)1 Patchset (com.gitblit.models.TicketModel.Patchset)1 MailService (com.gitblit.service.MailService)1 TicketNotifier (com.gitblit.tickets.TicketNotifier)1 File (java.io.File)1 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)1