Ejemplo n.º 1
0
  @Test
  public void testCalculateMorning() {
    Calendar cal = Calendar.getInstance();
    cal.set(2016, 4, 1);
    int startDoy = cal.get(Calendar.DAY_OF_YEAR);
    cal.set(2016, 4, 31);
    int endDoy = cal.get(Calendar.DAY_OF_YEAR);

    Avail avail = new Avail();
    for (int i = startDoy; i <= endDoy; i++) {
      avail.setAvailOn(i, AvailType.MORNING);
    }

    AvailCalculator calc = new AvailCalculator(avail, gamedays);
    TotalAvailDto totalAvails = calc.calculateTotalAvails(startDoy, endDoy);

    Assert.assertEquals(425.0, totalAvails.getTotal(), 0.01);
    Assert.assertEquals(8.5, totalAvails.getDays(), 0.01);
  }
Ejemplo n.º 2
0
  @Test
  public void testCalculateMH() {
    Calendar cal = Calendar.getInstance();
    cal.set(2016, 4, 1);
    int startDoy = cal.get(Calendar.DAY_OF_YEAR);
    cal.set(2016, 4, 31);
    int endDoy = cal.get(Calendar.DAY_OF_YEAR);

    Avail avail = new Avail();
    avail.setAvailOn(startDoy, AvailType.NO);
    avail.setAvailOn(startDoy + 3, AvailType.EVENING);
    avail.setAvailOn(startDoy + 4, AvailType.YES);
    avail.setAvailOn(startDoy + 6, AvailType.EFAF);
    avail.setAvailOn(startDoy + 7, AvailType.NO);
    avail.setAvailOn(startDoy + 13, AvailType.NO);
    avail.setAvailOn(startDoy + 14, AvailType.GFL);
    avail.setAvailOn(startDoy + 15, AvailType.EMERGENCY_ONLY);
    avail.setAvailOn(startDoy + 20, AvailType.YES);
    avail.setAvailOn(startDoy + 21, AvailType.YES);
    avail.setAvailOn(startDoy + 25, AvailType.EMERGENCY_ONLY);
    avail.setAvailOn(startDoy + 27, AvailType.NO);
    avail.setAvailOn(startDoy + 28, AvailType.NO);

    AvailCalculator calc = new AvailCalculator(avail, gamedays);
    TotalAvailDto totalAvails = calc.calculateTotalAvails(startDoy, endDoy);

    Assert.assertEquals(450.0, totalAvails.getTotal(), 0.01);
    Assert.assertEquals(8.5, totalAvails.getDays(), 0.01);
    Assert.assertEquals(53.0, Math.ceil(totalAvails.getTotal() / totalAvails.getDays()), 0.01);
    Assert.assertEquals(53, totalAvails.getPercent());
  }