@Test public void modifyContactSpecifyingTag() throws Exception { final String firstName = "bug67327"; final String surName = "surname"; final String tag1 = "tag67327-a"; final String tag2 = "tag67327-b"; final Byte tag1color = Byte.valueOf((byte) 2); final Byte tag2color = Byte.valueOf((byte) 3); Utility.ensureAccountExists(testAcct); // create a contact testCreateContactRequest req = new testCreateContactRequest(); testContactSpec origSpec = new testContactSpec(); origSpec.setL("7"); // Folder ID - would be nice if wasn't hard coded. testNewContactAttr nam = new testNewContactAttr(); nam.setN("firstName"); nam.setValue(firstName); origSpec.getA().add(nam); req.setCn(origSpec); req.setVerbose(true); Utility.addSoapAcctAuthHeaderForAcct((WSBindingProvider) mailSvcEIF, testAcct); testCreateContactResponse resp = mailSvcEIF.createContactRequest(req); Assert.assertNotNull("CreateContactResponse object", resp); testContactInfo createdContact = resp.getCn(); Assert.assertNotNull("CreateContactResponse/cn object", createdContact); String contactId = createdContact.getId(); Assert.assertNotNull("CreateContactResponse/cn contactId", contactId); Assert.assertEquals("Created FileAs string", firstName, createdContact.getFileAsStr()); Assert.assertEquals("Folder string", "7", createdContact.getL()); Assert.assertTrue("Revision should be positive", createdContact.getRev() > 0); List<testContactAttr> attrs = createdContact.getA(); Assert.assertEquals("Original number of attrs", 1, attrs.size()); testContactAttr firstAttr = attrs.get(0); Assert.assertEquals("Created first attr value", firstName, firstAttr.getValue()); // create a couple of tags to apply to the contact testCreateTagRequest crTagReq = new testCreateTagRequest(); testTagSpec tagSpec = new testTagSpec(); tagSpec.setName(tag1); tagSpec.setColor(tag1color); crTagReq.setTag(tagSpec); testCreateTagResponse crTagResp = mailSvcEIF.createTagRequest(crTagReq); Assert.assertNotNull("CreateTagResponse object 1", crTagResp); testTagInfo tagInfo = crTagResp.getTag(); Assert.assertNotNull("CreateTagResponse object 1 tagInfo", tagInfo); Assert.assertNotNull("CreateTagResponse object 1 tagInfo id", tagInfo.getId()); Assert.assertEquals("CreateTagResponse object 1 tagInfo name", tag1, tagInfo.getName()); Assert.assertEquals("CreateTagResponse object 1 tagInfo color", tag1color, tagInfo.getColor()); tagSpec.setName(tag2); tagSpec.setColor(tag2color); crTagResp = mailSvcEIF.createTagRequest(crTagReq); Assert.assertNotNull("CreateTagResponse object 2", crTagResp); tagInfo = crTagResp.getTag(); Assert.assertNotNull("CreateTagResponse object 2 tagInfo", tagInfo); Assert.assertNotNull("CreateTagResponse object 2 tagInfo id", tagInfo.getId()); Assert.assertEquals("CreateTagResponse object 2 tagInfo name", tag2, tagInfo.getName()); Assert.assertEquals("CreateTagResponse object 2 tagInfo color", tag2color, tagInfo.getColor()); // modify the contact with a real change as well as applying the 2 tags testModifyContactRequest modReq = new testModifyContactRequest(); modReq.setReplace(false); modReq.setVerbose(true); testModifyContactSpec modSpec = new testModifyContactSpec(); modSpec.setId(Integer.valueOf(contactId)); modSpec.setTn(tag1 + "," + tag2); testModifyContactAttr lnam = new testModifyContactAttr(); lnam.setN("lastName"); lnam.setValue(surName); modSpec.getA().add(lnam); modReq.setCn(modSpec); testModifyContactResponse modResp = mailSvcEIF.modifyContactRequest(modReq); testContactInfo modCn = modResp.getCn(); attrs = modCn.getA(); Assert.assertEquals("ModifiedContact 1 number of attrs", 2, attrs.size()); String tags = modCn.getTn(); Assert.assertTrue("ModifiedContact 1 has tag1", tags.indexOf(tag1) >= 0); Assert.assertTrue("ModifiedContact 1 has tag2", tags.indexOf(tag2) >= 0); // Check that we can replace the set of tags with a new set modSpec.setTn(tag2); modResp = mailSvcEIF.modifyContactRequest(modReq); modCn = modResp.getCn(); attrs = modCn.getA(); Assert.assertEquals("ModifiedContact 2 number of attrs", 2, attrs.size()); tags = modCn.getTn(); Assert.assertTrue("ModifiedContact 2 does NOT have tag1", tags.indexOf(tag1) == -1); Assert.assertTrue("ModifiedContact 2 has tag2", tags.indexOf(tag2) >= 0); // Check that not specifying "tn" leaves the taglist alone modSpec.setTn(null); modResp = mailSvcEIF.modifyContactRequest(modReq); modCn = modResp.getCn(); attrs = modCn.getA(); Assert.assertEquals("ModifiedContact 3 number of attrs", 2, attrs.size()); tags = modCn.getTn(); Assert.assertTrue("ModifiedContact 3 has tag2", tags.indexOf(tag2) >= 0); // Check that can delete all tags modSpec.setTn(""); modResp = mailSvcEIF.modifyContactRequest(modReq); modCn = modResp.getCn(); attrs = modCn.getA(); Assert.assertEquals("ModifiedContact 4 number of attrs", 2, attrs.size()); tags = modCn.getTn(); Assert.assertTrue("ModifiedContact 4 tags", tags == null); }
@Test public void createAppointment() throws Exception { Utility.ensureAccountExists(testAcct); Utility.ensureAccountExists(testAcct2); testCreateAppointmentRequest req = new testCreateAppointmentRequest(); testMsg msg = new testMsg(); msg.setL("15"); msg.setSu("WSDL Appointment 1"); testInvitationInfo invite = new testInvitationInfo(); testInviteComponent inviteComp = new testInviteComponent(); inviteComp.setFb("B"); inviteComp.setRsvp(true); inviteComp.setMethod("REQUEST"); inviteComp.setLoc("Mars"); // TODO inviteComp.setType("event"); inviteComp.setName("WSDL Appointment 1"); inviteComp.setAllDay(false); inviteComp.setTransp("O"); testCalendarAttendee attendee = new testCalendarAttendee(); attendee.setRsvp(true); attendee.setA(testAcct2); attendee.setRole("OPT"); attendee.setPtst("NE"); inviteComp.getAt().add(attendee); testDtTimeInfo start = new testDtTimeInfo(); start.setD("20320627T075906"); inviteComp.setS(start); testDtTimeInfo end = new testDtTimeInfo(); end.setD("20320627T085959"); inviteComp.setE(end); testCalOrganizer org = new testCalOrganizer(); org.setA(testAcct); org.setD("wsdl1"); inviteComp.setOr(org); invite.setComp(inviteComp); msg.setInv(invite); testEmailAddrInfo emailAddr = new testEmailAddrInfo(); emailAddr.setT("t"); emailAddr.setA(testAcct2); msg.getE().add(emailAddr); testMimePartInfo mp = new testMimePartInfo(); mp.setCt("multipart/alternative"); testMimePartInfo mpPlain = new testMimePartInfo(); mpPlain.setCt("text/plain"); mpPlain.setContent("Body of the Appointment"); mp.getMp().add(mpPlain); testMimePartInfo mpHtml = new testMimePartInfo(); mpHtml.setCt("text/html"); mpHtml.setContent("<html><body><b>Body</b> of the Appointment</body></html>"); mp.getMp().add(mpHtml); msg.setMp(mp); req.setM(msg); req.setEcho(true); Utility.addSoapAcctAuthHeaderForAcct((WSBindingProvider) mailSvcEIF, testAcct); testCreateAppointmentResponse resp = mailSvcEIF.createAppointmentRequest(req); Assert.assertNotNull("CreateAppointmentResponse object", resp); Assert.assertTrue("revision", resp.getRev() >= 0); Assert.assertTrue("ms", resp.getMs() >= 0); Assert.assertNotNull("CreateAppointmentResponse invId", resp.getInvId()); Assert.assertNotNull("CreateAppointmentResponse calItemId", resp.getCalItemId()); testCalEcho echo = resp.getEcho(); Assert.assertNotNull("CreateAppointmentResponse echo object", echo); }
@Test public void modifyContactGroup() throws Exception { final String fileAs = "bug75912"; final String nickName = "contactGrp"; final String qaTeam = "uid=qa-team,ou=people,dc=example,dc=com"; final String terryp = "\"Terry Pratchett\" <*****@*****.**>"; final String neilg = "\"Neil Gaiman\" <*****@*****.**>"; final String jrrtolkien = "\"JRR Tolkien\" <*****@*****.**>"; Utility.ensureAccountExists(testAcct); testCreateContactRequest req = new testCreateContactRequest(); req.setVerbose(true); testContactSpec origSpec = new testContactSpec(); req.setCn(origSpec); origSpec.setL("7"); // Folder ID - would be nice if wasn't hard coded. testNewContactAttr nam = new testNewContactAttr(); nam.setN("fileAs"); nam.setValue( "8:" + fileAs); // 8: means fileAs is freeform (i.e. not Company, or first/last etc) origSpec.getA().add(nam); nam = new testNewContactAttr(); nam.setN("nickname"); nam.setValue(nickName); origSpec.getA().add(nam); nam = new testNewContactAttr(); nam.setN("type"); nam.setValue("group"); origSpec.getA().add(nam); testNewContactGroupMember member = new testNewContactGroupMember(); member.setType("G"); member.setValue(qaTeam); origSpec.getM().add(member); member = new testNewContactGroupMember(); member.setType("I"); member.setValue(terryp); origSpec.getM().add(member); Utility.addSoapAcctAuthHeaderForAcct((WSBindingProvider) mailSvcEIF, testAcct); testCreateContactResponse resp = mailSvcEIF.createContactRequest(req); Assert.assertNotNull("CreateContactResponse object", resp); testContactInfo createdContact = resp.getCn(); Assert.assertNotNull("CreateContactResponse/cn object", createdContact); String contactId = createdContact.getId(); Assert.assertNotNull("CreateContactResponse/cn contactId", contactId); Assert.assertEquals("Created FileAs string", fileAs, createdContact.getFileAsStr()); Assert.assertEquals("Folder string", "7", createdContact.getL()); Assert.assertTrue("Revision should be positive", createdContact.getRev() > 0); List<testContactAttr> attrs = createdContact.getA(); Assert.assertEquals("Original number of attrs", 3, attrs.size()); Assert.assertEquals("Original number of members", 2, createdContact.getM().size()); // Modify to remove a member testModifyContactRequest modReq = new testModifyContactRequest(); modReq.setReplace(false); modReq.setVerbose(true); testModifyContactSpec modSpec = new testModifyContactSpec(); modSpec.setId(Integer.valueOf(contactId)); modReq.setCn(modSpec); testModifyContactGroupMember modMember = new testModifyContactGroupMember(); modMember.setOp("-"); modMember.setType("I"); modMember.setValue(terryp); modSpec.getM().add(modMember); testModifyContactResponse modResp = mailSvcEIF.modifyContactRequest(modReq); Assert.assertEquals("After 1st mod number of members", 1, modResp.getCn().getM().size()); testContactGroupMember firstMember = modResp.getCn().getM().get(0); firstMember.getValue(); Assert.assertEquals("After 1st mod first member value", qaTeam, firstMember.getValue()); // Modify to replace all members with one new member modReq = new testModifyContactRequest(); modReq.setReplace(false); modReq.setVerbose(true); modSpec = new testModifyContactSpec(); modSpec.setId(Integer.valueOf(contactId)); modReq.setCn(modSpec); modMember = new testModifyContactGroupMember(); modMember.setOp("+"); modMember.setType("I"); modMember.setValue(neilg); modSpec.getM().add(modMember); modResp = mailSvcEIF.modifyContactRequest(modReq); Assert.assertEquals("After 2nd mod number of members", 2, modResp.getCn().getM().size()); // Modify to add a member modReq = new testModifyContactRequest(); modReq.setReplace(false); modReq.setVerbose(true); modSpec = new testModifyContactSpec(); modSpec.setId(Integer.valueOf(contactId)); modReq.setCn(modSpec); modMember = new testModifyContactGroupMember(); modMember.setOp("reset"); modSpec.getM().add(modMember); modMember = new testModifyContactGroupMember(); modMember.setOp("+"); modMember.setType("I"); modMember.setValue(jrrtolkien); modSpec.getM().add(modMember); modResp = mailSvcEIF.modifyContactRequest(modReq); Assert.assertEquals("After 3rd mod number of members", 1, modResp.getCn().getM().size()); firstMember = modResp.getCn().getM().get(0); firstMember.getValue(); Assert.assertEquals("After 3rd mod first member value", jrrtolkien, firstMember.getValue()); }
@Test public void createTask() throws Exception { Utility.ensureAccountExists(testAcct); testCreateTaskRequest req = new testCreateTaskRequest(); testMsg msg = new testMsg(); msg.setL("15"); msg.setSu("WSDL Task 1"); testInvitationInfo invite = new testInvitationInfo(); testInviteComponent inviteComp = new testInviteComponent(); inviteComp.setPercentComplete("0"); inviteComp.setAllDay(true); inviteComp.setStatus("NEED"); inviteComp.setPriority("5"); inviteComp.setName("WSDL Task 1"); inviteComp.setLoc("Mars"); testCalOrganizer org = new testCalOrganizer(); org.setA(testAcct); org.setD("wsdl1"); inviteComp.setOr(org); invite.setComp(inviteComp); msg.setInv(invite); testMimePartInfo mp = new testMimePartInfo(); mp.setCt("multipart/alternative"); testMimePartInfo mpPlain = new testMimePartInfo(); mpPlain.setCt("text/plain"); mpPlain.setContent("Body of the Task"); mp.getMp().add(mpPlain); testMimePartInfo mpHtml = new testMimePartInfo(); mpHtml.setCt("text/html"); mpHtml.setContent("<html><body><b>Body</b> of the Task</body></html>"); mp.getMp().add(mpHtml); msg.setMp(mp); req.setM(msg); req.setEcho(true); Utility.addSoapAcctAuthHeaderForAcct((WSBindingProvider) mailSvcEIF, testAcct); testCreateTaskResponse resp = mailSvcEIF.createTaskRequest(req); Assert.assertNotNull("CreateTaskResponse object", resp); Assert.assertTrue("revision", resp.getRev() >= 0); Assert.assertTrue("ms", resp.getMs() >= 0); Assert.assertNotNull("CreateTaskResponse invId", resp.getInvId()); Assert.assertNotNull("CreateTaskResponse calItemId", resp.getCalItemId()); testCalEcho echo = resp.getEcho(); Assert.assertNotNull("CreateTaskResponse echo object", echo); testInviteAsMP inviteMp = echo.getM(); Assert.assertNotNull("CreateTaskResponse/echo/m object", inviteMp); Assert.assertNotNull("CreateTaskResponse/echo/m @id object", inviteMp.getId()); Assert.assertNotNull("CreateTaskResponse/echo/m @f object", inviteMp.getF()); Assert.assertNotNull("CreateTaskResponse/echo/m @rev object", inviteMp.getRev()); Assert.assertNotNull("CreateTaskResponse/echo/m @d object", inviteMp.getD()); Assert.assertNotNull("CreateTaskResponse/echo/m @t object", inviteMp.getT()); Assert.assertNotNull("CreateTaskResponse/echo/m @s object", inviteMp.getS()); Assert.assertNotNull("CreateTaskResponse/echo/m @md object", inviteMp.getMd()); Assert.assertNotNull("CreateTaskResponse/echo/m @ms object", inviteMp.getMs()); Assert.assertNotNull("CreateTaskResponse/echo/m @l object", inviteMp.getL()); Assert.assertNotNull("CreateTaskResponse/echo/m/meta object", inviteMp.getMeta()); testMpInviteInfo info = inviteMp.getInv(); Assert.assertNotNull("CreateTaskResponse/echo/m/inv object", info); Assert.assertEquals("invite type", "task", info.getType()); List<testInviteComponent> iComps = info.getComp(); Assert.assertNotNull("CreateTaskResponse/echo/m/inv/comp list ", iComps); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp list size", 1, iComps.size()); testInviteComponent iComp = iComps.get(0); Assert.assertNotNull("CreateTaskResponse/echo/m/inv/comp @uid", iComp.getUid()); Assert.assertNotNull( "CreateTaskResponse/echo/m/inv/comp @percentComplete", iComp.getPercentComplete()); Assert.assertNotNull("CreateTaskResponse/echo/m/inv/comp @d", iComp.getD()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @status", "NEED", iComp.getStatus()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @noBlob", true, iComp.isNoBlob()); Assert.assertNotNull("CreateTaskResponse/echo/m/inv/comp @ciFolder", iComp.getCiFolder()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @isOrg", true, iComp.isIsOrg()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @class", "PUB", iComp.getClazz()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @loc", "Mars", iComp.getLoc()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @compNum", 0, iComp.getCompNum()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @url", "", iComp.getUrl()); Assert.assertNotNull("CreateTaskResponse/echo/m/inv/comp @calItemId", iComp.getCalItemId()); Assert.assertNotNull("CreateTaskResponse/echo/m/inv/comp @x_uid", iComp.getX_Uid()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @priority", "5", iComp.getPriority()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @name", "WSDL Task 1", iComp.getName()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @rsvp", false, iComp.isRsvp()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @seq", new Integer(0), iComp.getSeq()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp @method", "PUBLISH", iComp.getMethod()); Assert.assertEquals("CreateTaskResponse/echo/m/inv/comp/fr", "Body of the Task", iComp.getFr()); Assert.assertEquals( "CreateTaskResponse/echo/m/inv/comp/desc", "Body of the Task", iComp.getDesc()); Assert.assertNotNull("CreateTaskResponse/echo/m/inv/comp/descHtml", iComp.getDescHtml()); testCalOrganizer echoO = iComp.getOr(); Assert.assertNotNull("CreateTaskResponse/echo/m/inv/comp/or", echoO); Assert.assertNotNull("CreateTaskResponse/echo/m/inv/comp/or @url", echoO.getUrl()); }