### Question:
DelegatingTokenHolder extends AbstractTokenHolderBase { @Override protected synchronized int createToken( String name ) throws KernelException { Integer id = tokenRegistry.getId( name ); if ( id != null ) { return id; } id = tokenCreator.createToken( name ); try { tokenRegistry.put( new NamedToken( name, id ) ); } catch ( NonUniqueTokenException e ) { throw new IllegalStateException( "Newly created token should be unique.", e ); } return id; } DelegatingTokenHolder( TokenCreator tokenCreator, String tokenType ); @Override void getOrCreateIds( String[] names, int[] ids );  }### Answer:
@Test public void mustCreateAndCacheNewTokens() throws Exception { when( creator.createToken( "token" ) ).thenReturn( 42 ); assertThat( holder.getOrCreateId( "token" ), is( 42 ) ); assertThat( holder.getOrCreateId( "token" ), is( 42 ) ); verify( creator ).createToken( "token" ); verifyNoMoreInteractions( creator ); }