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);
}
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);
}
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);
}
Aggregations