final TestElement element = TestElement.TYPE.instantiate();
try
{
final DefinitionLoader.Reference<DialogDef> definition = DefinitionLoader.sdef( PartValidationFunctionTests.class ).dialog();
final SapphirePart part = new DialogPart();
try
{
part.init( null, element, definition.resolve(), Collections.<String,String>emptyMap() );
part.initialize();
final FunctionResult fr = ExpressionLanguageParser.parse( "${ Part.Validation }" ).evaluate( new PartFunctionContext( part, element ) );
try
{
assertInstanceOf( fr.value(), Status.class );
assertEquals( Status.Severity.ERROR, ( (Status) fr.value() ).severity() );
element.setValue( "abc" );
assertInstanceOf( fr.value(), Status.class );
assertEquals( Status.Severity.OK, ( (Status) fr.value() ).severity() );
}
finally
{
fr.dispose();
}
}
finally
{
part.dispose();
}
}
finally
{
element.dispose();