use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method parentPropertiesAreInherited.
@Test
public void parentPropertiesAreInherited() {
Bean parent = new Bean();
parent.defineProperty("parentProperty", "value");
Bean bean = new Bean();
bean.setParent(parent.getAsDynamicObject());
DynamicObject inherited = bean.getInheritable();
assertTrue(inherited.hasProperty("parentProperty"));
assertThat(inherited.getProperty("parentProperty"), equalTo((Object) "value"));
assertThat(inherited.getProperties().get("parentProperty"), equalTo((Object) "value"));
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method extraPropertiesAreInherited.
@Test
public void extraPropertiesAreInherited() {
Bean bean = new Bean();
bean.defineProperty("additional", "value");
DynamicObject inherited = bean.getInheritable();
assertTrue(inherited.hasProperty("additional"));
assertThat(inherited.getProperty("additional"), equalTo((Object) "value"));
assertThat(inherited.getProperties().get("additional"), equalTo((Object) "value"));
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method cannotSetInheritedProperties.
@Test
public void cannotSetInheritedProperties() {
Bean bean = new Bean();
bean.defineProperty("additional", "value");
DynamicObject inherited = bean.getInheritable();
try {
inherited.setProperty("additional", "new value");
fail();
} catch (MissingPropertyException e) {
assertThat(e.getMessage(), equalTo("Could not find property 'additional' inherited from <bean>."));
}
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method otherMethodsAreNotInherited.
@Test
public void otherMethodsAreNotInherited() {
Bean bean = new Bean();
assertTrue(bean.hasMethod("javaMethod", "a", "b"));
DynamicObject inherited = bean.getInheritable();
assertFalse(inherited.hasMethod("javaMethod", "a", "b"));
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method additionalObjectPropertiesAreInherited.
@Test
public void additionalObjectPropertiesAreInherited() {
Bean other = new Bean();
other.defineProperty("other", "value");
Bean bean = new Bean();
bean.extensibleDynamicObject.addObject(other.getAsDynamicObject(), ExtensibleDynamicObject.Location.BeforeConvention);
DynamicObject inherited = bean.getInheritable();
assertTrue(inherited.hasProperty("other"));
assertThat(inherited.getProperty("other"), equalTo((Object) "value"));
assertThat(inherited.getProperties().get("other"), equalTo((Object) "value"));
}
Aggregations