### Question:
DelegatingTokenHolder extends AbstractTokenHolderBase { @Override public void getOrCreateIds( String[] names, int[] ids ) { if ( names.length != ids.length ) { throw new IllegalArgumentException( "Name and id arrays must have the same length." ); } boolean hasUnresolvedTokens = resolveIds( names, ids, ALWAYS_TRUE_INT ); if ( hasUnresolvedTokens ) { createMissingTokens( names, ids ); } } DelegatingTokenHolder( TokenCreator tokenCreator, String tokenType ); @Override void getOrCreateIds( String[] names, int[] ids );  }### Answer:
@Test public void batchTokenCreateMustIgnoreExistingTokens() throws Exception { initialTokensABC(); AtomicInteger nextId = new AtomicInteger( 42 ); mockAssignNewTokenIdsInBatch( nextId ); String[] names = new String[]{"b", "X", "a", "Y", "c"}; int[] ids = new int[names.length]; holder.getOrCreateIds( names, ids ); assertThat( ids.length, is( 5 ) ); assertThat( ids[0], is( 2 ) ); assertThat( ids[1], isOneOf( 42, 43 ) ); assertThat( ids[2], is( 1 ) ); assertThat( ids[3], isOneOf( 42, 43 ) ); assertThat( ids[4], is( 3 ) ); assertThat( nextId.get(), is( 44 ) ); holder.getTokenById( 42 ); holder.getTokenById( 43 ); }
@Test public void batchTokenCreateMustDeduplicateTokenCreates() throws Exception { initialTokensABC(); AtomicInteger nextId = new AtomicInteger( 42 ); mockAssignNewTokenIdsInBatch( nextId ); String[] names = new String[]{"b", "b", "X", "a", "X", "c"}; int[] ids = new int[names.length]; holder.getOrCreateIds( names, ids ); assertThat( ids.length, is( 6 ) ); assertThat( ids[0], is( 2 ) ); assertThat( ids[1], is( 2 ) ); assertThat( ids[2], is( 42 ) ); assertThat( ids[3], is( 1 ) ); assertThat( ids[4], is( 42 ) ); assertThat( ids[5], is( 3 ) ); assertThat( nextId.get(), is( 43 ) ); holder.getTokenById( 42 ); }
@Test( expected = IllegalArgumentException.class ) public void batchTokenCreateMustThrowOnArraysOfDifferentLengths() { holder.getOrCreateIds( new String[3], new int[2] ); }