예제 #1
0
  @Test
  public void testNumberOfSelectedJointPlans() throws Exception {
    final JointPlans jointPlans = new JointPlans();
    final GroupPlanStrategy strategy =
        new GroupPlanStrategy(
            new HighestScoreSumSelector(new EmptyIncompatiblePlansIdentifierFactory()));
    strategy.addStrategyModule(new JointStructureInvertingModule(jointPlans.getFactory()));

    final ReplanningGroup group = createTestGroup(jointPlans);
    strategy.run(createContext(), jointPlans, Arrays.asList(group));

    int countSelectedJoint = 0;
    int countSelectedIndiv = 0;
    for (Person person : group.getPersons()) {
      for (Plan plan : person.getPlans()) {
        if (plan.isSelected() && jointPlans.getJointPlan(plan) != null) {
          countSelectedJoint++;
        }
        if (plan.isSelected() && jointPlans.getJointPlan(plan) == null) {
          countSelectedIndiv++;
        }
      }
    }

    assertEquals(
        "wrong number of selected plans in joint plans",
        N_INITIALLY_INDIV_PLANS,
        countSelectedJoint);
    assertEquals(
        "wrong number of selected plans in individual plans",
        N_INITIALLY_JOINT_PLANS,
        countSelectedIndiv);
  }
예제 #2
0
  @Test
  public void testNewPlanIsSelected() throws Exception {
    final JointPlans jointPlans = new JointPlans();
    final GroupPlanStrategy strategy =
        new GroupPlanStrategy(
            new HighestScoreSumSelector(new EmptyIncompatiblePlansIdentifierFactory()));
    strategy.addStrategyModule(new JointStructureInvertingModule(jointPlans.getFactory()));

    final List<Plan> selectedPlans = new ArrayList<Plan>();
    final ReplanningGroup group = createTestGroup(jointPlans);
    for (Person p : group.getPersons()) {
      selectedPlans.add(p.getSelectedPlan());
    }

    strategy.run(createContext(), jointPlans, Arrays.asList(group));
    for (Person person : group.getPersons()) {
      for (Plan plan : person.getPlans()) {
        if (plan.isSelected()) {
          // new plan: selection status inverted
          assertFalse("old plan still selected", selectedPlans.contains(plan));
        } else {
          assertTrue("old plan still selected", selectedPlans.contains(plan));
        }
      }
    }
  }
예제 #3
0
  @Test
  public void testNumberOfPlans() throws Exception {
    final JointPlans jointPlans = new JointPlans();
    final GroupPlanStrategy strategy =
        new GroupPlanStrategy(
            new HighestScoreSumSelector(new EmptyIncompatiblePlansIdentifierFactory()));
    strategy.addStrategyModule(new JointStructureInvertingModule(jointPlans.getFactory()));

    final ReplanningGroup group = createTestGroup(jointPlans);
    final int groupSize = group.getPersons().size();
    strategy.run(createContext(), jointPlans, Arrays.asList(group));

    assertEquals("group size changed by strategy!", groupSize, group.getPersons().size());
  }