### Question:
AllSummariesDefinedModel extends UnmodifiableHolder<Boolean> implements PropertyChangeListener { @Override public Boolean getValue() { return evaluate(d_summaries); } AllSummariesDefinedModel(List<? extends Summary> summaries); void propertyChange(PropertyChangeEvent evt); @Override Boolean getValue();  }### Answer:
@Test public void testEvaluateSingleSummary() { MySummary trueSummary = new MySummary(true); AllSummariesDefinedModel trueModel = new AllSummariesDefinedModel(Collections.singletonList(trueSummary)); assertTrue(trueModel.getValue()); MySummary falseSummary = new MySummary(false); AllSummariesDefinedModel falseModel = new AllSummariesDefinedModel(Collections.singletonList(falseSummary)); assertFalse(falseModel.getValue()); }
@Test public void testEvaluateMultipleSummaries() { MySummary summary1 = new MySummary(true); MySummary summary2 = new MySummary(false); List<Summary> summaries = Arrays.asList(new Summary[] { summary1, summary2 }); AllSummariesDefinedModel allValuesModel = new AllSummariesDefinedModel(summaries); assertEquals(false, allValuesModel.getValue()); summary2.setDefined(true); allValuesModel = new AllSummariesDefinedModel(summaries); assertEquals(true, allValuesModel.getValue()); }
@Test public void testListenMultipleSummaries() { MySummary summary1 = new MySummary(true); MySummary summary2 = new MySummary(false); List<Summary> summaries = Arrays.asList(new Summary[] { summary1, summary2 }); AllSummariesDefinedModel allValuesModel = new AllSummariesDefinedModel(summaries); assertEquals(false, allValuesModel.getValue()); summary2.setDefined(true); assertEquals(true, allValuesModel.getValue()); }
@Test public void testFiresChanges() { MySummary summary1 = new MySummary(true); MySummary summary2 = new MySummary(false); List<Summary> summaries = Arrays.asList(new Summary[] { summary1, summary2 }); AllSummariesDefinedModel allValuesModel = new AllSummariesDefinedModel(summaries); assertEquals(false, allValuesModel.getValue()); PropertyChangeListener mock = JUnitUtil.mockListener(allValuesModel, "value", false, true); allValuesModel.addPropertyChangeListener(mock); summary2.setDefined(true); assertEquals(true, allValuesModel.getValue()); verify(mock); }
@Test public void testFiresChangesTrueToFalse() { MySummary summary1 = new MySummary(true); MySummary summary2 = new MySummary(true); List<Summary> summaries = Arrays.asList(new Summary[] { summary1, summary2 }); AllSummariesDefinedModel allValuesModel = new AllSummariesDefinedModel(summaries); assertEquals(true, allValuesModel.getValue()); PropertyChangeListener mock = JUnitUtil.mockListener(allValuesModel, "value", true, false); allValuesModel.addPropertyChangeListener(mock); summary2.setDefined(false); assertEquals(false, allValuesModel.getValue()); verify(mock); }
@Test public void testOnlyFireWhenShould() { MySummary summary1 = new MySummary(false); MySummary summary2 = new MySummary(false); List<Summary> summaries = Arrays.asList(new Summary[] { summary1, summary2 }); AllSummariesDefinedModel allValuesModel = new AllSummariesDefinedModel(summaries); assertEquals(false, allValuesModel.getValue()); PropertyChangeListener m = createStrictMock(PropertyChangeListener.class); replay(m); allValuesModel.addPropertyChangeListener(m); summary2.setDefined(true); assertEquals(false, allValuesModel.getValue()); verify(m); }