### Question:
DefaultAtlasConversionService implements AtlasConversionService { @Override public Optional<AtlasConverter<?>> findMatchingConverter(FieldType source, FieldType target) { Class<?> sourceClass = classFromFieldType(source); Class<?> targetClass = classFromFieldType(target); if (sourceClass != null && targetClass != null) { return findMatchingConverter(sourceClass.getCanonicalName(), targetClass.getCanonicalName()); } return Optional.empty(); } private  DefaultAtlasConversionService(); static DefaultAtlasConversionService getInstance(); static Set<String> listPrimitiveClassNames(); @Override Optional<AtlasConverter<?>> findMatchingConverter(FieldType source, FieldType target); @Override Optional<AtlasConverter<?>> findMatchingConverter(String sourceClassName, String targetClassName); @Override Object copyPrimitive(Object sourceValue); @Override Object convertType(Object sourceValue, FieldType origSourceType, FieldType targetType); @Override Object convertType(Object sourceValue, String sourceFormat, FieldType targetType, String targetFormat); @Override Object convertType(Object sourceValue, String sourceFormat, Class<?> targetType, String targetFormat); @Override boolean isConvertionAvailableFor(Object sourceValue, Class<?> targetType); @Override Boolean isPrimitive(String className); @Override Boolean isPrimitive(Class<?> clazz); @Override Boolean isPrimitive(FieldType fieldType); @Override Boolean isBoxedPrimitive(Class<?> clazz); @Override Class<?> boxOrUnboxPrimitive(String clazzName); @Override Class<?> boxOrUnboxPrimitive(Class<?> clazz); @Override FieldType fieldTypeFromClass(Class<?> clazz); @Override FieldType fieldTypeFromClass(String className); @Override Class<?> classFromFieldType(FieldType fieldType); @Override Boolean isAssignableFieldType(FieldType source, FieldType target);  }### Answer:
@Test public void findMatchingConverterByFieldTypes() { assertNotNull(service); Optional<AtlasConverter<?>> atlasConverter = service.findMatchingConverter(FieldType.STRING, FieldType.BOOLEAN); assertTrue(atlasConverter.isPresent()); assertNotNull(atlasConverter); assertEquals(StringConverter.class, atlasConverter.get().getClass()); StringConverter stringConverter = (StringConverter) atlasConverter.get(); assertNotNull(stringConverter); assertThat("io.atlasmap.converters.StringConverter", is(atlasConverter.get().getClass().getCanonicalName())); Boolean t = stringConverter.toBoolean("T", null, null); assertNotNull(t); assertTrue(t); Boolean f = stringConverter.toBoolean("F", null, null); assertNotNull(f); assertFalse(f); service.findMatchingConverter(null, FieldType.BOOLEAN); service.findMatchingConverter(FieldType.STRING, null); FieldType fieldType = null; service.findMatchingConverter(fieldType, fieldType); }
@Test public void findMatchingConverterByFieldTypesCustomConverter() { assertNotNull(service); Optional<AtlasConverter<?>> atlasConverter = service.findMatchingConverter(FieldType.STRING, FieldType.STRING); assertNotNull(atlasConverter); assertTrue(atlasConverter.isPresent()); assertTrue(AtlasConverter.class.isAssignableFrom(atlasConverter.get().getClass())); assertThat("io.atlasmap.converters.StringConverter", is(atlasConverter.get().getClass().getCanonicalName())); }
@Test public void findMatchingConverterByFieldTypesNoMatching() { assertNotNull(service); Optional<AtlasConverter<?>> atlasConverter = service.findMatchingConverter(FieldType.STRING, FieldType.COMPLEX); assertFalse(atlasConverter.isPresent()); }
@Test public void findMatchingConverterBySourceClass() { assertNotNull(service); Optional<AtlasConverter<?>> atlasConverter = service.findMatchingConverter("java.util.Date", "java.time.ZonedDateTime"); assertNotNull(atlasConverter); assertTrue(atlasConverter.isPresent()); assertTrue(AtlasConverter.class.isAssignableFrom(atlasConverter.get().getClass())); assertThat("io.atlasmap.converters.DateConverter", is(atlasConverter.get().getClass().getCanonicalName())); }
@Test public void findMatchingConverterBySourceClassNoMatching() { assertNotNull(service); Optional<AtlasConverter<?>> atlasConverter = service.findMatchingConverter("java.util.Date", "java.time.CustomClass"); assertFalse(atlasConverter.isPresent()); }