@Test public void testCreateContactItem() throws Exception { OutlookContactItem contactItem = new OutlookContactItem(); contactItem.setDisplayName("John Doe"); contactItem.setBody("Body"); contactItem.setSubject("Subject"); contactItem.setCompanyName("Armedia"); contactItem.setEmailAddress1("john.doe@armedia.com"); contactItem.setPrimaryTelephone("+55555656456"); contactItem.setSurname("Doe"); contactItem.setCompleteName("John Doe"); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String content = objectMapper.writeValueAsString(contactItem); expect(mockAuthentication.getName()).andReturn("user").times(2); OutlookDTO password = new OutlookDTO(); password.setOutlookPassword("outlookPassword"); expect(outlookService.retrieveOutlookPassword(mockAuthentication)).andReturn(password); AcmUser user = new AcmUser(); user.setMail("test@armedia.com"); session.setAttribute("acm_user", user); Capture<AcmOutlookUser> outlookUserCapture = new Capture<>(); Capture<OutlookContactItem> contactItemCapture = new Capture<>(); contactItem.setId("some_fake_id"); expect(outlookService.createOutlookContactItem(capture(outlookUserCapture), eq(WellKnownFolderName.Contacts), capture(contactItemCapture))).andReturn(contactItem); replayAll(); MvcResult result = mockMvc .perform(post("/api/latest/plugin/outlook/contacts").session(session).accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON).principal(mockAuthentication).content(content)) .andExpect(status().isOk()).andReturn(); OutlookContactItem item = objectMapper.readValue(result.getResponse().getContentAsString(), OutlookContactItem.class); assertNotNull(item.getId()); }
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public OutlookContactItem createContactItem(@RequestBody OutlookContactItem in, Authentication authentication, HttpSession session) throws AcmEncryptionException { AcmUser user = (AcmUser) session.getAttribute("acm_user"); OutlookDTO outlookDTO = getOutlookService().retrieveOutlookPassword(authentication); AcmOutlookUser outlookUser = new AcmOutlookUser(authentication.getName(), user.getMail(), outlookDTO.getOutlookPassword()); in = outlookService.createOutlookContactItem(outlookUser, WellKnownFolderName.Contacts, in); return in; }
CreateContactItemAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public OutlookContactItem createContactItem(@RequestBody OutlookContactItem in, Authentication authentication, HttpSession session) throws AcmEncryptionException { AcmUser user = (AcmUser) session.getAttribute("acm_user"); OutlookDTO outlookDTO = getOutlookService().retrieveOutlookPassword(authentication); AcmOutlookUser outlookUser = new AcmOutlookUser(authentication.getName(), user.getMail(), outlookDTO.getOutlookPassword()); in = outlookService.createOutlookContactItem(outlookUser, WellKnownFolderName.Contacts, in); return in; } }
CreateContactItemAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public OutlookContactItem createContactItem(@RequestBody OutlookContactItem in, Authentication authentication, HttpSession session) throws AcmEncryptionException { AcmUser user = (AcmUser) session.getAttribute("acm_user"); OutlookDTO outlookDTO = getOutlookService().retrieveOutlookPassword(authentication); AcmOutlookUser outlookUser = new AcmOutlookUser(authentication.getName(), user.getMail(), outlookDTO.getOutlookPassword()); in = outlookService.createOutlookContactItem(outlookUser, WellKnownFolderName.Contacts, in); return in; }  }
CreateContactItemAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public OutlookContactItem createContactItem(@RequestBody OutlookContactItem in, Authentication authentication, HttpSession session) throws AcmEncryptionException { AcmUser user = (AcmUser) session.getAttribute("acm_user"); OutlookDTO outlookDTO = getOutlookService().retrieveOutlookPassword(authentication); AcmOutlookUser outlookUser = new AcmOutlookUser(authentication.getName(), user.getMail(), outlookDTO.getOutlookPassword()); in = outlookService.createOutlookContactItem(outlookUser, WellKnownFolderName.Contacts, in); return in; }  @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody OutlookContactItem createContactItem(@RequestBody OutlookContactItem in, Authentication authentication, HttpSession session); UserOrgService getUserOrgService(); void setUserOrgService(UserOrgService userOrgService); OutlookService getOutlookService(); void setOutlookService(OutlookService outlookService); }
CreateContactItemAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public OutlookContactItem createContactItem(@RequestBody OutlookContactItem in, Authentication authentication, HttpSession session) throws AcmEncryptionException { AcmUser user = (AcmUser) session.getAttribute("acm_user"); OutlookDTO outlookDTO = getOutlookService().retrieveOutlookPassword(authentication); AcmOutlookUser outlookUser = new AcmOutlookUser(authentication.getName(), user.getMail(), outlookDTO.getOutlookPassword()); in = outlookService.createOutlookContactItem(outlookUser, WellKnownFolderName.Contacts, in); return in; }  @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody OutlookContactItem createContactItem(@RequestBody OutlookContactItem in, Authentication authentication, HttpSession session); UserOrgService getUserOrgService(); void setUserOrgService(UserOrgService userOrgService); OutlookService getOutlookService(); void setOutlookService(OutlookService outlookService);  }