use of com.vaadin.flow.template.angular.model.TemplateModel 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());
}
use of com.vaadin.flow.template.angular.model.TemplateModel 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));
}
use of com.vaadin.flow.template.angular.model.TemplateModel in project flow by vaadin.
the class TemplateModelProxyHandlerTest method testToString.
@Test
public void testToString() {
EmptyModelTemplate emptyModelTemplate1 = new EmptyModelTemplate();
EmptyModelTemplate emptyModelTemplate2 = new EmptyModelTemplate();
TemplateModel m1 = emptyModelTemplate1.getModel();
TemplateModel m2 = emptyModelTemplate2.getModel();
// add templates to UI so that their state nodes get an id which is used
// in toString()
new UI().add(emptyModelTemplate1, emptyModelTemplate2);
Assert.assertEquals(m1.toString(), m1.toString());
Assert.assertNotEquals(m1.toString(), m2.toString());
}
use of com.vaadin.flow.template.angular.model.TemplateModel in project flow by vaadin.
the class TemplateModelTest method testTemplateModelCreation.
@Test
public void testTemplateModelCreation() {
EmptyModelTemplate emptyModelTemplate = new EmptyModelTemplate();
TemplateModel modelProxy = emptyModelTemplate.getModel();
TemplateModel modelProxy2 = emptyModelTemplate.getModel();
Assert.assertTrue(modelProxy == modelProxy2);
modelProxy2 = new EmptyModelTemplate().getModel();
Assert.assertNotSame(modelProxy, modelProxy2);
}
Aggregations