@Test
public void testMixPeriodicAndNonPeriodic() throws PlanningException {

  int[] alloc = { 2, 5, 0 };
  long[] timeSteps = { 1L, 2L, 3L };
  RLESparseResourceAllocation tempPeriodic = ReservationSystemTestUtil
      .generateRLESparseResourceAllocation(alloc, timeSteps);
  PeriodicRLESparseResourceAllocation periodic =
      new PeriodicRLESparseResourceAllocation(tempPeriodic, 10L);
  int[] alloc2 = { 10, 10, 0 };
  long[] timeSteps2 = { 12L, 13L, 14L };
  RLESparseResourceAllocation nonPeriodic = ReservationSystemTestUtil
      .generateRLESparseResourceAllocation(alloc2, timeSteps2);
  RLESparseResourceAllocation merged =
      RLESparseResourceAllocation.merge(nonPeriodic.getResourceCalculator(),
          Resource.newInstance(100 * 1024, 100), periodic, nonPeriodic,
          RLESparseResourceAllocation.RLEOperator.add, 2, 25);
  Assert.assertEquals(Resource.newInstance(5, 5),
      merged.getCapacityAtTime(2L));
  Assert.assertEquals(Resource.newInstance(0, 0),
      merged.getCapacityAtTime(3L));
  Assert.assertEquals(Resource.newInstance(2, 2),
      merged.getCapacityAtTime(11L));
  Assert.assertEquals(Resource.newInstance(15, 15),
      merged.getCapacityAtTime(12L));
  Assert.assertEquals(Resource.newInstance(10, 10),
      merged.getCapacityAtTime(13L));
  Assert.assertEquals(Resource.newInstance(0, 0),
      merged.getCapacityAtTime(14L));
  Assert.assertEquals(Resource.newInstance(2, 2),
      merged.getCapacityAtTime(21L));
  Assert.assertEquals(Resource.newInstance(5, 5),
      merged.getCapacityAtTime(22L));
  Assert.assertEquals(Resource.newInstance(0, 0),
      merged.getCapacityAtTime(23L));
}