### Question:
BundleManifestScanner implements BundleScanner<ManifestEntry> { public List<ManifestEntry> scan( final Bundle bundle ) { NullArgumentException.validateNotNull( bundle, "Bundle" ); final Dictionary bundleHeaders = bundle.getHeaders(); if( bundleHeaders != null && !bundleHeaders.isEmpty() ) { return asManifestEntryList( m_manifestFilter.match( dictionaryToMap( bundleHeaders ) ) ); } else { return Collections.emptyList(); } } BundleManifestScanner( final ManifestFilter manifestFilter ); List<ManifestEntry> scan( final Bundle bundle );  }### Answer:
@Test( expected = org.ops4j.lang.NullArgumentException.class ) public void scanWithNullBundle() { new BundleManifestScanner( createMock( ManifestFilter.class ) ).scan( null ); }
@Test public void scanWithNullBundleHeaders() { final Bundle bundle = createMock( Bundle.class ); expect( bundle.getHeaders() ).andReturn( null ); replay( bundle ); List<?> headers = new BundleManifestScanner( createMock( ManifestFilter.class ) ).scan( bundle ); assertThat( "Headers list", headers, is( notNullValue() ) ); assertThat( "Number of headers", 0, is( equalTo( headers.size() ) ) ); verify( bundle ); }
@Test public void scan() { final Dictionary<String, String> dictionary = new Hashtable<String, String>(); dictionary.put( "k1", "v1" ); dictionary.put( "k2", "v2" ); final Map<String, String> entries = new HashMap<String, String>(); entries.put( "k1", "v1" ); entries.put( "k2", "v2" ); final Bundle bundle = createMock( Bundle.class ); expect( bundle.getHeaders() ).andReturn( dictionary ); final ManifestFilter filter = createMock( ManifestFilter.class ); expect( filter.match( (Map<String, String>) notNull() ) ).andReturn( entries ); replay( bundle, filter ); List<?> headers = new BundleManifestScanner( filter ).scan( bundle ); verify( bundle, filter ); assertThat( "Headers list", headers, is( notNullValue() ) ); assertThat( "Number of headers", 2, is( equalTo( headers.size() ) ) ); }