@Test public void testAttributesC() { IBindableDescriptor descriptor = BindableDescriptorUtils.getDescriptor(C.class); Map<String, AttributeInfo> attributesByKey = descriptor.getAttributesByKey(); // static attributes assertTrue(attributesByKey.containsKey("a")); assertTrue(attributesByKey.containsKey("c")); // 'd' is a nested bindable, its attributes are collected dynamically at runtime. assertFalse(attributesByKey.containsKey("d")); }
/* * http://issues.carrot2.org/browse/CARROT-734 */ @Test public void testInputOutputGettersSetters() { IBindableDescriptor descriptor = BindableDescriptorUtils.getDescriptor(OutputAttributeCheck.class); Class<?> builder = getNestedClass(descriptor.getClass(), "AttributeBuilder"); assertNotNull(getMethod(builder, "in", int.class)); assertNotNull(getMethod(builder, "inout", int.class)); assertNotNull("Expected getter for inout", getMethod(builder, "inout")); assertNotNull("Expected getter for out", getMethod(builder, "out")); assertNull("Unexpected setter for out", getMethod(builder, "out", int.class)); assertNotNull(getMethod(builder, "inRef", A.class)); assertNotNull(getMethod(builder, "inRef", Class.class)); assertNotNull(getMethod(builder, "inoutRef", A.class)); assertNotNull(getMethod(builder, "inoutRef", Class.class)); assertNotNull("Expected getter for inoutRef", getMethod(builder, "inoutRef")); assertNotNull("Expected getter for outRef", getMethod(builder, "outRef")); assertNull("Unexpected setter for outRef", getMethod(builder, "outRef", A.class)); assertNull(getMethod(builder, "outRef", Class.class)); }
@Test public void testOwnAttributesC() { IBindableDescriptor descriptor = BindableDescriptorUtils.getDescriptor(C.class); assertEquals(descriptor.getOwnAttributes().size(), 1); }
@Test public void testKeyInKeyCheck() { IBindableDescriptor descriptor = BindableDescriptorUtils.getDescriptor(KeyCheck.class); Map<String, AttributeInfo> attributesByKey = descriptor.getAttributesByKey(); assertTrue(attributesByKey.containsKey(AttributeUtils.getKey(KeyCheck.class, "field"))); }