@Test public void normal_conversion() { AssetSource source = mockAssetSource(); ObjectLocator locator = mockObjectLocator(); Asset asset = mockAsset(); String path = "${foo}"; String expanded = "foo/bar/baz.gif"; AnnotationProvider annotationProvider = mockAnnotationProvider(); TypeCoercer typeCoercer = mockTypeCoercer(); Path pathAnnotation = mockPath(); SymbolSource symbolSource = mockSymbolSource(); train_getAnnotation(annotationProvider, Path.class, pathAnnotation); train_value(pathAnnotation, path); train_expandSymbols(symbolSource, path, expanded); train_getAsset(source, null, expanded, null, asset); train_coerce(typeCoercer, asset, Asset.class, asset); replay(); ObjectProvider provider = new AssetObjectProvider(source, typeCoercer, symbolSource); Asset result = provider.provide(Asset.class, annotationProvider, locator); assertSame(result, asset); verify(); }
public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) { Path path = annotationProvider.getAnnotation(Path.class); if (path == null) return null; String expanded = symbolSource.expandSymbols(path.value()); Asset asset = source.getAsset(null, expanded, null); return typeCoercer.coerce(asset, objectType); }
AssetObjectProvider implements ObjectProvider { public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) { Path path = annotationProvider.getAnnotation(Path.class); if (path == null) return null; String expanded = symbolSource.expandSymbols(path.value()); Asset asset = source.getAsset(null, expanded, null); return typeCoercer.coerce(asset, objectType); } }
AssetObjectProvider implements ObjectProvider { public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) { Path path = annotationProvider.getAnnotation(Path.class); if (path == null) return null; String expanded = symbolSource.expandSymbols(path.value()); Asset asset = source.getAsset(null, expanded, null); return typeCoercer.coerce(asset, objectType); } AssetObjectProvider(@Core AssetSource source,

                               @Builtin TypeCoercer typeCoercer,

                               @Builtin SymbolSource symbolSource); }
AssetObjectProvider implements ObjectProvider { public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) { Path path = annotationProvider.getAnnotation(Path.class); if (path == null) return null; String expanded = symbolSource.expandSymbols(path.value()); Asset asset = source.getAsset(null, expanded, null); return typeCoercer.coerce(asset, objectType); } AssetObjectProvider(@Core AssetSource source,

                               @Builtin TypeCoercer typeCoercer,

                               @Builtin SymbolSource symbolSource); T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator); }
AssetObjectProvider implements ObjectProvider { public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) { Path path = annotationProvider.getAnnotation(Path.class); if (path == null) return null; String expanded = symbolSource.expandSymbols(path.value()); Asset asset = source.getAsset(null, expanded, null); return typeCoercer.coerce(asset, objectType); } AssetObjectProvider(@Core AssetSource source,

                               @Builtin TypeCoercer typeCoercer,

                               @Builtin SymbolSource symbolSource); T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator);  }