use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestJaxb method testBrowseRequestAttachments.
@Test
public void testBrowseRequestAttachments() throws Exception {
TestUtil.createAccount(USER_NAME);
ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
MessageBuilder mb = new MessageBuilder();
String raw = mb.withSubject(NAME_PREFIX).withBody(bodyWithObject).withContentType(MimeConstants.CT_APPLICATION_PDF).create();
TestUtil.addRawMessage(zmbox, raw);
forceIndexing(USER_NAME);
BrowseRequest browseRequest = new BrowseRequest("attachments", /* browseBy */
"", /* regex */
10);
BrowseResponse browseResponse = doBrowseRequest(browseRequest);
Assert.assertNotNull("JAXB BrowseResponse object", browseResponse);
List<BrowseData> datas = browseResponse.getBrowseDatas();
Assert.assertNotNull("JAXB BrowseResponse datas", datas);
Assert.assertTrue("JAXB BrowseResponse datas", datas.size() >= 1);
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestJaxb method testGetFolderWithCacheContainingNullParent.
@Test
public void testGetFolderWithCacheContainingNullParent() throws Exception {
TestUtil.createAccount(USER_NAME);
ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
ZFolder f1 = TestUtil.createFolder(zmbox, FOLDER_F1);
ZFolder f2 = TestUtil.createFolder(zmbox, SUB_FOLDER_F2);
Mailbox mbox = TestUtil.getMailbox(USER_NAME);
OperationContext octxt = new OperationContext(mbox);
ItemId f1ItemId = new ItemId(mbox, Integer.parseInt(f1.getId()));
ItemId f2ItemId = new ItemId(mbox, Integer.parseInt(f2.getId()));
// ItemId rootItemId = new ItemId(mbox, Mailbox.ID_FOLDER_USER_ROOT);
// mbox.getFolderTree(octxt, rootItemId, false);
Folder f1folder = mbox.getFolderById(octxt, f1ItemId.getId());
Folder f2folder = mbox.getFolderById(octxt, f2ItemId.getId());
// Bug 100588 f1folder/f2folder will have been retrieved from the folder cache. Deliberately poison it
// by setting the parent folder to null, and ensure that can still successfully do a GetFolderRequest
f1folder.setParent(null);
f2folder.setParent(null);
GetFolderResponse gfResp = zmbox.invokeJaxb(new GetFolderRequest());
Assert.assertNotNull("GetFolderResponse null", gfResp);
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestJaxb method acceptAndTentativeSeriesDeclineInstanceAcceptInstance.
/**
* Bug 94018. Accepting series, then declining single instance leads to inconsistent display of attendee
* status for organizer copy for the declined instance.
*
* Pseudo exceptions should be created for each reply to an individual instance of the series.
*
* At the end of this, check that exceptions have been created. Check that the exceptions register
* the correct statuses for the users.
*/
@Test
public void acceptAndTentativeSeriesDeclineInstanceAcceptInstance() throws Exception {
TestUtil.createAccount(ORGANIZER);
TestUtil.createAccount(ATTENDEE1);
TestUtil.createAccount(ATTENDEE2);
String subject = NAME_PREFIX + " every 2 days";
ZMailbox organizerZMbox = TestUtil.getZMailbox(ORGANIZER);
ZMailbox attendee1ZMbox = TestUtil.getZMailbox(ATTENDEE1);
ZMailbox attendee2ZMbox = TestUtil.getZMailbox(ATTENDEE2);
String londonTZ = "Europe/London";
int year = Calendar.getInstance().get(Calendar.YEAR) + 1;
// Create and send meeting that occurs every 2 days
InviteComponent inviteComp = createInviteComponentSkeleton(subject, "room 101", organizerZMbox, attendee1ZMbox, attendee2ZMbox);
GregorianCalendar start = startTime(londonTZ, year, 1, /* February */
2, /* day */
14, /* hour */
0);
GregorianCalendar end = plus(start, Calendar.MINUTE, 30);
setStartAndEnd(inviteComp, londonTZ, start, end);
inviteComp.setRecurrence(recurrence("DAI", 2, /* every 2 days */
String.format("%d0529", year)));
sendMeetingRequest(organizerZMbox, createMsgForAppointmentRequest(subject, inviteComp, attendee1ZMbox, attendee2ZMbox));
// attendee 1 wait for original invite
ZMessage seriesMsg = waitForInvite(attendee1ZMbox, subject);
// attendee 1 accepts the original invite to the whole series
sendInviteReplyAndWaitForIt(attendee1ZMbox, organizerZMbox, seriesMsg.getId(), subject, "ACCEPT", null);
// attendee 1 declines one instance of the daily meeting - 2 + 4 --> 6th Feb
GregorianCalendar exceptionTime = plus(start, Calendar.DAY_OF_MONTH, 4);
sendInviteReplyAndWaitForIt(attendee1ZMbox, organizerZMbox, seriesMsg.getId(), subject, "DECLINE", DtTimeInfo.createForDatetimeAndZone(dateTime(exceptionTime), londonTZ));
// attendee 2 wait for original invite
seriesMsg = waitForInvite(attendee2ZMbox, subject);
// attendee 2 tentatively accepts the original invite to the whole series
sendInviteReplyAndWaitForIt(attendee2ZMbox, organizerZMbox, seriesMsg.getId(), subject, "TENTATIVE", null);
// attendee 2 declines one instance of the daily meeting 2 + 8 --> 10th Feb
GregorianCalendar exceptionTime2 = plus(start, Calendar.DAY_OF_MONTH, 8);
sendInviteReplyAndWaitForIt(attendee2ZMbox, organizerZMbox, seriesMsg.getId(), subject + " " + ATTENDEE2, "DECLINE", DtTimeInfo.createForDatetimeAndZone(dateTime(exceptionTime2), londonTZ));
// Search for a range of instances of the organizer's calendar entry
SearchRequest sReq = new SearchRequest();
sReq.setSearchTypes(ZSearchParams.TYPE_APPOINTMENT);
/* 2nd Feb + 1 --> 3rd, 2nd Feb + 13 --> 15th. So should match instances on:
* 4th, 6th, 8th, 10th, 12th, 14th. */
List<AppointmentHitInfo> apptHits = findMatchingExpandedAppointments(organizerZMbox, plus(start, Calendar.DAY_OF_MONTH, 1).getTime(), plus(start, Calendar.DAY_OF_MONTH, 13).getTime(), String.format("in:Calendar and subject:%s", subject), 1);
AppointmentHitInfo orgApptHit = apptHits.get(0);
Assert.assertNotNull("Organizer Calendar at end - series invite id", orgApptHit.getInvId());
List<InstanceDataInfo> instances = orgApptHit.getInstances();
Assert.assertNotNull("Organizer Calendar at end - instances in expansion", instances);
Assert.assertEquals("Organizer Calendar at end - number of instances in expansion", 6, instances.size());
// The 2nd entry in the list should be for an exception
Map<ZMailbox, String> partstatMap = new HashMap<>(2);
partstatMap.put(attendee1ZMbox, ZAppointmentHit.PSTATUS_DECLINED);
/* for this instance */
partstatMap.put(attendee2ZMbox, ZAppointmentHit.PSTATUS_TENTATIVE);
/* for the series */
validateException(organizerZMbox, instances.get(1), partstatMap, exceptionTime);
// The 4th entry in the list should also be for an exception
partstatMap.put(attendee1ZMbox, ZAppointmentHit.PSTATUS_ACCEPT);
/* for the series */
partstatMap.put(attendee2ZMbox, ZAppointmentHit.PSTATUS_DECLINED);
/* for the instance */
validateException(organizerZMbox, instances.get(3), partstatMap, exceptionTime2);
// Do a GetMsg for the series in the Organizer's calendar
MsgSpec gmsMsgSpec = new MsgSpec(orgApptHit.getInvId());
GetMsgRequest gmsReq = new GetMsgRequest(gmsMsgSpec);
GetMsgResponse gmsResp = organizerZMbox.invokeJaxb(gmsReq);
List<InviteComponentWithGroupInfo> sInviteComps = gmsResp.getMsg().getInvite().getInviteComponents();
Assert.assertEquals("number of components in series", 1, sInviteComps.size());
List<CalendarAttendeeWithGroupInfo> sAttendees = sInviteComps.get(0).getAttendees();
Assert.assertEquals("number of attendees in exception", 2, sAttendees.size());
for (CalendarAttendeeWithGroupInfo sAttendee : sAttendees) {
String addr = sAttendee.getAddress();
String ptst = sAttendee.getPartStat();
if (addr.equals(attendee1ZMbox.getName())) {
Assert.assertEquals("exception attendee1 partstat", ZAppointmentHit.PSTATUS_ACCEPT, ptst);
} else if (addr.equals(attendee2ZMbox.getName())) {
Assert.assertEquals("exception attendee2 partstat", ZAppointmentHit.PSTATUS_TENTATIVE, ptst);
} else {
Assert.fail(String.format("Unexpected attendee in exception [%s]", addr));
}
}
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestJaxb method doBadBrowseRequest.
public Element doBadBrowseRequest(BrowseRequest browseRequest) throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String authToken = mbox.getAuthToken().getValue();
DocumentResult dr = new DocumentResult();
marshaller.marshal(browseRequest, dr);
Document doc = dr.getDocument();
ZimbraLog.test.debug(doc.getRootElement().asXML());
return sendReqExpectingFail(envelope(authToken, doc.getRootElement().asXML()), "BrowseRequest", 500);
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestJaxb method validateException.
private void validateException(ZMailbox zmbox, InstanceDataInfo instance, Map<ZMailbox, String> partstats, GregorianCalendar recurIdTime) throws ServiceException {
String exceptionInviteId = instance.getInvId();
Assert.assertNotNull("exception invite id", exceptionInviteId);
String exceptionRidZ = instance.getRecurIdZ();
Assert.assertNotNull("exception invite RecurIdZ", exceptionRidZ);
Assert.assertEquals("RecurIdZ", ParsedDateTime.fromUTCTime(recurIdTime.getTimeInMillis()).getDateTimePartString(false), exceptionRidZ);
// Do a GetMsg for the exception in the Organizer's calendar
MsgSpec gmeMsgSpec = new MsgSpec(exceptionInviteId);
gmeMsgSpec.setRecurIdZ(exceptionRidZ);
GetMsgRequest gmeReq = new GetMsgRequest(gmeMsgSpec);
GetMsgResponse gmeResp = zmbox.invokeJaxb(gmeReq);
List<InviteComponentWithGroupInfo> eInviteComps = gmeResp.getMsg().getInvite().getInviteComponents();
Assert.assertEquals("number of components in exception", 1, eInviteComps.size());
List<CalendarAttendeeWithGroupInfo> eAttendees = eInviteComps.get(0).getAttendees();
Assert.assertEquals("number of attendees in exception", 2, eAttendees.size());
for (CalendarAttendeeWithGroupInfo eAttendee : eAttendees) {
String addr = eAttendee.getAddress();
String ptst = eAttendee.getPartStat();
boolean found = false;
for (Entry<ZMailbox, String> entry : partstats.entrySet()) {
if (addr.equals(entry.getKey().getName())) {
Assert.assertEquals(String.format("Exception partstat for %s", entry.getKey()), entry.getValue(), ptst);
found = true;
}
}
Assert.assertTrue(String.format("Unexpected attendee in exception [%s]", addr), found);
}
}
Aggregations