Search in sources :

Example 1 with ZDateTime

use of com.zimbra.client.ZDateTime in project zm-mailbox by Zimbra.

the class TestJaxb method testProposeNewTimeWorkflow.

/**
     * Bug 96748:
     * 1. user1 sends meeting invite to user2
     * 2. user2 proposes new time
     * 3. user1 accepts the proposed new time and new invite is sent to user2
     * 4. user2 accepts the new invite
     * At step 4, no acceptance message was being generated
     */
@Test
public void testProposeNewTimeWorkflow() throws Exception {
    TestUtil.createAccount(ORGANIZER);
    TestUtil.createAccount(ATTENDEE1);
    String subject = NAME_PREFIX + " attendee will cause time to change";
    ZMailbox organizerBox = TestUtil.getZMailbox(ORGANIZER);
    ZMailbox attendeeBox = TestUtil.getZMailbox(ATTENDEE1);
    String organizerEmail = organizerBox.getName();
    // Create and send the meeting request
    InviteComponent inviteComp = new InviteComponent();
    inviteComp.addAttendee(CalendarAttendee.createForAddressDisplaynameRolePartstatRsvp(attendeeBox.getName(), getCN(attendeeBox), "REQ", "NE", true));
    inviteComp.setStatus("CONF");
    inviteComp.setFreeBusy("B");
    inviteComp.setCalClass("PUB");
    inviteComp.setTransparency("O");
    inviteComp.setIsDraft(false);
    inviteComp.setIsAllDay(false);
    Date startDate = new Date(System.currentTimeMillis() + Constants.MILLIS_PER_DAY);
    ZDateTime start = new ZDateTime(startDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    Date endDate = new Date(startDate.getTime() + Constants.MILLIS_PER_HOUR);
    ZDateTime end = new ZDateTime(endDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    Date newStartDate = new Date(System.currentTimeMillis() + 2 * Constants.MILLIS_PER_DAY);
    ZDateTime newStart = new ZDateTime(newStartDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    Date newEndDate = new Date(newStartDate.getTime() + Constants.MILLIS_PER_HOUR);
    ZDateTime newEnd = new ZDateTime(newEndDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    inviteComp.setDtStart(DtTimeInfo.createForDatetimeAndZone(start.getDateTime(), start.getTimeZoneId()));
    inviteComp.setDtEnd(DtTimeInfo.createForDatetimeAndZone(end.getDateTime(), end.getTimeZoneId()));
    inviteComp.setName(subject);
    inviteComp.setLocation("room 101");
    inviteComp.setOrganizer(CalOrganizer.createForAddress(organizerEmail));
    InvitationInfo invite = new InvitationInfo();
    invite.setInviteComponent(inviteComp);
    EmailAddrInfo attendeeAddr = EmailAddrInfo.createForAddressPersonalAndAddressType(attendeeBox.getName(), getCN(attendeeBox), "t");
    MimePartInfo mimePart = MimePartInfo.createForContentType("multipart/alternative");
    mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", "invite body"));
    mimePart.addMimePart(MimePartInfo.createForContentTypeAndContent("text/html", "<html><body><p><b>invite</b> body</p></body></html>"));
    Msg msg = new Msg();
    msg.setFolderId("10");
    msg.setInvite(invite);
    msg.addEmailAddress(attendeeAddr);
    msg.setSubject(subject);
    msg.setMimePart(mimePart);
    CreateAppointmentRequest createApptReq = CreateAppointmentRequest.create(msg);
    CreateAppointmentResponse caResp = organizerBox.invokeJaxb(createApptReq);
    Assert.assertNotNull("JAXB CreateAppointmentResponse object", caResp);
    Assert.assertNotNull("JAXB CreateAppointmentResponse calItemId", caResp.getCalItemId());
    Assert.assertNotNull("JAXB CreateAppointmentResponse invId", caResp.getCalInvId());
    Assert.assertNotNull("JAXB CreateAppointmentResponse modified sequence ms", caResp.getModifiedSequence());
    Assert.assertNotNull("JAXB CreateAppointmentResponse rev", caResp.getRevision());
    ZMessage seriesInviteMsg = TestUtil.waitForMessage(attendeeBox, subject);
    Assert.assertNotNull("ZMessage for series invite", seriesInviteMsg);
    ZInvite seriesInvite = seriesInviteMsg.getInvite();
    Assert.assertNotNull("ZInvite for series invite", seriesInvite);
    AppointmentHitInfo hit = findMatchingAppointment(attendeeBox, startDate, endDate, subject);
    // User 1 proposes new time for meeting
    ZMessage propNewTimeMsg = attendeeProposeNewTimeForMeeting(attendeeBox, organizerBox, newStart, newEnd, hit, subject);
    Assert.assertNotNull("ZMessage for propose new time", propNewTimeMsg);
    hit = findMatchingAppointment(organizerBox, startDate, endDate, subject);
    // Organizer changes the meeting to the new proposed time
    // easier to find unique inbox entry
    subject = NAME_PREFIX + " attendee CAUSED time to change";
    ZMessage attendee2ndInvite = organizerChangeTimeForMeeting(attendeeBox, organizerBox, newStart, newEnd, hit, subject);
    Assert.assertNotNull("attendee 2nd invite", attendee2ndInvite);
    hit = findMatchingAppointment(attendeeBox, newStartDate, newEndDate, "inid:10");
    acceptInvite(attendeeBox, organizerBox, attendee2ndInvite, subject);
}
Also used : Msg(com.zimbra.soap.mail.type.Msg) ZMessage(com.zimbra.client.ZMessage) CreateAppointmentRequest(com.zimbra.soap.mail.message.CreateAppointmentRequest) ZInvite(com.zimbra.client.ZInvite) InvitationInfo(com.zimbra.soap.mail.type.InvitationInfo) CreateAppointmentResponse(com.zimbra.soap.mail.message.CreateAppointmentResponse) AppointmentHitInfo(com.zimbra.soap.mail.type.AppointmentHitInfo) Date(java.util.Date) InviteComponent(com.zimbra.soap.mail.type.InviteComponent) ZDateTime(com.zimbra.client.ZDateTime) ZMailbox(com.zimbra.client.ZMailbox) EmailAddrInfo(com.zimbra.soap.mail.type.EmailAddrInfo) MimePartInfo(com.zimbra.soap.mail.type.MimePartInfo) Test(org.junit.Test)

Example 2 with ZDateTime

use of com.zimbra.client.ZDateTime in project zm-mailbox by Zimbra.

the class TestJaxb method proposeNewTimeWorkflow.

/**
 * Bug 96748:
 * 1. user1 sends meeting invite to user2
 * 2. user2 proposes new time
 * 3. user1 accepts the proposed new time and new invite is sent to user2
 * 4. user2 accepts the new invite
 * At step 4, no acceptance message was being generated
 */
@Test
public void proposeNewTimeWorkflow() throws Exception {
    TestUtil.createAccount(ORGANIZER);
    TestUtil.createAccount(ATTENDEE1);
    String subject = NAME_PREFIX + " attendee will cause time to change";
    ZMailbox organizerBox = TestUtil.getZMailbox(ORGANIZER);
    ZMailbox attendeeBox = TestUtil.getZMailbox(ATTENDEE1);
    // Create and send the meeting request
    InviteComponent inviteComp = createInviteComponentSkeleton(subject, "room 101", organizerBox, attendeeBox);
    long soon = ((System.currentTimeMillis() / 1000) + 10) * 1000;
    /* to nearest second + 10 */
    Date startDate = new Date(soon + Constants.MILLIS_PER_DAY);
    ZDateTime start = new ZDateTime(startDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    Date endDate = new Date(startDate.getTime() + Constants.MILLIS_PER_HOUR);
    ZDateTime end = new ZDateTime(endDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    Date newStartDate = new Date(soon + 2 * Constants.MILLIS_PER_DAY);
    ZDateTime newStart = new ZDateTime(newStartDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    Date newEndDate = new Date(newStartDate.getTime() + Constants.MILLIS_PER_HOUR);
    ZDateTime newEnd = new ZDateTime(newEndDate.getTime(), false, organizerBox.getPrefs().getTimeZone());
    inviteComp.setDtStart(DtTimeInfo.createForDatetimeAndZone(start.getDateTime(), start.getTimeZoneId()));
    inviteComp.setDtEnd(DtTimeInfo.createForDatetimeAndZone(end.getDateTime(), end.getTimeZoneId()));
    sendMeetingRequest(organizerBox, createMsgForAppointmentRequest(subject, inviteComp, attendeeBox));
    waitForInvite(attendeeBox, subject);
    AppointmentHitInfo hit = findMatchingAppointment(attendeeBox, startDate, endDate, subject);
    // User 1 proposes new time for meeting
    ZMessage propNewTimeMsg = attendeeProposeNewTimeForMeeting(attendeeBox, organizerBox, newStart, newEnd, hit, subject);
    Assert.assertNotNull("ZMessage for propose new time", propNewTimeMsg);
    hit = findMatchingAppointment(organizerBox, startDate, endDate, subject);
    // Organizer changes the meeting to the new proposed time
    // easier to find unique inbox entry
    subject = NAME_PREFIX + " attendee CAUSED time to change";
    ZMessage attendee2ndInvite = organizerChangeTimeForMeeting(attendeeBox, organizerBox, newStart, newEnd, hit, subject);
    Assert.assertNotNull("attendee 2nd invite", attendee2ndInvite);
    hit = findMatchingAppointment(attendeeBox, newStartDate, newEndDate, "inid:10");
    acceptInvite(attendeeBox, organizerBox, attendee2ndInvite, subject);
}
Also used : ZMessage(com.zimbra.client.ZMessage) ZDateTime(com.zimbra.client.ZDateTime) ZMailbox(com.zimbra.client.ZMailbox) AppointmentHitInfo(com.zimbra.soap.mail.type.AppointmentHitInfo) Date(java.util.Date) InviteComponent(com.zimbra.soap.mail.type.InviteComponent) Test(org.junit.Test)

Example 3 with ZDateTime

use of com.zimbra.client.ZDateTime in project zm-mailbox by Zimbra.

the class TestUtil method createAppointment.

public static ZAppointmentResult createAppointment(ZMailbox mailbox, String subject, String attendee, Date startDate, Date endDate) throws ServiceException {
    ZInvite invite = new ZInvite();
    ZInvite.ZComponent comp = new ZComponent();
    comp.setStatus(ZStatus.CONF);
    comp.setClassProp(ZClass.PUB);
    comp.setTransparency(ZTransparency.O);
    comp.setStart(new ZDateTime(startDate.getTime(), false, mailbox.getPrefs().getTimeZone()));
    comp.setEnd(new ZDateTime(endDate.getTime(), false, mailbox.getPrefs().getTimeZone()));
    comp.setName(subject);
    comp.setOrganizer(new ZOrganizer(mailbox.getName()));
    if (attendee != null) {
        attendee = addDomainIfNecessary(attendee);
        ZAttendee zattendee = new ZAttendee();
        zattendee.setAddress(attendee);
        zattendee.setRole(ZRole.REQ);
        zattendee.setParticipantStatus(ZParticipantStatus.NE);
        zattendee.setRSVP(true);
        comp.getAttendees().add(zattendee);
    }
    invite.getComponents().add(comp);
    ZOutgoingMessage m = null;
    if (attendee != null) {
        m = getOutgoingMessage(attendee, subject, "Test appointment", null);
    }
    return mailbox.createAppointment(ZFolder.ID_CALENDAR, null, m, invite, null);
}
Also used : ZComponent(com.zimbra.client.ZInvite.ZComponent) ZDateTime(com.zimbra.client.ZDateTime) ZOutgoingMessage(com.zimbra.client.ZMailbox.ZOutgoingMessage) ZInvite(com.zimbra.client.ZInvite) ZAttendee(com.zimbra.client.ZInvite.ZAttendee) ZOrganizer(com.zimbra.client.ZInvite.ZOrganizer) ZComponent(com.zimbra.client.ZInvite.ZComponent)

Aggregations

ZDateTime (com.zimbra.client.ZDateTime)3 ZInvite (com.zimbra.client.ZInvite)2 ZMailbox (com.zimbra.client.ZMailbox)2 ZMessage (com.zimbra.client.ZMessage)2 AppointmentHitInfo (com.zimbra.soap.mail.type.AppointmentHitInfo)2 InviteComponent (com.zimbra.soap.mail.type.InviteComponent)2 Date (java.util.Date)2 Test (org.junit.Test)2 ZAttendee (com.zimbra.client.ZInvite.ZAttendee)1 ZComponent (com.zimbra.client.ZInvite.ZComponent)1 ZOrganizer (com.zimbra.client.ZInvite.ZOrganizer)1 ZOutgoingMessage (com.zimbra.client.ZMailbox.ZOutgoingMessage)1 CreateAppointmentRequest (com.zimbra.soap.mail.message.CreateAppointmentRequest)1 CreateAppointmentResponse (com.zimbra.soap.mail.message.CreateAppointmentResponse)1 EmailAddrInfo (com.zimbra.soap.mail.type.EmailAddrInfo)1 InvitationInfo (com.zimbra.soap.mail.type.InvitationInfo)1 MimePartInfo (com.zimbra.soap.mail.type.MimePartInfo)1 Msg (com.zimbra.soap.mail.type.Msg)1