Search in sources :

Example 1 with ClientDelegateHandlers

use of com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers in project flow by vaadin.

the class ClientDelegteHandlersTest method attach_methodHasGoodArg_ExceptionIsThrown.

@Test
public void attach_methodHasGoodArg_ExceptionIsThrown() {
    UI ui = new UI();
    AngularTemplate template = new TemplateWithGoodParametersMethods();
    ui.add(template);
    ClientDelegateHandlers feature = template.getElement().getNode().getFeature(ClientDelegateHandlers.class);
    Assert.assertEquals(10, feature.size());
    Set<String> methods = getDeclaredMethods(TemplateWithGoodParametersMethods.class).collect(Collectors.toCollection(HashSet::new));
    methods.add(getDeclaredMethods(Template1.class).findFirst().get());
    for (int i = 0; i < feature.size(); i++) {
        methods.remove(feature.get(i));
    }
    Assert.assertTrue("Feature doesn't contain methods: " + methods.toString(), methods.isEmpty());
}
Also used : UI(com.vaadin.flow.component.UI) AngularTemplate(com.vaadin.flow.template.angular.AngularTemplate) ClientDelegateHandlers(com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers) Test(org.junit.Test)

Example 2 with ClientDelegateHandlers

use of com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers in project flow by vaadin.

the class ClientDelegteHandlersTest method nonTemplateComponentWithEventHandler.

@Test
public void nonTemplateComponentWithEventHandler() {
    UI ui = new UI();
    NonTemplateComponentWithEventHandler component = new NonTemplateComponentWithEventHandler();
    ui.add(component);
    ClientDelegateHandlers feature = component.getElement().getNode().getFeature(ClientDelegateHandlers.class);
    assertListFeature(feature, "publishedMethod1");
}
Also used : UI(com.vaadin.flow.component.UI) ClientDelegateHandlers(com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers) Test(org.junit.Test)

Example 3 with ClientDelegateHandlers

use of com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers in project flow by vaadin.

the class ClientDelegteHandlersTest method attach_handlersContainsTemplateMethod.

@Test
public void attach_handlersContainsTemplateMethod() {
    UI ui = new UI();
    AngularTemplate template = new Template1();
    ui.add(template);
    ClientDelegateHandlers feature = template.getElement().getNode().getFeature(ClientDelegateHandlers.class);
    Assert.assertEquals(1, feature.size());
    Assert.assertEquals(getDeclaredMethods(Template1.class).findFirst().get(), feature.get(0));
}
Also used : UI(com.vaadin.flow.component.UI) AngularTemplate(com.vaadin.flow.template.angular.AngularTemplate) ClientDelegateHandlers(com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers) Test(org.junit.Test)

Example 4 with ClientDelegateHandlers

use of com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers in project flow by vaadin.

the class ClientDelegteHandlersTest method attach_methodWithUncheckedException_handlersContainsTemplateMethod.

@Test
public void attach_methodWithUncheckedException_handlersContainsTemplateMethod() {
    UI ui = new UI();
    AngularTemplate template = new TemplateWithMethodDeclaringUncheckedException();
    ui.add(template);
    ClientDelegateHandlers feature = template.getElement().getNode().getFeature(ClientDelegateHandlers.class);
    Assert.assertEquals(2, feature.size());
    Assert.assertEquals(getDeclaredMethods(TemplateWithMethodDeclaringUncheckedException.class).findFirst().get(), feature.get(0));
}
Also used : UI(com.vaadin.flow.component.UI) AngularTemplate(com.vaadin.flow.template.angular.AngularTemplate) ClientDelegateHandlers(com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers) Test(org.junit.Test)

Example 5 with ClientDelegateHandlers

use of com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers in project flow by vaadin.

the class ClientDelegteHandlersTest method attach_handlersContainsAllTemplateMethods.

@Test
public void attach_handlersContainsAllTemplateMethods() {
    UI ui = new UI();
    AngularTemplate template = new ChildTemplateWithMultipleMethods();
    ui.add(template);
    ClientDelegateHandlers feature = template.getElement().getNode().getFeature(ClientDelegateHandlers.class);
    Assert.assertEquals(3, feature.size());
    Set<String> methods = getDeclaredMethods(ChildTemplateWithMultipleMethods.class).collect(Collectors.toCollection(HashSet::new));
    methods.add(getDeclaredMethods(Template1.class).findFirst().get());
    for (int i = 0; i < feature.size(); i++) {
        methods.remove(feature.get(i));
    }
    Assert.assertTrue("Feature doesn't contain methods: " + methods.toString(), methods.isEmpty());
}
Also used : UI(com.vaadin.flow.component.UI) AngularTemplate(com.vaadin.flow.template.angular.AngularTemplate) ClientDelegateHandlers(com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers) Test(org.junit.Test)

Aggregations

ClientDelegateHandlers (com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers)8 Test (org.junit.Test)8 UI (com.vaadin.flow.component.UI)7 AngularTemplate (com.vaadin.flow.template.angular.AngularTemplate)5 StateNode (com.vaadin.flow.internal.StateNode)1 ComponentMapping (com.vaadin.flow.internal.nodefeature.ComponentMapping)1