Exemplo n.º 1
0
  /**
   * Test of getTVChanges method, of class TmdbTV.
   *
   * @throws com.omertron.themoviedbapi.MovieDbException
   */
  @Test
  public void testGetTVChanges() throws MovieDbException {
    LOG.info("getTVChanges");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String startDate = sdf.format(DateUtils.addDays(new Date(), -14));
    String endDate = "";
    int maxCheck = 5;

    TmdbChanges chgs = new TmdbChanges(getApiKey(), getHttpTools());
    ResultList<ChangeListItem> changeList = chgs.getChangeList(MethodBase.TV, null, null, null);
    LOG.info(
        "Found {} changes to check, will check maximum of {}",
        changeList.getResults().size(),
        maxCheck);

    int count = 1;
    ResultList<ChangeKeyItem> result;
    for (ChangeListItem item : changeList.getResults()) {
      result = instance.getTVChanges(item.getId(), startDate, endDate);
      for (ChangeKeyItem ci : result.getResults()) {
        assertNotNull("Null changes", ci);
      }

      if (count++ > maxCheck) {
        break;
      }
    }
  }
 @JsonProperty(value = "passwordExpirationDate")
 @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyyMMddHHmmss")
 public Date getPasswordExpirationDate() {
   if (!accountStatus.isPending()
       && (getPasswordLastModifiedDate() != null)
       && (getPasswordExpirationInterval() != null)) {
     return DateUtils.addDays(
         DateUtils.truncate(getPasswordLastModifiedDate(), Calendar.DATE),
         getPasswordExpirationInterval());
   }
   return null;
 }
Exemplo n.º 3
0
 /**
  * @author Chivalry 批量价格修改
  * @param request
  * @return 2015-12-02
  */
 @PolicyJournal(accessLevel = AccessLevel.PRIVATE)
 @RequestMapping("/to_hotelRoomPrices_edit")
 public ModelAndView to_hotelRoomPrices_edit(HttpServletRequest request) {
   String hotelRoomId = request.getParameter("hotelRoomId");
   String hotelNameId = request.getParameter("hotelNameId");
   ModelAndView mav = new ModelAndView("/hotelroom/to_hotelRoomPrices_edit");
   String time = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
   String next = new SimpleDateFormat("yyyy-MM-dd").format(DateUtils.addDays(new Date(), 7));
   mav.addObject("hotelRoomId", hotelRoomId);
   mav.addObject("hotelNameId", hotelNameId);
   mav.addObject("time", time);
   mav.addObject("next", next);
   return mav;
 }
  @Test(expectedExceptions = UnknownTokenException.class)
  public void findUserByTokenExpired() {
    MolgenisToken molgenisToken = new MolgenisToken();
    molgenisToken.setToken("token");
    molgenisToken.setExpirationDate(DateUtils.addDays(new Date(), -1));

    when(dataService.findOne(
            MolgenisToken.ENTITY_NAME,
            new QueryImpl().eq(MolgenisToken.TOKEN, "token"),
            MolgenisToken.class))
        .thenReturn(molgenisToken);

    tokenService.findUserByToken("token");
  }
Exemplo n.º 5
0
 private void handlePubSub(final Feed feed) {
   if (feed.getPushHub() != null && feed.getPushTopic() != null) {
     Date lastPing = feed.getPushLastPing();
     Date now = new Date();
     if (lastPing == null || lastPing.before(DateUtils.addDays(now, -3))) {
       new Thread() {
         @Override
         public void run() {
           handler.subscribe(feed);
         }
       }.start();
     }
   }
 }
Exemplo n.º 6
0
  private void updateReports(String calendarId) throws IOException {
    Date to = new Date();
    Date from = DateUtils.addDays(to, -10);
    DateTime fromDateTime = new DateTime(from);
    DateTime toDateTime = new DateTime(to);

    List<WorkReport> reports = achievoConnector.getHours(from, to);
    Events events =
        googleCalendarService
            .events()
            .list(calendarId)
            .setTimeMin(fromDateTime)
            .setTimeMax(toDateTime)
            .execute();

    new ReportMerger(googleCalendarService, calendarId).merge(reports, events);
  }
  /**
   * @verifies fail validation if dateActivated is before encounter's encounterDatetime
   * @see OrderValidator#validate(Object, org.springframework.validation.Errors)
   */
  @Test
  public void validate_shouldFailValidationIfDateActivatedIsBeforeEncountersEncounterDatetime()
      throws Exception {
    Date encounterDate = new Date();
    Date orderDate = DateUtils.addDays(encounterDate, -1);
    Encounter encounter = Context.getEncounterService().getEncounter(3);
    encounter.setEncounterDatetime(encounterDate);
    Order order = new Order();
    order.setDateActivated(orderDate);
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setEncounter(encounter);
    order.setOrderer(Context.getProviderService().getProvider(1));
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);

    Assert.assertTrue(errors.hasFieldErrors("dateActivated"));
  }
Exemplo n.º 8
0
 private Date calculateDate(Date beginDate, String timeType, Integer amount) {
   Date limitDate = null;
   timeType = timeType == null ? "" : timeType;
   amount = amount == null ? 0 : amount;
   switch (timeType) {
     case "M":
       limitDate = DateUtils.addMinutes(beginDate, amount);
       break;
     case "H":
       limitDate = DateUtils.addHours(beginDate, amount);
       break;
     case "D":
       limitDate = DateUtils.addDays(beginDate, amount);
       break;
     default:
       //			limitDate = beginDate;
       break;
   }
   return limitDate;
 }
Exemplo n.º 9
0
 @Override
 @Transactional(readOnly = true)
 @CheckCache(namespace = CACHE_NAMESPACE, key = "${username}", cacheNull = true)
 public UserDetails loadUserByUsername(String username) {
   if (StringUtils.isBlank(username)) return null;
   // throw new UsernameNotFoundException("username is blank");
   username = username.toLowerCase();
   User user;
   if (username.indexOf('@') > 0) user = findOne("email", username);
   else user = findByNaturalId(username);
   if (user == null) {
     // throw new UsernameNotFoundException("No such Username : "+
     // username);
     return null; // for @CheckCache
   }
   if (passwordExpiresInDays > 0) {
     Date passwordModifyDate = user.getPasswordModifyDate();
     if (passwordModifyDate != null
         && DateUtils.addDays(passwordModifyDate, passwordExpiresInDays).before(new Date()))
       user.setPasswordExpired(true);
   }
   populateAuthorities(user);
   return user;
 }
Exemplo n.º 10
0
 /**
  * 计算指定日期的后一天
  *
  * @param date
  * @return
  */
 public static Date getNextDay(Date date) {
   return org.apache.commons.lang3.time.DateUtils.addDays(date, 1);
 }
  private String getFormatDate(String infmt, String date, String outfmt) throws ParseException {
    if (date == null || date.length() <= 0) {
      return "";
    }
    if (date.length() == 1) {
      Date today = Calendar.getInstance().getTime();
      return DateFormatUtils.format(today, outfmt);
    } else {
      int plus = date.indexOf('+');
      int minus = date.indexOf('-');
      if (plus > 0 || minus > 0) {
        Date today = Calendar.getInstance().getTime();
        String type = date.substring(0, 1);
        String sign = date.substring(1, 2);
        int amount = 0;
        try {
          amount = Integer.parseInt(date.substring(2));
        } catch (NumberFormatException e) {
          LOG.error("Exception", e);
          return null;
        }
        if (("+").equals(sign)) {
          if (("D").equals(type)) {
            return DateFormatUtils.format(DateUtils.addDays(today, amount), outfmt);
          } else if (("M").equals(type)) {
            return DateFormatUtils.format(DateUtils.addMonths(today, amount), outfmt);
          } else if (("Y").equals(type)) {
            return DateFormatUtils.format(DateUtils.addYears(today, amount), outfmt);
          }
        } else if (("-").equals(sign)) {
          if (("D").equals(type)) {
            return DateFormatUtils.format(DateUtils.addDays(today, -amount), outfmt);
          } else if (("M").equals(type)) {
            return DateFormatUtils.format(DateUtils.addMonths(today, -amount), outfmt);
          } else if (("Y").equals(type)) {
            return DateFormatUtils.format(DateUtils.addYears(today, -amount), outfmt);
          }
        } else {
          return null;
        }
      }
    }

    // date 형식이  infmt 에 맞지 않다면 date 를 infmt 에 맞추어줌.
    StringBuilder sDate = new StringBuilder(date);
    int len = date.length();

    if (("yyyyMMddHHmm").equals(infmt) && len < 12) {
      for (int i = len; i < 12; i++) {
        sDate.append("0");
      }
    } else if (("yyyyMMddHHmmss").equals(infmt) && len < 14) {
      for (int i = len; i < 14; i++) {
        sDate.append("0");
      }
    }

    SimpleDateFormat sdf = new SimpleDateFormat(infmt);
    Date d = sdf.parse(sDate.toString());
    sdf.applyPattern(outfmt);

    return sdf.format(d);
  }
Exemplo n.º 12
0
  @Test
  public void testAll() {
    LoginResultVO loginResult = userApi.login(TEST_ACCOUNT_EMAIL, TEST_ACCOUNT_PASSWORD);
    UserVO seeker = loginResult.getUserVo();

    RegisterVO register = new RegisterVO();
    register.setUsername(TEST_OFFERER_ACCOUNT);
    register.setPassword(TEST_OFFERER_PASSWORD);
    LoginResultVO offererLoginResult = userApi.register(register);
    UserVO offerer = offererLoginResult.getUserVo();
    Assert.assertNotNull(offerer.getId());

    userApi.login(TEST_ACCOUNT_EMAIL, TEST_ACCOUNT_PASSWORD);
    SeekVO seek = new SeekVO();
    seek.setSeekerId(seeker.getId());
    seek.setCategoryL1("IT");
    seek.setCategoryL2("软件");
    seek.setContent("求开发一款类似陌陌的手机App");
    List<ImageVO> images = new ArrayList<ImageVO>();
    images.add(new ImageVO(null, null, "small_url", "original_url"));
    images.add(new ImageVO(null, null, "small_url2", "original_url2"));
    seek.setImages(images);
    seek.setRequirement("要求支持短视频分享");
    seek.setReward("一个月内完成,两万;一个半月内完成,一万五。");

    seek = seekApi.publish(seek);
    Assert.assertNotNull(seek.getId());

    userApi.login(TEST_OFFERER_ACCOUNT, TEST_OFFERER_PASSWORD);
    OfferVO offer = new OfferVO();
    offer.setOffererId(offerer.getId());
    offer.setSeekId(seek.getId());
    offer.setContent("我做过,半个月能出产品。");
    offer.setDescription("我做过");
    offer.setDeadline(DateUtils.addDays(new Date(), 15));
    offer = offerApi.offer(offer);
    Assert.assertNotNull(offer.getId());

    offer = offerApi.getById(offer.getId());
    Assert.assertEquals(seek.getId(), offer.getSeekId());

    userApi.login(TEST_ACCOUNT_EMAIL, TEST_ACCOUNT_PASSWORD);
    DelegationVO delegation = new DelegationVO();
    delegation.setSeekId(seek.getId());
    delegation.setSeekerId(seek.getSeekerId());
    delegation.setOfferId(offer.getId());
    delegation.setOffererId(offer.getOffererId());
    delegation.setDeadline(offer.getDeadline());
    delegation = delegationApi.delegate(delegation);
    Assert.assertNotNull(delegation.getId());
    Assert.assertEquals(Constants.DELEGATE_STATUS_DELEGATED, delegation.getStatus());

    delegationApi.finish(delegation.getId());

    EvaluationVO evaluation = new EvaluationVO();
    evaluation.setDelegationId(delegation.getId());
    evaluation.setType(Constants.EVALUATION_TYPE_SEEKER_TO_OFFERER);
    evaluation.setEvaluatorId(seeker.getId());
    evaluation.setEvaluateTargetId(offerer.getId());
    evaluation.setPoint(10);
    images = new ArrayList<ImageVO>();
    images.add(new ImageVO(null, null, "small_url", "original_url"));
    images.add(new ImageVO(null, null, "small_url2", "original_url2"));
    evaluation.setImages(images);
    evaluation = evaluationApi.evaluate(evaluation);
    Assert.assertNotNull(evaluation.getId());
    delegation = delegationApi.getById(delegation.getId());
    Assert.assertEquals(Constants.DELEGATE_STATUS_SEEKER_EVALUATED, delegation.getStatus());

    userApi.login(TEST_OFFERER_ACCOUNT, TEST_OFFERER_PASSWORD);
    evaluation = new EvaluationVO();
    evaluation.setDelegationId(delegation.getId());
    evaluation.setType(Constants.EVALUATION_TYPE_OFFERER_TO_SEEKER);
    evaluation.setEvaluatorId(offerer.getId());
    evaluation.setEvaluateTargetId(seeker.getId());
    evaluation.setPoint(10);
    evaluation = evaluationApi.evaluate(evaluation);
    Assert.assertNotNull(evaluation.getId());
    delegation = delegationApi.getById(delegation.getId());
    Assert.assertEquals(Constants.DELEGATE_STATUS_BI_EVALUATED, delegation.getStatus());

    List<EvaluationVO> evaluations = evaluationApi.listByEvaluatorId(seeker.getId(), 0, 20);
    Assert.assertEquals(1, evaluations.size());

    evaluations = evaluationApi.listByEvaluateTargetId(seeker.getId(), 0, 20);
    Assert.assertEquals(1, evaluations.size());

    evaluations = evaluationApi.listByDelegationId(delegation.getId());
    Assert.assertEquals(2, evaluations.size());
  }
Exemplo n.º 13
0
 public static Date endOfDay(Date d) {
   return DateUtils.addSeconds(DateUtils.addDays(DateUtils.truncate(d, Calendar.DATE), 1), -1);
 }
Exemplo n.º 14
0
 /**
  * Sets a temporary password which is set to expire on the current date.
  *
  * @param password plain text password value.
  */
 public void setTemporaryPassword(final String password) {
   this.temporaryPassword = hashPassword(password);
   this.temporaryPasswordExpiration = DateUtils.addDays(new Date(), 1);
 }