Search in sources :

Example 1 with EmptyModelTemplate

use of com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModelTemplate in project flow by vaadin.

the class TemplateModelProxyHandlerTest method objectMethodIsNotIntercepted.

@Test
public void objectMethodIsNotIntercepted() {
    EmptyModelTemplate template = new EmptyModelTemplate();
    Model proxy = TemplateModelProxyHandler.createModelProxy(template.getElement().getNode(), new BeanModelType<>(Model.class, PropertyFilter.ACCEPT_ALL));
    Assert.assertEquals(System.identityHashCode(proxy), proxy.hashCode());
}
Also used : EmptyModel(com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModel) TemplateModel(com.vaadin.flow.template.angular.model.TemplateModel) EmptyModelTemplate(com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModelTemplate) Test(org.junit.Test)

Example 2 with EmptyModelTemplate

use of com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModelTemplate in project flow by vaadin.

the class TemplateModelProxyHandlerTest method testHashCode.

@Test
public void testHashCode() {
    EmptyModelTemplate emptyModelTemplate1 = new EmptyModelTemplate();
    EmptyModelTemplate emptyModelTemplate2 = new EmptyModelTemplate();
    TemplateModel m1 = emptyModelTemplate1.getModel();
    TemplateModel m2 = emptyModelTemplate2.getModel();
    Assert.assertNotEquals(m1.hashCode(), m2.hashCode());
}
Also used : TemplateModel(com.vaadin.flow.template.angular.model.TemplateModel) EmptyModelTemplate(com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModelTemplate) Test(org.junit.Test)

Example 3 with EmptyModelTemplate

use of com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModelTemplate in project flow by vaadin.

the class TemplateModelProxyHandlerTest method noDefaultConstructor_throwsException.

@Test(expected = IllegalArgumentException.class)
public void noDefaultConstructor_throwsException() {
    EmptyModelTemplate template = new EmptyModelTemplate();
    TemplateModelProxyHandler.createModelProxy(template.getElement().getNode(), new BeanModelType<>(BadModel.class, PropertyFilter.ACCEPT_ALL));
}
Also used : EmptyModelTemplate(com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModelTemplate) Test(org.junit.Test)

Example 4 with EmptyModelTemplate

use of com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModelTemplate in project flow by vaadin.

the class TemplateModelProxyHandlerTest method notAccessorIsNotIntercepted.

@Test
public void notAccessorIsNotIntercepted() {
    EmptyModelTemplate template = new EmptyModelTemplate();
    Model proxy = TemplateModelProxyHandler.createModelProxy(template.getElement().getNode(), new BeanModelType<>(Model.class, PropertyFilter.ACCEPT_ALL));
    Assert.assertEquals("foo", proxy.toString());
}
Also used : EmptyModel(com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModel) TemplateModel(com.vaadin.flow.template.angular.model.TemplateModel) EmptyModelTemplate(com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModelTemplate) Test(org.junit.Test)

Example 5 with EmptyModelTemplate

use of com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModelTemplate in project flow by vaadin.

the class TemplateModelProxyHandlerTest method testEquals.

@Test
public void testEquals() {
    EmptyModelTemplate emptyModelTemplate1 = new EmptyModelTemplate();
    EmptyModelTemplate emptyModelTemplate2 = new EmptyModelTemplate();
    TemplateModel m1 = emptyModelTemplate1.getModel();
    TemplateModel m2 = emptyModelTemplate2.getModel();
    Assert.assertSame(m1.getClass(), m2.getClass());
    Assert.assertFalse(m1.equals(null));
    Assert.assertFalse(m1.equals("foobar"));
    Assert.assertFalse(m1.equals(m2));
    ModelDescriptor<EmptyModel> realModelType = ModelDescriptor.get(EmptyModel.class);
    Assert.assertTrue(m1.equals(TemplateModelProxyHandler.createModelProxy(emptyModelTemplate1.getElement().getNode(), realModelType)));
    BeanModelType<TemplateModel> wrongModelType = new BeanModelType<>(TemplateModel.class, PropertyFilter.ACCEPT_ALL);
    Assert.assertFalse(m1.equals(TemplateModelProxyHandler.createModelProxy(emptyModelTemplate1.getElement().getNode(), wrongModelType)));
    Assert.assertTrue(m2.equals(m2));
}
Also used : TemplateModel(com.vaadin.flow.template.angular.model.TemplateModel) EmptyModelTemplate(com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModelTemplate) EmptyModel(com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModel) BeanModelType(com.vaadin.flow.template.angular.model.BeanModelType) Test(org.junit.Test)

Aggregations

EmptyModelTemplate (com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModelTemplate)7 Test (org.junit.Test)7 TemplateModel (com.vaadin.flow.template.angular.model.TemplateModel)5 EmptyModel (com.vaadin.flow.template.angular.model.TemplateModelTest.EmptyModel)3 UI (com.vaadin.flow.component.UI)1 BeanModelType (com.vaadin.flow.template.angular.model.BeanModelType)1