CustomMappingsLoader { public LoadMappingsResult load(List<MappingFileData> mappings) { Configuration globalConfiguration = findConfiguration(mappings); ClassMappings customMappings = new ClassMappings(beanContainer); for (MappingFileData mappingFileData : mappings) { List<ClassMap> classMaps = mappingFileData.getClassMaps(); ClassMappings customMappingsPrime = mappingsParser.processMappings(classMaps, globalConfiguration); customMappings.addAll(customMappingsPrime); } classMapBuilder.addDefaultFieldMappings(customMappings, globalConfiguration); Set<CustomConverterDescription> customConverterDescriptions = new LinkedHashSet<>(); if (globalConfiguration.getCustomConverters() != null && globalConfiguration.getCustomConverters().getConverters() != null) { for (CustomConverterDescription cc : globalConfiguration.getCustomConverters().getConverters()) { customConverterDescriptions.add(cc); } } for (Entry<String, ClassMap> entry : customMappings.getAll().entrySet()) { ClassMap classMap = entry.getValue(); if (classMap.getCustomConverters() != null) { classMap.getCustomConverters().setConverters(new ArrayList<>(customConverterDescriptions)); } else { classMap.setCustomConverters(new CustomConverterContainer()); classMap.getCustomConverters().setConverters(new ArrayList<>(customConverterDescriptions)); } } addDefaultCustomConverters(globalConfiguration); return new LoadMappingsResult(customMappings, globalConfiguration); } CustomMappingsLoader(MappingsParser mappingsParser, ClassMapBuilder classMapBuilder, BeanContainer beanContainer); LoadMappingsResult load(List<MappingFileData> mappings);  }
@Test(expected = MappingException.class) public void testLoad_MultipleGlobalConfigsFound() { data.add(createMappingData(true)); data.add(createMappingData(true)); loader.load(data); fail("should have thrown exception"); }
@Test public void testLoad_DoesNotAddDefaultUUIDConverter_IfCustomConverterSpecified() { Configuration configuration = new Configuration(); CustomConverterDescription userSpecifiedConverter = new CustomConverterDescription(); userSpecifiedConverter.setClassA(UUID.class); userSpecifiedConverter.setClassB(UUID.class); userSpecifiedConverter.setType(CustomConverter.class); configuration.getCustomConverters().addConverter(userSpecifiedConverter); MappingFileData mappingFileData = new MappingFileData(); mappingFileData.setConfiguration(configuration); data.add(mappingFileData); loader.load(data); List<CustomConverterDescription> customConverters = configuration.getCustomConverters().getConverters(); assertEquals("User-specified converter should be in list of converters.", 1, customConverters.size()); assertFalse("User-specified converter should override default by reference " + "converter for UUID to UUID mapping.", customConverters.get(0).getType().equals(CustomMappingsLoader.ByReferenceConverter.class)); }