### Question:
AnnotatedFieldMappers { @Reference(cardinality = MULTIPLE, policy = DYNAMIC, unbind = "unbind") protected synchronized void bind(AnnotatedFieldMapper<?, ?> mapper) { if (mapper == null) { throw new IllegalArgumentException("Method argument mapper must not be null."); } this.fieldMappers.put(mapper.getAnnotationType(), mapper); this.cache.clear(); }  Collection<AnnotationMapping<?, ?>> get(MappedFieldMetaData metaData);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testAdditionOfNullMapper() { bind(null); }
@Test public void testMapperResolutionWithDisjointMappers() { bind(this.mapper1); bind(this.mapper2); assertMetadataHasMappers(this.metadata1, this.mapper1); assertMetadataHasAnnotations(this.metadata1, this.annotation1); assertMetadataHasMappers(this.metadata2, this.mapper2); assertMetadataHasAnnotations(this.metadata2, this.annotation2); }
@Test public void testMapperResolutionWithOverlappingMappers() { withMapperSupporting(this.mapper1, Resource.class); bind(this.mapper1); bind(this.mapper2); assertNoMapperExistFor(this.metadata1); assertMetadataHasMappers(this.metadata2, this.mapper1, this.mapper2); assertMetadataHasAnnotations(this.metadata2, this.annotation2, this.metaAnnotation1); }
@Test public void testMappersForBoxedTypesAreaAppliedToTheirPrimitiveVariants() { bind(this.mapper1); doReturn(Boolean.class).when(this.mapper1).getFieldType(); doReturn(boolean.class).when(this.metadata1).getType(); assertMetadataHasMappers(this.metadata1, this.mapper1); }
@Test public void testLookupCache() { bind(this.mapper1); assertMetadataHasMappers(this.metadata1, this.mapper1); assertMetadataHasAnnotations(this.metadata1, this.annotation1); assertMetadataHasMappers(this.metadata1, this.mapper1); assertMetadataHasAnnotations(this.metadata1, this.annotation1); verifyAnnotationsWhereQueriedOnlyOnce(); }