TapestryInternalUtils { public static InternalPropertyConduit toInternalPropertyConduit(final PropertyConduit conduit) { if (conduit instanceof InternalPropertyConduit) return (InternalPropertyConduit) conduit; return new InternalPropertyConduit() { public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { return conduit.getAnnotation(annotationClass); } public void set(Object instance, Object value) { conduit.set(instance, value); } public Class getPropertyType() { return conduit.getPropertyType(); } public Type getPropertyGenericType() { if (conduit instanceof PropertyConduit2) { return ((PropertyConduit2) conduit).getPropertyGenericType(); } return conduit.getPropertyType(); } public Object get(Object instance) { return conduit.get(instance); } public String getPropertyName() { return null; } }; }  static String toUserPresentable(String id); static Map<String, String> mapFromKeysAndValues(String... keysAndValues); static OptionModel toOptionModel(String input); static List<OptionModel> toOptionModels(String input); static SelectModel toSelectModel(String input); static OptionModel toOptionModel(Map.Entry input); static List<OptionModel> toOptionModels(Map<K, V> input); static SelectModel toSelectModel(Map<K, V> input); static OptionModel toOptionModel(Object input); static List<OptionModel> toOptionModels(List<E> input); static SelectModel toSelectModel(List<E> input); static KeyValue parseKeyValue(String input); static String extractIdFromPropertyExpression(String expression); static String defaultLabel(String id, Messages messages, String propertyExpression); static String lastTerm(String input); static String toClassAttributeValue(List<String> classes); static String getLabelForEnum(Messages messages, String prefix, Enum value); static String getLabelForEnum(Messages messages, Enum value); static boolean isEqual(T left, T right); static String[] splitPath(String path); static String[] splitAtCommas(String value); static void copy(InputStream in, OutputStream out); static boolean isEqual(EventContext left, EventContext right); static Asset2 toAsset2(final Asset asset); static InternalPropertyConduit toInternalPropertyConduit(final PropertyConduit conduit); static Orderable<String> mixinTypeAndOrder(String mixinDef); static String[] splitMixinConstraints(String s); static LinkCreationListener2 toLinkCreationListener2(final LinkCreationListener delegate); static String toFileSuffix(String fileName); static V getAndDeref(Map<K, ? extends Reference<V>> map, K key); static Thread[] getAllThreads(); static Mapper<Asset, StylesheetLink> assetToStylesheetLink; }
@Test public void to_internal_property_conduit_no_wrapper_needed() { InternalPropertyConduit conduit2 = newMock(InternalPropertyConduit.class); assertSame(TapestryInternalUtils.toInternalPropertyConduit(conduit2), conduit2); }
@Test public void to_internal_property_conduit_wrapper() { PropertyConduit conduit = mockPropertyConduit(); Integer result = 123; Width width = newMock(Width.class); expect(conduit.get("")).andReturn(result); expect(conduit.getAnnotation(Width.class)).andReturn(width); expect(conduit.getPropertyType()).andReturn(Integer.class); conduit.set("", 345); replay(); InternalPropertyConduit conduit2 = TapestryInternalUtils.toInternalPropertyConduit(conduit); assertNull(conduit2.getPropertyName()); assertSame(conduit2.get(""), result); assertSame(conduit2.getAnnotation(Width.class), width); assertSame(conduit2.getPropertyType(), Integer.class); conduit2.set("", 345); verify(); }