Browse Source

Erase type of BeanBinder#bindInstanceFields parameter in equality test

Fixes vaadin/framework8-issues#466
tags/8.0.0.alpha9^0
Aleksi Hietanen 7 years ago
parent
commit
d0184c4ccd

+ 2
- 2
server/src/main/java/com/vaadin/data/BeanBinder.java View File

memberField.getName(), memberField.getName(),
objectWithMemberFields.getClass().getName())); objectWithMemberFields.getClass().getName()));
} }
if (propertyType.equals(valueType)) {
if (propertyType.equals(GenericTypeReflector.erase(valueType))) {
HasValue<?> field; HasValue<?> field;
// Get the field from the object // Get the field from the object
try { try {
throw new IllegalStateException(String.format( throw new IllegalStateException(String.format(
"Property type '%s' doesn't " "Property type '%s' doesn't "
+ "match the field type '%s'. " + "match the field type '%s'. "
+ "Binding should be configured manulaly using converter.",
+ "Binding should be configured manually using converter.",
propertyType.getName(), valueType.getTypeName())); propertyType.getName(), valueType.getTypeName()));
} }
} }

+ 28
- 0
server/src/test/java/com/vaadin/data/BeanBinderTest.java View File



import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List; import java.util.List;
import java.util.Set;


import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import com.vaadin.data.BeanBinder.BeanBindingBuilder; import com.vaadin.data.BeanBinder.BeanBindingBuilder;
import com.vaadin.data.Binder.BindingBuilder; import com.vaadin.data.Binder.BindingBuilder;
import com.vaadin.tests.data.bean.BeanToValidate; import com.vaadin.tests.data.bean.BeanToValidate;
import com.vaadin.ui.CheckBoxGroup;


public class BeanBinderTest public class BeanBinderTest
extends BinderTestBase<BeanBinder<BeanToValidate>, BeanToValidate> { extends BinderTestBase<BeanBinder<BeanToValidate>, BeanToValidate> {


private enum TestEnum {
}

private class TestClass {
private CheckBoxGroup<TestEnum> enums;
}

private class TestBean {
private Set<TestEnum> enums;

public Set<TestEnum> getEnums() {
return enums;
}

public void setEnums(Set<TestEnum> enums) {
this.enums = enums;
}
}

@Before @Before
public void setUp() { public void setUp() {
binder = new BeanBinder<>(BeanToValidate.class); binder = new BeanBinder<>(BeanToValidate.class);
item.setAge(32); item.setAge(32);
} }


@Test
public void bindInstanceFields_parameters_type_erased() {
BeanBinder<TestBean> otherBinder = new BeanBinder<>(TestBean.class);
TestClass testClass = new TestClass();
otherBinder.bindInstanceFields(testClass);
}

@Test @Test
public void fieldBound_bindBean_fieldValueUpdated() { public void fieldBound_bindBean_fieldValueUpdated() {
binder.bind(nameField, "firstname"); binder.bind(nameField, "firstname");

Loading…
Cancel
Save