/** 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()); }
/** The type is an interface that has the id property declared by more than one interfaces. */ @Test public void testConstructor_samePropertyDeclaredInDifferentInterfaces() { TypeAnalysis analysis = new TypeAnalysis(IdentifiedBean.class); Assert.assertEquals(3, analysis.getAbstractGetters().size()); Assert.assertEquals(3, analysis.getAbstractSetters().size()); Assert.assertEquals(1, analysis.getAbstractMethods().size()); Assert.assertEquals(0, analysis.getConcreteGetters().size()); Assert.assertEquals(0, analysis.getConcreteSetters().size()); Assert.assertEquals(0, analysis.concreteMethods.size()); Assert.assertEquals(3, analysis.allProperties.size()); Assert.assertEquals(0, analysis.getOddProperties().size()); Assert.assertEquals(0, analysis.getOddPropertiesNames().size()); Assert.assertEquals(0, analysis.oddPropertiesByName.size()); }
/** Unit test for constructor on concrete class. */ @Test public void testConstructor_onConcreteTypeThatOverridesItsSupertype() { TypeAnalysis analysis = new TypeAnalysis(Range.class); Assert.assertEquals(0, analysis.getAbstractGetters().size()); Assert.assertEquals(0, analysis.getAbstractSetters().size()); Assert.assertEquals(0, analysis.getAbstractMethods().size()); Assert.assertEquals(2, analysis.getConcreteGetters().size()); Assert.assertEquals(2, analysis.getConcreteSetters().size()); Assert.assertEquals( OBJECT_METHODS_COUNT + COMPARABLE_METHODS_COUNT + 3, analysis.concreteMethods.size()); Assert.assertEquals(2, analysis.allProperties.size()); Assert.assertEquals(0, analysis.getOddProperties().size()); Assert.assertEquals(0, analysis.getOddPropertiesNames().size()); Assert.assertEquals(0, analysis.oddPropertiesByName.size()); }
/** Unit test for constructor on concrete class. */ @Test public void testConstructor_onExtendedAbstractClass() { TypeAnalysis analysis = new TypeAnalysis(AbstractExtendedSampleInterfaceImpl.class); Assert.assertEquals(AbstractExtendedSampleInterfaceImpl.class, analysis.clazz); Assert.assertEquals(5, analysis.getAbstractGetters().size()); Assert.assertEquals(5, analysis.getAbstractSetters().size()); Assert.assertEquals(2, analysis.getAbstractMethods().size()); Assert.assertEquals(1, analysis.getConcreteGetters().size()); Assert.assertEquals(1, analysis.getConcreteSetters().size()); Assert.assertEquals(OBJECT_METHODS_COUNT + 1, analysis.concreteMethods.size()); Assert.assertEquals(0, analysis.getOddProperties().size()); Assert.assertEquals(0, analysis.getOddPropertiesNames().size()); Assert.assertNull(analysis.getAllFieldsByName("field1")); Assert.assertEquals(6, analysis.allProperties.size()); Assert.assertEquals(0, analysis.oddPropertiesByName.size()); }
/** Unit test for constructor on interface. */ @Test public void testConstructor_onInterfaceWithAllTypesOfPropertyNames() { TypeAnalysis analysis = new TypeAnalysis(IBeanWithAllTypesOfPropertyNames.class); Assert.assertEquals(IBeanWithAllTypesOfPropertyNames.class, analysis.clazz); Assert.assertEquals(4, analysis.getAbstractGetters().size()); Assert.assertEquals(4, analysis.getAbstractSetters().size()); Assert.assertEquals(0, analysis.getAbstractMethods().size()); Assert.assertEquals(0, analysis.getConcreteGetters().size()); Assert.assertEquals(0, analysis.getConcreteSetters().size()); Assert.assertEquals(0, analysis.concreteMethods.size()); Assert.assertEquals(0, analysis.getOddProperties().size()); Assert.assertEquals(0, analysis.getOddPropertiesNames().size()); Assert.assertNull(analysis.getAllFieldsByName("beanName")); Assert.assertEquals(4, analysis.allProperties.size()); Assert.assertEquals(0, analysis.oddPropertiesByName.size()); Assert.assertNotNull(analysis.annotatedFields); Assert.assertEquals(0, analysis.annotatedFields.size()); }