You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BeanFieldGroupTest.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2012 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.v7.data.fieldgroup;
  17. import static org.junit.Assert.assertEquals;
  18. import org.junit.Test;
  19. public class BeanFieldGroupTest {
  20. class Main {
  21. private String mainField;
  22. public String getMainField() {
  23. return mainField;
  24. }
  25. public void setMainField(String mainField) {
  26. this.mainField = mainField;
  27. }
  28. }
  29. class Sub1 extends Main {
  30. private Integer sub1Field;
  31. public Integer getSub1Field() {
  32. return sub1Field;
  33. }
  34. public void setSub1Field(Integer sub1Field) {
  35. this.sub1Field = sub1Field;
  36. }
  37. }
  38. class Sub2 extends Sub1 {
  39. private boolean sub2field;
  40. public boolean isSub2field() {
  41. return sub2field;
  42. }
  43. public void setSub2field(boolean sub2field) {
  44. this.sub2field = sub2field;
  45. }
  46. }
  47. @Test
  48. public void propertyTypeWithoutItem() {
  49. BeanFieldGroup<Sub2> s = new BeanFieldGroup<BeanFieldGroupTest.Sub2>(
  50. Sub2.class);
  51. assertEquals(boolean.class, s.getPropertyType("sub2field"));
  52. assertEquals(Integer.class, s.getPropertyType("sub1Field"));
  53. assertEquals(String.class, s.getPropertyType("mainField"));
  54. }
  55. }