### Question:
BaseExtensionUtils { @SuppressWarnings( "unchecked" ) protected static void setStringValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable String 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<String>) typeFactory.apply( "string" ) ).setValue( value ) ); } } private  BaseExtensionUtils();   }### Answer:
@Test public void resetStringValue() { TestPlanDefinition planDefinition = new TestPlanDefinition(); BaseExtensionUtils.setStringValue( "testUrl", planDefinition, "testValue", TypeFactory::createType ); BaseExtensionUtils.setStringValue( "testUrl", planDefinition, null, TypeFactory::createType ); Assert.assertTrue( planDefinition.getExtension().isEmpty() ); }
@Test public void setStringValue() { TestPlanDefinition planDefinition = new TestPlanDefinition(); BaseExtensionUtils.setStringValue( "testUrl", planDefinition, "testValue", TypeFactory::createType ); Assert.assertEquals( 1, planDefinition.getExtension().size() ); Assert.assertEquals( "testUrl", planDefinition.getExtension().get( 0 ).getUrl() ); Assert.assertEquals( "testValue", planDefinition.getExtension().get( 0 ).getValue().toString() ); }