コード例 #1
0
 private void saveBannerForSomePriority(int priority, int bannerDayViewLimit) throws Exception {
   DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   Banner prioriryBanner = new Banner();
   String bannerName = STRING_FOR_BANNER_NAME + priority;
   String bannerUid =
       Long.toString(new Date().getTime()) + Double.toString(Math.random()).split("\\.")[1];
   Date startDate = dfm.parse("2010-09-30 00:00:00");
   Date endDate = dfm.parse("2010-11-30 00:00:00");
   int bannerTrafficShare = 30;
   int adFormatId = 5;
   int bannerContentTypeId = 1;
   String countryBits = "";
   for (int i = 0; i < 239; i++) {
     countryBits += "1";
   }
   String hourBits = "";
   for (int i = 0; i < 24; i++) {
     hourBits += "1";
   }
   String weekBits = "";
   for (int i = 0; i < 7; i++) {
     weekBits += "1";
   }
   String browserBits = "";
   for (int i = 0; i < 8; i++) {
     browserBits += "1";
   }
   String osBits = "";
   for (int i = 0; i < 16; i++) {
     osBits += "1";
   }
   String languageBits = "";
   for (int i = 0; i < 16; i++) {
     languageBits += "1";
   }
   prioriryBanner.setDailyViewsLimit(bannerDayViewLimit);
   prioriryBanner.setAdFormatId(adFormatId);
   prioriryBanner.setStartDate(startDate);
   prioriryBanner.setEndDate(endDate);
   prioriryBanner.setPriority(priority);
   prioriryBanner.setBannerName(bannerName);
   prioriryBanner.setUid(bannerUid);
   prioriryBanner.setAdPlaceUid(adPlaceUID);
   prioriryBanner.setCountryBits(countryBits);
   prioriryBanner.setHourBits(hourBits);
   prioriryBanner.setDayBits(weekBits);
   prioriryBanner.setBrowserBits(browserBits);
   prioriryBanner.setOsBits(osBits);
   prioriryBanner.setLanguageBits(languageBits);
   prioriryBanner.setTrafficShare(bannerTrafficShare);
   prioriryBanner.setBannerContentTypeId(bannerContentTypeId);
   List<Banner> l = new ArrayList<Banner>();
   l.add(prioriryBanner);
   bannerDAO.saveOrUpdateBanners(l);
 }
コード例 #2
0
 private boolean getBannerForSomePriority(int priority, List<Integer> banners) throws Exception {
   DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   RequestParametersForm form = new RequestParametersForm();
   form.setAdPlaceUid(adPlaceUID);
   form.setIp(1L);
   form.setCurrentBrowser(ApplicationConstants.BROWSER_FIREFOX);
   form.setOs(ApplicationConstants.OS_WINDOWS_XP);
   form.setLanguage("ru-ru;ru;en-us;en;");
   ServerRequest serverRequest = new ServerRequest();
   serverRequest.installationId = 1;
   form.setServerRequest(serverRequest);
   adCodeProcessor.processRequest(form, dfm.parse("2010-10-30 23:59:59"));
   NextBannerProcResult nbpr = form.getNextBannerProcResult();
   assertNotNull(nbpr.getBannerUid());
   Banner b = bannerDAO.getBannerByUid(nbpr.getBannerUid());
   return (b.getPriority() == priority);
 }