### Question:
SinkUtils { public static MutableAttributeSet filterAttributes( AttributeSet attributes, String[] valids ) { if ( attributes == null ) { return null; } if ( valids == null || valids.length == 0 ) { return new SinkEventAttributeSet( 0 ); } MutableAttributeSet atts = new SinkEventAttributeSet( attributes.getAttributeCount() ); Enumeration<?> names = attributes.getAttributeNames(); while ( names.hasMoreElements() ) { String key = names.nextElement().toString(); if ( Arrays.binarySearch( valids, key ) >= 0 ) { atts.addAttribute( key, attributes.getAttribute( key ) ); } } return atts; } private  SinkUtils(); static String getAttributeString( AttributeSet att ); static MutableAttributeSet filterAttributes( AttributeSet attributes, String[] valids ); static final String[] SINK_BASE_ATTRIBUTES; static final String[] SINK_BR_ATTRIBUTES; static final String[] SINK_IMG_ATTRIBUTES; static final String[] SINK_SECTION_ATTRIBUTES; static final String[] SINK_VERBATIM_ATTRIBUTES; static final String[] SINK_HR_ATTRIBUTES; static final String[] SINK_LINK_ATTRIBUTES; static final String[] SINK_TABLE_ATTRIBUTES; static final String[] SINK_TD_ATTRIBUTES; static final String[] SINK_TR_ATTRIBUTES; }### Answer:
@Test public void testFilterAttributes() { Assert.assertNull( SinkUtils.filterAttributes( null, null ) ); AttributeSet attributes = new SinkEventAttributeSet( 1 ); String[] valids = null; MutableAttributeSet result = SinkUtils.filterAttributes( attributes, valids ); assertEquals( 0, result.getAttributeCount() ); valids = new String[] {}; result = SinkUtils.filterAttributes( attributes, valids ); assertEquals( 0, result.getAttributeCount() ); result = SinkUtils.filterAttributes( SinkEventAttributeSet.BOLD, SinkUtils.SINK_BASE_ATTRIBUTES ); assertEquals( 1, result.getAttributeCount() ); result = SinkUtils.filterAttributes( SinkEventAttributeSet.CENTER, SinkUtils.SINK_BASE_ATTRIBUTES ); assertEquals( 0, result.getAttributeCount() ); }