/**
   * Test deletion with n obligations (no time-based trigger) The Obligation Handler should call n
   * times deleteObject on ObligationTriggerDaom with the correct ObligationTrigger instances should
   * have no interaction with the Time Based Trigger Handler
   */
  @Test
  public void testDeleteObligationsWithObligations() {
    List<ObligationTrigger> otList = new ArrayList<ObligationTrigger>();
    ObligationTrigger ot0 = new ObligationTrigger();
    ot0.setId(0);
    ot0.setPiiId((long) 0);
    ot0.setAction(new Action());
    otList.add(ot0);

    ObligationTrigger ot1 = new ObligationTrigger();
    ot1.setId(1);
    ot1.setPiiId((long) 0);
    ot1.setAction(new Action());
    otList.add(ot1);

    ObligationTrigger ot2 = new ObligationTrigger();
    ot2.setId(2);
    ot2.setPiiId((long) 0);
    ot2.setAction(new Action());
    otList.add(ot2);

    when(otDao.findByPiiId((long) 0)).thenReturn(otList);

    obligationHandler.removeObligations(pii);

    verify(otDao).findByPiiId((long) 0);
    verify(otDao).deleteObject(ot0);
    verify(otDao).deleteObject(ot1);
    verify(otDao).deleteObject(ot2);
    verifyZeroInteractions(timeBasedTriggerHandler);
  }
  /**
   * Test deletion with n obligations and m containing time-based triggers The Obligation Handler
   * should call n times deleteObject on ObligationTriggerDao with the correct ObligationTrigger
   * instances should call m times unHandle on the Time Based Trigger Handler with the correct
   * ObligationTrigger instances
   */
  @Test
  public void testDeleteObligationsWithTimeBasedObligations() {
    // ----- Test n obligations (with k time based triggers) -----
    List<ObligationTrigger> otList = new ArrayList<ObligationTrigger>();

    ObligationTrigger ot0 = new ObligationTrigger();
    ot0.setId(0);
    ot0.setPiiId((long) 0);
    ot0.setAction(new Action());
    otList.add(ot0);

    ObligationTrigger ot1 = new ObligationTrigger();
    ot1.setId(1);
    ot1.setPiiId((long) 0);
    ot1.setAction(new Action());
    otList.add(ot1);

    ObligationTrigger ot2 = new ObligationTrigger();
    ot2.setId(2);
    ot2.setPiiId((long) 0);
    ot2.setAction(new Action());
    otList.add(ot2);

    ObligationTrigger ot3 = new ObligationTrigger();
    ot3.setId(3);
    ot3.setPiiId((long) 0);
    ot3.setAction(new Action());
    ot3.setTriggerName("{http://www.primelife.eu/ppl/obligation}TriggerAtTime");
    Trigger triggerAtTime = new TriggerAtTime();
    ot3.setTrigger(triggerAtTime);
    otList.add(ot3);

    ObligationTrigger ot4 = new ObligationTrigger();
    ot4.setId(3);
    ot4.setPiiId((long) 0);
    ot4.setAction(new Action());
    ot4.setTriggerName("{http://www.primelife.eu/ppl/obligation}TriggerPeriodic");
    Trigger triggerPeriodic = new TriggerPeriodic();
    ot4.setTrigger(triggerPeriodic);
    otList.add(ot4);

    when(otDao.findByPiiId((long) 0)).thenReturn(otList);

    obligationHandler.removeObligations(pii);
    verify(otDao).findByPiiId((long) 0);
    verify(otDao).deleteObject(ot0);
    verify(otDao).deleteObject(ot1);
    verify(otDao).deleteObject(ot2);
    verify(otDao).deleteObject(ot3);
    verify(otDao).deleteObject(ot4);
    verify(timeBasedTriggerHandler).unhandle(triggerAtTime, (long) 0);
    verify(timeBasedTriggerHandler).unhandle(triggerPeriodic, (long) 0);
  }