EffectivityConfigSpec extends ProductConfigSpec { @Override public PartIteration filterPartIteration(PartMaster partMaster) { List<PartRevision> revisions = partMaster.getPartRevisions(); PartRevision pr=null; for(int i=revisions.size()-1;i>=0;i--){ pr=revisions.get(i); if(isEffective(pr)) { break; } else { pr = null; } } if(pr != null){ PartIteration lastIteration = pr.getLastIteration(); retainedPartIterations.add(pr.getLastIteration()); return lastIteration; } return null; } EffectivityConfigSpec(ConfigurationItem configurationItem);  EffectivityConfigSpec(ProductConfiguration configuration); ConfigurationItem getConfigurationItem(); @Override PartIteration filterPartIteration(PartMaster partMaster); @Override PartLink filterPartLink(List<PartLink> path);  }
@Test public void filterPartIterationTest(){ when(pM1_pR1.getEffectivities()).thenReturn(Collections.EMPTY_SET); when(pM1_pR2.getEffectivities()).thenReturn(Collections.EMPTY_SET); when(pM1_pR3.getEffectivities()).thenReturn(Collections.EMPTY_SET); PartIteration result = effectivityConfigSpec.filterPartIteration(pM1); Assert.assertNull(result); when(pM1_pR1.getEffectivities()).thenReturn(Collections.singleton(pM1_eF1)); when(pM1_pR1.getLastIteration()).thenReturn(pM1_pI1); doReturn(true).when(effectivityConfigSpec).isEffective(pM1_eF1); result = effectivityConfigSpec.filterPartIteration(pM1); Assert.assertNotNull(result); Assert.assertEquals(pM1_pI1,result); when(pM1_pR3.getEffectivities()).thenReturn(Collections.singleton(pM1_eF3)); when(pM1_pR3.getLastIteration()).thenReturn(pM1_pI2); doReturn(true).when(effectivityConfigSpec).isEffective(pM1_eF3); result = effectivityConfigSpec.filterPartIteration(pM1); Assert.assertNotNull(result); Assert.assertEquals(pM1_pI2,result); HashSet<PartIteration> retained = (HashSet) Whitebox.getInternalState(effectivityConfigSpec, "retainedPartIterations"); Assert.assertTrue(retained.size() == 2); verify(effectivityConfigSpec,times(2)).isEffective(pM1_pR1); verify(effectivityConfigSpec,times(2)).isEffective(pM1_pR2); verify(effectivityConfigSpec,times(3)).isEffective(pM1_pR3); }