Class AbstractValidatorTest<V extends Validator,T>
- java.lang.Object
-
- de.cuioss.test.jsf.junit5.JsfEnabledTestEnvironment
-
- de.cuioss.test.jsf.validator.AbstractValidatorTest<V,T>
-
- Type Parameters:
V- identifying the concreteValidatorto be tested.T- identifying the type of elements to be passed into the validator
- All Implemented Interfaces:
JsfEnvironmentConsumer,de.cuioss.test.valueobjects.objects.ConfigurationCallBackHandler<V>
public abstract class AbstractValidatorTest<V extends Validator,T> extends JsfEnabledTestEnvironment implements de.cuioss.test.valueobjects.objects.ConfigurationCallBackHandler<V>
Base Class for testing implementations ofValidatorwithin a Junit 5 contextSetup
It uses
EnableJsfEnvironment, for the basic test-infrastructure.See the class-documentation for details.initValidator(): Instantiates the concreteValidatorusing reflection. After this the method callsConfigurationCallBackHandler.configure(Object)that can be used for further configuration of theValidatorIn case you want you want to create the
Validatoryourself you can overwritegetValidator()In case you want a pass another
UIComponentas parameter to theValidatoryou can overwritegetComponent()Test-Methods
The core test-methods are
shouldFailOnInvalidTestdata()andshouldHandleValidTestdata(). They callpopulate(TestItems)in oder to create corresponding test-data. The implementation is in the actual test-class.API-Test
The api as defined within
Validatoris tested with the methodsshouldFailOnNullComponent(),shouldFailOnNullFacesContext()andshouldHandleNullValue()Example
@EnableJsfEnvironment class LengthValidatorTest extends AbstractValidatorTest<LengthValidator, String> { @Override public void populate(final TestItems<String> testItems) { testItems.addValid("1").addValid("abc").addInvalidWithMessage("123456", LengthValidator.MAXIMUM_MESSAGE_ID); } @Override public void configure(final LengthValidator validator) { validator.setMaximum(5); } }- Author:
- Oliver Wolff
-
-
Constructor Summary
Constructors Constructor Description AbstractValidatorTest()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description UIComponentgetComponent()VgetValidator()abstract voidpopulate(TestItems<T> testItems)Populates the test-items-
Methods inherited from class de.cuioss.test.jsf.junit5.JsfEnabledTestEnvironment
getEnvironmentHolder, setEnvironmentHolder
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.cuioss.test.valueobjects.objects.ConfigurationCallBackHandler
configure
-
Methods inherited from interface de.cuioss.test.jsf.util.JsfEnvironmentConsumer
assertNavigatedWithOutcome, assertRedirect, getApplication, getApplicationConfigDecorator, getBeanConfigDecorator, getComponentConfigDecorator, getExternalContext, getFacesContext, getRequestConfigDecorator, getResponse
-
-
-
-
Constructor Detail
-
AbstractValidatorTest
public AbstractValidatorTest()
-
-
Method Detail
-
populate
public abstract void populate(TestItems<T> testItems)
Populates the test-items- Parameters:
testItems- to be populated, is never null
-
getComponent
public UIComponent getComponent()
-
getValidator
public V getValidator()
-
-