use of com.vaadin.flow.component.Component in project flow by vaadin.
the class PolymerTemplateTest method setUp.
@SuppressWarnings("serial")
@Before
public void setUp() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
executionOrder.clear();
executionParams.clear();
Field customElements = CustomElementRegistry.class.getDeclaredField("customElements");
customElements.setAccessible(true);
customElements.set(CustomElementRegistry.getInstance(), new AtomicReference<>());
Map<String, Class<? extends Component>> map = new HashMap<>();
map.put("child-template", TemplateChild.class);
map.put("ffs", TestPolymerTemplate.class);
map.put("execution-child", ExecutionChild.class);
CustomElementRegistry.getInstance().setCustomElements(map);
VaadinSession session = Mockito.mock(VaadinSession.class);
UI ui = new UI() {
private Page page = new Page(this) {
@Override
public ExecutionCanceler executeJavaScript(String expression, Serializable... parameters) {
executionOrder.add(expression);
executionParams.add(parameters);
return () -> true;
}
};
@Override
public VaadinSession getSession() {
return session;
}
@Override
public Page getPage() {
return page;
}
};
VaadinService service = Mockito.mock(VaadinService.class);
when(session.getService()).thenReturn(service);
DefaultInstantiator instantiator = new DefaultInstantiator(service);
when(service.getInstantiator()).thenReturn(instantiator);
UI.setCurrent(ui);
}
Aggregations