@Test public void shouldUseConfigSerializer() throws Exception { Serializer mock = mock(Serializer.class); when(config.get(getClass().getName() + SimpleXmlFactory.SERIALIZER)).thenReturn(mock); assertSame(mock, SimpleXmlFactory.createSerializer(config, getClass())); verify(config, never()).getBooleanFalse(); verify(config, never()).getBooleanTrue(); verify(config, never()).getDateFormat(); verify(config).get(getClass().getName() + SimpleXmlFactory.SERIALIZER); }
static Serializer createSerializer(CRestConfig crestConfig, Class<?> source){ String prefix = source.getName(); Serializer serializer = crestConfig.get(prefix + SERIALIZER); if(serializer != null) { return serializer; } Map<Class, Transform> registry = new HashMap<Class, Transform>(); registry.put(Date.class, new DateMatcher(crestConfig.getDateFormat())); registry.put(Boolean.class, new BooleanMatcher(crestConfig.getBooleanTrue(), crestConfig.getBooleanFalse())); registry.put(boolean.class, registry.get(Boolean.class)); return new Persister(new MatcherRegistry(registry)); }
SimpleXmlFactory { static Serializer createSerializer(CRestConfig crestConfig, Class<?> source){ String prefix = source.getName(); Serializer serializer = crestConfig.get(prefix + SERIALIZER); if(serializer != null) { return serializer; } Map<Class, Transform> registry = new HashMap<Class, Transform>(); registry.put(Date.class, new DateMatcher(crestConfig.getDateFormat())); registry.put(Boolean.class, new BooleanMatcher(crestConfig.getBooleanTrue(), crestConfig.getBooleanFalse())); registry.put(boolean.class, registry.get(Boolean.class)); return new Persister(new MatcherRegistry(registry)); } }
SimpleXmlFactory { static Serializer createSerializer(CRestConfig crestConfig, Class<?> source){ String prefix = source.getName(); Serializer serializer = crestConfig.get(prefix + SERIALIZER); if(serializer != null) { return serializer; } Map<Class, Transform> registry = new HashMap<Class, Transform>(); registry.put(Date.class, new DateMatcher(crestConfig.getDateFormat())); registry.put(Boolean.class, new BooleanMatcher(crestConfig.getBooleanTrue(), crestConfig.getBooleanFalse())); registry.put(boolean.class, registry.get(Boolean.class)); return new Persister(new MatcherRegistry(registry)); } private  SimpleXmlFactory(); }
SimpleXmlFactory { static Serializer createSerializer(CRestConfig crestConfig, Class<?> source){ String prefix = source.getName(); Serializer serializer = crestConfig.get(prefix + SERIALIZER); if(serializer != null) { return serializer; } Map<Class, Transform> registry = new HashMap<Class, Transform>(); registry.put(Date.class, new DateMatcher(crestConfig.getDateFormat())); registry.put(Boolean.class, new BooleanMatcher(crestConfig.getBooleanTrue(), crestConfig.getBooleanFalse())); registry.put(boolean.class, registry.get(Boolean.class)); return new Persister(new MatcherRegistry(registry)); } private  SimpleXmlFactory();  }
SimpleXmlFactory { static Serializer createSerializer(CRestConfig crestConfig, Class<?> source){ String prefix = source.getName(); Serializer serializer = crestConfig.get(prefix + SERIALIZER); if(serializer != null) { return serializer; } Map<Class, Transform> registry = new HashMap<Class, Transform>(); registry.put(Date.class, new DateMatcher(crestConfig.getDateFormat())); registry.put(Boolean.class, new BooleanMatcher(crestConfig.getBooleanTrue(), crestConfig.getBooleanFalse())); registry.put(boolean.class, registry.get(Boolean.class)); return new Persister(new MatcherRegistry(registry)); } private  SimpleXmlFactory();   }