@Test public void testIso8601DateOrSecondsDateParse() { Date dsDate = dateService.iso8601DateOrSecondsDateParse(testData[0].iso8601DateString); assertEquals(dsDate, testData[0].date); Date dsSecondsDate = dateService.iso8601DateOrSecondsDateParse(testData[0].iso8601SecondsDateString); assertEquals(dsSecondsDate, testData[0].date); }
/** * Process the specified HTTP request, and create the corresponding HTTP response (or forward to * another web component that will create it). Return an <code>ActionForward</code> instance * describing where and how control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * @exception Exception if business logic throws an exception */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Extract attributes we will need MessageResources messages = getResources(request); // save errors ActionMessages errors = new ActionMessages(); // START check for login (security) if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) { return (mapping.findForward("welcome")); } // END check for login (security) // PRIVS check that hrAdmin user is viewing this page if (!StandardCode.getInstance() .checkPrivStringArray( (String[]) request.getSession(false).getAttribute("userPrivs"), "hrAdmin")) { return (mapping.findForward("accessDenied")); } // END PRIVS check that hrAdmin user is viewing this page // get the employee to edit from the request String hrAdminUserId = request.getParameter("hrAdminUserId"); User u = UserService.getInstance().getSingleUser(Integer.valueOf(hrAdminUserId)); // get new performance review values DynaValidatorForm ha = (DynaValidatorForm) form; String dueDate = (String) ha.get("dueDate"); String actualDate = (String) ha.get("actualDate"); String signedDate = (String) ha.get("signedDate"); PerformanceReview performanceReviewNew = (PerformanceReview) ha.get("performanceReviewNew"); if (dueDate.length() > 0) // if entered performanceReviewNew.setDueDate(DateService.getInstance().convertDate(dueDate).getTime()); if (actualDate.length() > 0) // if entered performanceReviewNew.setActualDate(DateService.getInstance().convertDate(actualDate).getTime()); if (signedDate.length() > 0) // if entered performanceReviewNew.setSignedDate(DateService.getInstance().convertDate(signedDate).getTime()); // add new performanceReview to the db UserService.getInstance().addPerformanceReview(performanceReviewNew, u); // Forward control to the specified success URI return (mapping.findForward("Success")); }
/** * Delete * * @param model * @return */ public static void delete(UserModel userModel) { // ユーザーのすべてのDateModelを取得 List<DateModel> dateModelList = userModel.getDateModelListRef().getModelList(); for (DateModel dateModel : dateModelList) { // DateModelに紐づくつべてのActivityModel を取得 List<ActivityModel> activityModelList = dateModel.getActivityModelListRef().getModelList(); for (ActivityModel activityModel : activityModelList) { // アクティビティの削除 ActivityService.delete(userModel, activityModel); } // DateModelの削除 DateService.delete(userModel, dateModel); } // URLリストの削除 UserUrlsService.deleteAll(userModel); userModelDao.delete(userModel.getKey()); // 自信のキャッシュをクリア Memcache.delete(userModel.getKey().toString()); // ユーザーカウントのキャッシュクリア clearUserCountAndListMemcache(); // グループのキャッシュをクリア clearGroupUserListMemcache(userModel.getGroup()); }
@Test void testParseIso8601DateSerialResponseTime() { for (int i = 0; i < LOOP_COUNT; i++) dateService.iso8601DateParse(testData[0].iso8601DateString); }
@Test void testCDateFormatResponseTime() { for (int i = 0; i < LOOP_COUNT; i++) dateService.cDateFormat(); }
@Test void testTzNoT() { assertEquals( dateService.iso8601DateParse("2011-05-25 16:12:21.656+0000").getTime(), 1306339941656l); }
@Test void testTz() { assertEquals( dateService.iso8601SecondsDateParse("2011-05-26T02:14:13-04:00").getTime(), 1306390453000l); }
@Test void testUTCIsGMT() { assertEquals( dateService.iso8601SecondsDateParse("2012-11-26T17:32:31UTC+0000").getTime(), dateService.iso8601SecondsDateParse("2012-11-26T17:32:31UTC+0000").getTime()); }
@Test public void testRfc822DateFormat() { String dsString = dateService.rfc822DateFormat(testData[0].date); assertEquals(dsString, testData[0].rfc822DateString); }
@Test public void testIso8601SecondsDateFormat() { String dsString = dateService.iso8601SecondsDateFormat(testData[0].date); assertEquals(dsString, testData[0].iso8601SecondsDateString); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testRfc822DateParseIllegal() { dateService.rfc822DateParse("foo"); }
@Test public void testRfc822DateParse() { Date dsDate = dateService.rfc822DateParse(testData[0].rfc822DateString); assertEquals(dsDate, testData[0].date); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testIso8601SecondsDateParseIllegal() { dateService.iso8601SecondsDateParse("-1"); }