@Test public void unknown_translator_is_failure() { Translator fred = mockTranslator("fred", String.class); Translator barney = mockTranslator("barney", Long.class); Map<Class, Translator> configuration = CollectionFactory.newMap(); configuration.put(String.class, fred); configuration.put(Long.class, barney); replay(); TranslatorSource source = new TranslatorSourceImpl(configuration); try { source.get("wilma"); unreachable(); } catch (UnknownValueException ex) { assertMessageContains(ex, "Unknown translator type 'wilma'."); } }
public Translator get(String name) { Translator result = nameToTranslator.get(name); if (result == null) throw new UnknownValueException(String.format("Unknown translator type '%s'.", name), new AvailableValues( "Configured translators", nameToTranslator)); return result; }
TranslatorSourceImpl implements TranslatorSource, Runnable { public Translator get(String name) { Translator result = nameToTranslator.get(name); if (result == null) throw new UnknownValueException(String.format("Unknown translator type '%s'.", name), new AvailableValues( "Configured translators", nameToTranslator)); return result; } }
TranslatorSourceImpl implements TranslatorSource, Runnable { public Translator get(String name) { Translator result = nameToTranslator.get(name); if (result == null) throw new UnknownValueException(String.format("Unknown translator type '%s'.", name), new AvailableValues( "Configured translators", nameToTranslator)); return result; } TranslatorSourceImpl(Map<Class, Translator> configuration);  TranslatorSourceImpl(Map<Class, Translator> configuration, Map<String, Translator> alternates); }
TranslatorSourceImpl implements TranslatorSource, Runnable { public Translator get(String name) { Translator result = nameToTranslator.get(name); if (result == null) throw new UnknownValueException(String.format("Unknown translator type '%s'.", name), new AvailableValues( "Configured translators", nameToTranslator)); return result; } TranslatorSourceImpl(Map<Class, Translator> configuration);  TranslatorSourceImpl(Map<Class, Translator> configuration, Map<String, Translator> alternates); Translator get(String name); Translator getByType(Class valueType); Translator findByType(Class valueType); void run(); }
TranslatorSourceImpl implements TranslatorSource, Runnable { public Translator get(String name) { Translator result = nameToTranslator.get(name); if (result == null) throw new UnknownValueException(String.format("Unknown translator type '%s'.", name), new AvailableValues( "Configured translators", nameToTranslator)); return result; } TranslatorSourceImpl(Map<Class, Translator> configuration);  TranslatorSourceImpl(Map<Class, Translator> configuration, Map<String, Translator> alternates); Translator get(String name); Translator getByType(Class valueType); Translator findByType(Class valueType); void run();  }