use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class ExtensibleDynamicObjectTest method additionalObjectMethodsAreInherited.
@Test
public void additionalObjectMethodsAreInherited() {
Bean other = new Bean();
Convention convention = other.extensibleDynamicObject.getConvention();
convention.getPlugins().put("convention", new ConventionBean());
Bean bean = new Bean();
bean.extensibleDynamicObject.addObject(other.getAsDynamicObject(), ExtensibleDynamicObject.Location.BeforeConvention);
DynamicObject inherited = bean.getInheritable();
assertTrue(inherited.hasMethod("conventionMethod", "a", "b"));
assertThat(inherited.invokeMethod("conventionMethod", "a", "b"), equalTo((Object) "convention:a.b"));
}
use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class ExtensibleDynamicObjectTest method canInvokeMethodsOnGroovyObjectFromGroovy.
@Test
public void canInvokeMethodsOnGroovyObjectFromGroovy() {
GroovyBean bean = new GroovyBean();
Convention convention = bean.extensibleDynamicObject.getConvention();
convention.getPlugins().put("bean", new ConventionBean());
new ExtensibleDynamicObjectTestHelper().assertCanCallMethods(bean);
}
use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class ExtensibleDynamicObjectTest method conventionPropertyTakesPrecedenceOverParentProperty.
@Test
public void conventionPropertyTakesPrecedenceOverParentProperty() {
Bean parent = new Bean();
parent.defineProperty("conventionProperty", "parent");
Bean bean = new Bean();
bean.setParent(parent.getAsDynamicObject());
Convention convention = bean.extensibleDynamicObject.getConvention();
ConventionBean conventionBean = new ConventionBean();
conventionBean.setConventionProperty("value");
convention.getPlugins().put("test", conventionBean);
assertThat(bean.getProperty("conventionProperty"), equalTo((Object) "value"));
}
use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class ExtensibleDynamicObjectTest method parentMethodsAreInherited.
@Test
public void parentMethodsAreInherited() {
Bean parent = new Bean();
Convention convention = parent.extensibleDynamicObject.getConvention();
convention.getPlugins().put("convention", new ConventionBean());
Bean bean = new Bean();
bean.setParent(parent.getAsDynamicObject());
DynamicObject inherited = bean.getInheritable();
assertTrue(inherited.hasMethod("conventionMethod", "a", "b"));
assertThat(inherited.invokeMethod("conventionMethod", "a", "b"), equalTo((Object) "convention:a.b"));
}
use of org.gradle.api.plugins.Convention in project gradle by gradle.
the class ExtensibleDynamicObjectTest method inheritedConventionPropertiesTrackChanges.
@Test
public void inheritedConventionPropertiesTrackChanges() {
Bean bean = new Bean();
DynamicObject inherited = bean.getInheritable();
assertFalse(inherited.hasProperty("conventionProperty"));
Convention convention = bean.extensibleDynamicObject.getConvention();
ConventionBean conventionBean = new ConventionBean();
conventionBean.setConventionProperty("value");
convention.getPlugins().put("convention", conventionBean);
assertTrue(inherited.hasProperty("conventionProperty"));
assertThat(inherited.getProperty("conventionProperty"), equalTo((Object) "value"));
}
Aggregations