ReflectionSourcePropertyFactory implements SourcePropertyFactory { @Override public SourceProperty getSourceProperty( String expression ) { if ( isIdentifier( expression ) ) { return new ReflectionSourceProperty( expression ); } else { return null; } } ReflectionSourcePropertyFactory(); @Override SourceProperty getSourceProperty( String expression ); @Override SourceProperty getSourceProperty( String expressionPrefix, String unprefixedExpression ); @Override boolean supportsPrefix( String prefix );  }
@Test public void testGetSourcePropertyThrowsUnsupportedOperationExceptionWhenPrefixEmployed() { try { factory.getSourceProperty( "foo", "foo" ); } catch( UnsupportedOperationException exception ) { assertThat( exception.getMessage(), containsString( "doesn't support prefixes." ) ); } }
@Test public void testGetSourcePropertyWithKeywordReturnsNull() { assertNull( factory.getSourceProperty( "abstract" ) ); }
@Test public void testGetSourcePropertyWithLiteralReturnsNull() { assertNull( factory.getSourceProperty( "true" ) ); }
@Test public void testGetSourcePropertyWithStringNotMatchingJavaIdentifierReturnsNull() { assertNull( factory.getSourceProperty( "23skidoo" ) ); }
@Test public void testGetSourcePropertyWithStringMatchingJavaIdentifierReturnsSourceProperty() { SourceProperty prop = factory.getSourceProperty( "blackjack21" ); assertNotNull( prop ); assertEquals( "blackjack21", prop.getExpression() ); }