### Question:
DefaultVariableManager implements VariableManager { @Override public String parseAndGetValue( final Context context, final String link ) throws IllegalArgumentException, NoSuchVariableException { if( !link.startsWith( "{$" ) ) { throw new IllegalArgumentException( "Link does not start with {$" ); } if( !link.endsWith( "}" ) ) { throw new IllegalArgumentException( "Link does not end with }" ); } final String varName = link.substring( 2, link.length() - 1 ); return getValue( context, varName.trim() ); } DefaultVariableManager( final Properties props ); @Override String parseAndGetValue( final Context context, final String link ); @Override // FIXME: somewhat slow. String expandVariables( final Context context, final String source ); @Override String getValue( final Context context, final String varName, final String defValue ); @Override String getVariable( final Context context, final String name ); @Override String getValue( final Context context, final String varName );  }### Answer:
@Test public void testIllegalInsert1() { Assertions.assertThrows( IllegalArgumentException.class, () -> m_variableManager.parseAndGetValue( m_context, "" ) ); }
@Test public void testIllegalInsert2() { Assertions.assertThrows( IllegalArgumentException.class, () -> m_variableManager.parseAndGetValue( m_context, "{$" ) ); }
@Test public void testIllegalInsert3() { Assertions.assertThrows( IllegalArgumentException.class, () -> m_variableManager.parseAndGetValue( m_context, "{$pagename" ) ); }
@Test public void testIllegalInsert4() { Assertions.assertThrows( IllegalArgumentException.class, () -> m_variableManager.parseAndGetValue( m_context, "{$}" ) ); }
@Test public void testNonExistantVariable() { Assertions.assertThrows( NoSuchVariableException.class, () -> m_variableManager.parseAndGetValue( m_context, "{$no_such_variable}" ) ); }
@Test public void testPageName2() throws Exception { final String res = m_variableManager.parseAndGetValue( m_context, "{$ pagename }" ); Assertions.assertEquals( PAGE_NAME, res ); }
@Test public void testMixedCase() throws Exception { final String res = m_variableManager.parseAndGetValue( m_context, "{$PAGeNamE}" ); Assertions.assertEquals( PAGE_NAME, res ); }