Search in sources :

Example 1 with AngularTemplate

use of com.vaadin.flow.template.angular.AngularTemplate 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 AngularTemplate

use of com.vaadin.flow.template.angular.AngularTemplate in project flow by vaadin.

the class ClientDelegteHandlersTest method attach_overloadedMethod_ExceptionIsThrown.

@Test(expected = IllegalStateException.class)
public void attach_overloadedMethod_ExceptionIsThrown() {
    UI ui = new UI();
    AngularTemplate template = new ChildTemplateWithOverloadedMethod();
    ui.add(template);
}
Also used : UI(com.vaadin.flow.component.UI) AngularTemplate(com.vaadin.flow.template.angular.AngularTemplate) Test(org.junit.Test)

Example 3 with AngularTemplate

use of com.vaadin.flow.template.angular.AngularTemplate 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 AngularTemplate

use of com.vaadin.flow.template.angular.AngularTemplate in project flow by vaadin.

the class ClientDelegteHandlersTest method attach_methodReturnType_ExceptionIsThrown.

@Test(expected = IllegalStateException.class)
public void attach_methodReturnType_ExceptionIsThrown() {
    UI ui = new UI();
    AngularTemplate template = new TemplateWithMethodReturnValue();
    ui.add(template);
}
Also used : UI(com.vaadin.flow.component.UI) AngularTemplate(com.vaadin.flow.template.angular.AngularTemplate) Test(org.junit.Test)

Example 5 with AngularTemplate

use of com.vaadin.flow.template.angular.AngularTemplate 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)

Aggregations

UI (com.vaadin.flow.component.UI)11 AngularTemplate (com.vaadin.flow.template.angular.AngularTemplate)11 Test (org.junit.Test)11 ClientDelegateHandlers (com.vaadin.flow.internal.nodefeature.ClientDelegateHandlers)5 Element (com.vaadin.flow.dom.Element)2 TemplateElementStateProviderTest (com.vaadin.flow.dom.TemplateElementStateProviderTest)2 InlineTemplate (com.vaadin.flow.template.angular.InlineTemplate)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2