### Question:
BaseExtensionUtils { @SuppressWarnings( "unchecked" ) protected static void setDateValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable Date value, @Nonnull Function<String, IElement> typeFactory ) { resource.getExtension().removeIf( e -> url.equals( e.getUrl() ) ); if ( value != null ) { final IBaseExtension<?, ?> extension = resource.addExtension(); extension.setUrl( url ); extension.setValue( ( (IPrimitiveType<Date>) typeFactory.apply( "date" ) ).setValue( value ) ); } } private  BaseExtensionUtils();   }### Answer:
@Test public void resetDateValue() { TestPlanDefinition planDefinition = new TestPlanDefinition(); BaseExtensionUtils.setDateValue( "testUrl", planDefinition, new Date(), TypeFactory::createType ); BaseExtensionUtils.setDateValue( "testUrl", planDefinition, null, TypeFactory::createType ); Assert.assertTrue( planDefinition.getExtension().isEmpty() ); }
@Test public void setDateValue() { TestPlanDefinition planDefinition = new TestPlanDefinition(); final Date date = new Date(); BaseExtensionUtils.setDateValue( "testUrl", planDefinition, new Date(), TypeFactory::createType ); Assert.assertEquals( 1, planDefinition.getExtension().size() ); Assert.assertEquals( "testUrl", planDefinition.getExtension().get( 0 ).getUrl() ); Assert.assertEquals( date, ( (DateDt) planDefinition.getExtension().get( 0 ).getValue() ).getValue() ); }