### Question:
NodeIdList extends ArrayList<String> { @CheckForNull public String getNextNodeId( @Nonnull final String nodeId ) throws IllegalArgumentException { final int idx = indexOf( nodeId ); if ( idx < 0 ) { throw new IllegalArgumentException( "The given node id "+ nodeId +" is not part of this list " + toString() ); } if ( size() == 1 ) { return null; } return ( idx == size() - 1 ) ? get( 0 ) : get( idx + 1 ); } NodeIdList( @Nonnull final String ... nodeIds );  NodeIdList( @Nonnull final List<String> nodeIds ); @Nonnull static NodeIdList create( @Nonnull final String ... nodeIds ); @CheckForNull String getNextNodeId( @Nonnull final String nodeId );  }### Answer:
@Test public void testGetNextNodeId() { assertEquals( NodeIdList.create( "n1", "n2" ).getNextNodeId( "n1" ), "n2" ); assertEquals( NodeIdList.create( "n1", "n2" ).getNextNodeId( "n2" ), "n1" ); assertNull( NodeIdList.create( "n1" ).getNextNodeId( "n1" ) ); try { assertNull( NodeIdList.create( "n1" ).getNextNodeId( "n2" ) ); fail( "An unknown node should lead to an illegal arg exception." ); } catch( final IllegalArgumentException e ) { } }