コード例 #1
0
ファイル: BlogController.java プロジェクト: Canos/sagan
  @RequestMapping(
      value = "/{year:\\d+}/{month:\\d+}",
      method = {GET, HEAD})
  public String listPublishedPostsForYearAndMonth(
      @PathVariable int year,
      @PathVariable int month,
      @RequestParam(defaultValue = "1", value = "page") int page,
      Model model) {

    Pageable pageRequest = PageableFactory.forLists(page);
    Page<Post> result = service.getPublishedPostsByDate(year, month, pageRequest);
    YearMonth yearMonth = new YearMonth(year, month);
    model.addAttribute("title", "Archive for " + yearMonth.toString("MMMM yyyy"));
    return renderListOfPosts(result, model, "All Posts");
  }
  @Test
  @Ignore("Only for testing uploading a real raport, don't do it every run")
  public void insertReporting() throws Exception {
    YearMonth period = new YearMonth(2006, 3);
    Institute institute =
        new InstituteFactory().setShortName("RUG").setName("Rijks Universiteit Groningen").create();
    PhysicalResourceGroup group =
        new PhysicalResourceGroupFactory().setInstitute(institute).create();
    ReservationReportView adminReport =
        new ReservationReportView(period.toInterval().getStart(), period.toInterval().getEnd());
    adminReport.setAmountRunningReservationsFailed(1);
    adminReport.setAmountRequestsCreatedSucceeded(5);
    adminReport.setAmountRunningReservationsStillRunning(4);

    ReservationReportView nocReport =
        new ReservationReportView(period.toInterval().getStart(), period.toInterval().getEnd());
    nocReport.setAmountRunningReservationsFailed(2);
    nocReport.setAmountRequestsCreatedSucceeded(10);
    nocReport.setAmountRunningReservationsStillRunning(8);

    when(physicalResourceGroupServiceMock.findAllWithPorts()).thenReturn(Lists.newArrayList(group));
    when(reportingServiceMock.determineReportForAdmin(eq(period.toInterval()), any(BodRole.class)))
        .thenReturn(adminReport);
    when(reportingServiceMock.determineReportForNoc(period.toInterval())).thenReturn(nocReport);

    subject.sendReports(period);
  }