DateBasedEffectivityConfigSpec extends EffectivityConfigSpec { @Override protected boolean isEffective(Effectivity eff){ if(eff instanceof DateBasedEffectivity){ DateBasedEffectivity dateEff=(DateBasedEffectivity) eff; return isEffective(dateEff); }else return false; } DateBasedEffectivityConfigSpec(Date date, ConfigurationItem configurationItem);  DateBasedEffectivityConfigSpec(Date date, ProductConfiguration configuration); Date getDate(); void setDate(Date date);  }
@Test public void isEffectiveTest() throws ParseException { Assert.assertNotNull(dateBasedEffectivityConfigSpec_withConfigurationItem.getConfigurationItem()); Assert.assertNotNull(dateBasedEffectivityConfigSpec_withProductConfiguration.getConfigurationItem()); when(tmp_DBE.getConfigurationItem()).thenReturn(configurationItem_tmp); boolean result = dateBasedEffectivityConfigSpec_withConfigurationItem.isEffective(tmp_DBE); Assert.assertFalse(result); when(tmp_DBE.getConfigurationItem()).thenReturn(configurationItem); when(tmp_DBE.getStartDate()).thenReturn(after); result = dateBasedEffectivityConfigSpec_withConfigurationItem.isEffective(tmp_DBE); Assert.assertFalse(result); when(tmp_DBE.getStartDate()).thenReturn(date); when(tmp_DBE.getEndDate()).thenReturn(before); result = dateBasedEffectivityConfigSpec_withConfigurationItem.isEffective(tmp_DBE); Assert.assertFalse(result); when(tmp_DBE.getStartDate()).thenReturn(before); when(tmp_DBE.getEndDate()).thenReturn(after); result = dateBasedEffectivityConfigSpec_withConfigurationItem.isEffective(tmp_DBE); Assert.assertTrue(result); result = dateBasedEffectivityConfigSpec_withConfigurationItem.isEffective(new LotBasedEffectivity()); Assert.assertFalse(result); dateBasedEffectivityConfigSpec_withConfigurationItem.setDate(dateFormat.parse("11/04/2001")); Assert.assertEquals(dateFormat.parse("11/04/2001"),dateBasedEffectivityConfigSpec_withConfigurationItem.getDate()); }