### Question:
TokenRegistry { public void put( NamedToken token ) throws NonUniqueTokenException { idToToken.put( token.id(), token ); putAndEnsureUnique( nameToId, token ); } TokenRegistry( String tokenType ); String getTokenType(); void setInitialTokens( List<NamedToken> tokens ); void putAll( List<NamedToken> tokens ); void put( NamedToken token ); Integer getId( String name ); NamedToken getToken( int id ); Iterable<NamedToken> allTokens(); int size();  }### Answer:
@Test public void addTokenWithDuplicatedNotAllowed() { TokenRegistry tokenCache = createTokenCache(); tokenCache.put( new NamedToken( INBOUND1_TYPE, 1 ) ); tokenCache.put( new NamedToken( INBOUND2_TYPE, 2 ) ); expectedException.expect( NonUniqueTokenException.class ); expectedException.expectMessage( "The testType \"inbound1\" is not unique" ); tokenCache.put( new NamedToken( INBOUND1_TYPE, 3 ) ); }