/**
   * Tests if the scoring function correctly handles {@link PersonMoneyEvent}. It generates one
   * person with one plan having two activities (home, work) and a car-leg in between. It then tests
   * the scoring function by calling several methods on an instance of the scoring function with the
   * aforementioned plan.
   */
  @Test
  public void testAddMoney() {
    Fixture f = new Fixture();

    // score the same plan twice
    PersonImpl person1 = new PersonImpl(Id.create(1, Person.class));
    PlanImpl plan1 = person1.createAndAddPlan(true);
    Activity act1a =
        plan1.createAndAddActivity("home", (Id<Link>) null); // , 0, 7.0*3600, 7*3600, false);
    act1a.setEndTime(f.secondLegStartTime);
    Leg leg1 = plan1.createAndAddLeg(TransportMode.car); // , 7*3600, 100, 7*3600+100);
    leg1.setDepartureTime(f.secondLegStartTime);
    leg1.setTravelTime(f.secondLegTravelTime);
    Route route2 = new GenericRouteImpl(null, null);
    leg1.setRoute(route2);
    route2.setDistance(20000.0);
    Activity act1b =
        plan1.createAndAddActivity(
            "work",
            (Id<Link>) null); // , 7.0*3600+100, Time.UNDEFINED_TIME, Time.UNDEFINED_TIME, false);
    act1b.setStartTime(f.secondLegStartTime + f.secondLegTravelTime);
    ScoringFunction sf1 = getScoringFunctionInstance(f, person1);
    sf1.handleActivity(act1a);
    sf1.handleLeg(leg1);
    sf1.handleActivity(act1b);

    sf1.finish();
    double score1 = sf1.getScore();

    ScoringFunction sf2 = getScoringFunctionInstance(f, person1);
    sf2.handleActivity(act1a);
    sf2.addMoney(1.23);
    sf2.handleLeg(leg1);
    sf2.addMoney(-2.46);
    sf2.handleActivity(act1b);
    sf2.addMoney(4.86);
    sf2.addMoney(-0.28);
    sf2.finish();
    double score2 = sf2.getScore();

    assertEquals(1.23 - 2.46 + 4.86 - 0.28, score2 - score1, EPSILON);
  }