@Test public void testCreateCalendarAppointment() throws Exception { OutlookCalendarItem appointmentItem = new OutlookCalendarItem(); appointmentItem.setBody("Body"); appointmentItem.setSubject("Subject"); appointmentItem.setAllDayEvent(false); long tomorrow = System.currentTimeMillis() + 1000 * 60 * 60 * 24; appointmentItem.setStartDate(new Date(tomorrow)); appointmentItem.setEndDate(new Date(tomorrow + 1000 * 60 * 60)); appointmentItem.setMeeting(false); appointmentItem.setRecurring(true); appointmentItem.setRecurringInterval(1); appointmentItem.setRecurringEndDate(new Date(tomorrow + 1000 * 60 * 60 * 48)); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String content = objectMapper.writeValueAsString(appointmentItem); 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<OutlookCalendarItem> apointmentItemCapture = new Capture<>(); appointmentItem.setId("some_fake_id"); expect(outlookService.createOutlookAppointment(capture(outlookUserCapture), capture(apointmentItemCapture))) .andReturn(appointmentItem); replayAll(); MvcResult result = mockMvc .perform(post("/api/latest/plugin/outlook/calendar").session(session).accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON).principal(mockAuthentication).content(content)) .andExpect(status().isOk()).andReturn(); OutlookCalendarItem item = objectMapper.readValue(result.getResponse().getContentAsString(), OutlookCalendarItem.class); assertNotNull(item.getId()); }
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public OutlookCalendarItem createCalendarAppointment(@RequestBody OutlookCalendarItem 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.createOutlookAppointment(outlookUser, in); return in; }
CreateCalendarAppointmentAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public OutlookCalendarItem createCalendarAppointment(@RequestBody OutlookCalendarItem 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.createOutlookAppointment(outlookUser, in); return in; } }
CreateCalendarAppointmentAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public OutlookCalendarItem createCalendarAppointment(@RequestBody OutlookCalendarItem 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.createOutlookAppointment(outlookUser, in); return in; }  }
CreateCalendarAppointmentAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public OutlookCalendarItem createCalendarAppointment(@RequestBody OutlookCalendarItem 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.createOutlookAppointment(outlookUser, in); return in; }  @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody OutlookCalendarItem createCalendarAppointment(@RequestBody OutlookCalendarItem in, Authentication authentication,
            HttpSession session); UserOrgService getUserOrgService(); void setUserOrgService(UserOrgService userOrgService); OutlookService getOutlookService(); void setOutlookService(OutlookService outlookService); }
CreateCalendarAppointmentAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public OutlookCalendarItem createCalendarAppointment(@RequestBody OutlookCalendarItem 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.createOutlookAppointment(outlookUser, in); return in; }  @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody OutlookCalendarItem createCalendarAppointment(@RequestBody OutlookCalendarItem in, Authentication authentication,
            HttpSession session); UserOrgService getUserOrgService(); void setUserOrgService(UserOrgService userOrgService); OutlookService getOutlookService(); void setOutlookService(OutlookService outlookService);  }