### Question:
ObjectMapperSubtypeConfigurer { public void registerSubtype(ObjectMapper mapper, SubtypeLocator subtypeLocator) { subtypeLocator .searchPackages() .forEach(pkg -> mapper.registerSubtypes(findSubtypes(subtypeLocator.rootType(), pkg))); } ObjectMapperSubtypeConfigurer(boolean strictSerialization); void registerSubtypes(ObjectMapper mapper, List<SubtypeLocator> subtypeLocators); void registerSubtype(ObjectMapper mapper, SubtypeLocator subtypeLocator);  }### Answer:
@Test public void shouldRegisterSubtypesByClass() throws JsonProcessingException { new ObjectMapperSubtypeConfigurer(true) .registerSubtype(mapper, new ClassSubtypeLocator(RootType.class, searchPackages())); assertEquals("{\"kind\":\"child\"}", mapper.writeValueAsString(new ChildType())); }
@Test public void shouldRegisterSubtypesByName() throws JsonProcessingException { new ObjectMapperSubtypeConfigurer(true) .registerSubtype( mapper, new StringSubtypeLocator( "com.netflix.spinnaker.kork.jackson.RootType", searchPackages())); assertEquals("{\"kind\":\"child\"}", mapper.writeValueAsString(new ChildType())); }
@Test(expected = InvalidSubtypeConfigurationException.class) public void shouldThrowWhenSubtypeNameIsUndefined() { new ObjectMapperSubtypeConfigurer(true) .registerSubtype( mapper, new ClassSubtypeLocator(UndefinedRootType.class, searchPackages())); }