Search in sources :

Example 1 with WebComponentExporter

use of com.vaadin.flow.component.WebComponentExporter in project flow by vaadin.

the class WebComponentExporterUtilsTest method assertFactories.

private void assertFactories(WebComponentExporterFactory factory, WebComponentExporterFactory anotherFactory) {
    Assert.assertTrue(anotherFactory instanceof DefaultWebComponentExporterFactory);
    WebComponentExporter exporter = anotherFactory.create();
    MatcherAssert.assertThat(exporter, CoreMatchers.instanceOf(GoodExporter.class));
    exporter = factory.create();
    MatcherAssert.assertThat(exporter, CoreMatchers.instanceOf(NoDefaultCtorExporter.class));
}
Also used : WebComponentExporter(com.vaadin.flow.component.WebComponentExporter) DefaultWebComponentExporterFactory(com.vaadin.flow.component.WebComponentExporterFactory.DefaultWebComponentExporterFactory)

Example 2 with WebComponentExporter

use of com.vaadin.flow.component.WebComponentExporter in project flow by vaadin.

the class WebComponentWrapperTest method constructWrapperAndGetBinding.

/**
 * @param exporter
 *            exporter of the correct type, defines C
 * @param element
 *            nullable root element
 * @param ui
 *            nullable WebComponentUI
 * @param <C>
 *            type of the exported component
 * @return web component wrapper
 */
private <C extends Component> WebComponentBinding<C> constructWrapperAndGetBinding(WebComponentExporter<C> exporter, Element element, WebComponentUI ui) {
    if (element == null) {
        element = new Element("tag");
    }
    WebComponentBinding<C> binding = (WebComponentBinding<C>) new WebComponentExporter.WebComponentConfigurationFactory().create(exporter).createWebComponentBinding(new MockInstantiator(), element, Json.createObject());
    wrapper = new WebComponentWrapper(element, binding) {

        @Override
        public Optional<UI> getUI() {
            return Optional.of(ui);
        }
    };
    return binding;
}
Also used : WebComponentBinding(com.vaadin.flow.server.webcomponent.WebComponentBinding) Optional(java.util.Optional) Element(com.vaadin.flow.dom.Element) MockInstantiator(com.vaadin.flow.server.MockInstantiator) WebComponentExporter(com.vaadin.flow.component.WebComponentExporter)

Example 3 with WebComponentExporter

use of com.vaadin.flow.component.WebComponentExporter in project flow by vaadin.

the class WebComponentProviderTest method setupConfigurations.

@SuppressWarnings({ "unchecked", "rawtypes" })
@SafeVarargs
private final WebComponentConfigurationRegistry setupConfigurations(Class<? extends WebComponentExporter<? extends Component>>... exporters) {
    WebComponentConfigurationRegistry registry = setUpRegistry();
    final Set<Class<? extends WebComponentExporter<? extends Component>>> set = Stream.of(exporters).collect(Collectors.toSet());
    WebComponentExporter.WebComponentConfigurationFactory factory = new WebComponentExporter.WebComponentConfigurationFactory();
    Set<WebComponentConfiguration<? extends Component>> configurations = new HashSet<>();
    for (Class<? extends WebComponentExporter<? extends Component>> exporter : exporters) configurations.add(factory.create(new DefaultWebComponentExporterFactory(exporter).create()));
    registry.setConfigurations(configurations);
    return registry;
}
Also used : WebComponentConfiguration(com.vaadin.flow.component.webcomponent.WebComponentConfiguration) WebComponentConfigurationRegistry(com.vaadin.flow.server.webcomponent.WebComponentConfigurationRegistry) WebComponent(com.vaadin.flow.component.webcomponent.WebComponent) Component(com.vaadin.flow.component.Component) WebComponentExporter(com.vaadin.flow.component.WebComponentExporter) HashSet(java.util.HashSet) DefaultWebComponentExporterFactory(com.vaadin.flow.component.WebComponentExporterFactory.DefaultWebComponentExporterFactory)

Aggregations

WebComponentExporter (com.vaadin.flow.component.WebComponentExporter)3 DefaultWebComponentExporterFactory (com.vaadin.flow.component.WebComponentExporterFactory.DefaultWebComponentExporterFactory)2 Component (com.vaadin.flow.component.Component)1 WebComponent (com.vaadin.flow.component.webcomponent.WebComponent)1 WebComponentConfiguration (com.vaadin.flow.component.webcomponent.WebComponentConfiguration)1 Element (com.vaadin.flow.dom.Element)1 MockInstantiator (com.vaadin.flow.server.MockInstantiator)1 WebComponentBinding (com.vaadin.flow.server.webcomponent.WebComponentBinding)1 WebComponentConfigurationRegistry (com.vaadin.flow.server.webcomponent.WebComponentConfigurationRegistry)1 HashSet (java.util.HashSet)1 Optional (java.util.Optional)1