Esempio n. 1
0
  /** Unit test for constructor on concrete class. */
  @Test
  public void testConstructor_onConcreteClass() {
    TypeAnalysis analysis = new TypeAnalysis(BeanWithReadOnlyAndWriteOnly.class);
    Assert.assertEquals(BeanWithReadOnlyAndWriteOnly.class, analysis.clazz);
    Assert.assertEquals(0, analysis.getAbstractGetters().size());
    Assert.assertEquals(0, analysis.getAbstractSetters().size());
    Assert.assertEquals(0, analysis.getAbstractMethods().size());

    Assert.assertEquals(3, analysis.getConcreteGetters().size());
    Assert.assertEquals(4, analysis.getConcreteSetters().size());
    Assert.assertEquals(OBJECT_METHODS_COUNT + 1, analysis.concreteMethods.size());

    Assert.assertEquals(1, analysis.getOddProperties().size());
    Assert.assertEquals(1, analysis.getOddPropertiesNames().size());

    Assert.assertEquals(5, analysis.allProperties.size());
    Assert.assertEquals(1, analysis.oddPropertiesByName.size());

    BeanPropertyDefinition<?> odd = analysis.oddProperties.iterator().next();
    Assert.assertEquals("name", odd.getName());
    Assert.assertNull(odd.getGetter());

    Assert.assertEquals(1, analysis.getAllFieldsByName("name").size());

    Assert.assertNotNull(analysis.annotatedFields);
    Assert.assertEquals(3, analysis.annotatedFields.size());
  }
Esempio n. 2
0
 /** Unit test for handleSetter. */
 @Test
 public void testHandleMethod_GetterAndSetter() {
   TypeAnalysis analysis = new TypeAnalysis();
   analysis.clazz = IBeanWithIdAndNameImpl.class;
   Method setter = AccessorUtils.getSetter("beanName", String.class, analysis.clazz);
   analysis.handleMethod(setter);
   Method getter = AccessorUtils.getGetter("beanName", String.class, analysis.clazz);
   analysis.handleMethod(getter);
   Array key = new Array("beanName", String.class);
   BeanPropertyDefinition<?> bpd = analysis.allProperties.get(key);
   Assert.assertNotNull(bpd);
   Assert.assertNotNull(bpd.getGetter());
   Assert.assertNotNull(bpd.getSetter());
 }
Esempio n. 3
0
 /** Unit test for handleSetter. */
 @Test
 public void testHandleMethod_abstractSetter() {
   TypeAnalysis analysis = new TypeAnalysis();
   analysis.clazz = IBeanWithIdAndName.class;
   Method setter = AccessorUtils.getSetter("beanName", String.class, analysis.clazz);
   analysis.handleMethod(setter);
   Assert.assertTrue(analysis.abstractGetters.isEmpty());
   Assert.assertTrue(analysis.concreteGetters.isEmpty());
   Assert.assertTrue(analysis.abstractSetters.contains(setter));
   Assert.assertTrue(analysis.concreteSetters.isEmpty());
   Assert.assertTrue(analysis.abstractMethods.isEmpty());
   Assert.assertTrue(analysis.concreteMethods.isEmpty());
   Array key = new Array("beanName", String.class); // ???
   BeanPropertyDefinition<?> bpd = analysis.allProperties.get(key);
   Assert.assertNotNull(bpd);
   Assert.assertNotNull(bpd.getSetter());
 }