use of org.gradle.api.internal.provider.DefaultProviderFactory in project gradle by gradle.
the class AsmBackedClassGeneratorTest method doesNotAddSetterMethodsForPropertyWhoseTypeIsPropertyWhenTheSetterMethodsAlreadyExist.
@Test
public void doesNotAddSetterMethodsForPropertyWhoseTypeIsPropertyWhenTheSetterMethodsAlreadyExist() throws Exception {
DefaultProviderFactory providerFactory = new DefaultProviderFactory();
BeanWithProperty bean = generator.newInstance(BeanWithProperty.class, TestUtil.objectFactory());
DynamicObject dynamicObject = ((DynamicObjectAware) bean).getAsDynamicObject();
dynamicObject.setProperty("prop2", "value");
assertEquals("[value]", bean.getProp2().get());
dynamicObject.setProperty("prop2", 12);
assertEquals("[12]", bean.getProp2().get());
dynamicObject.setProperty("prop2", providerFactory.provider(new Callable<String>() {
int count;
@Override
public String call() throws Exception {
return "[" + String.valueOf(++count) + "]";
}
}));
assertEquals("[1]", bean.getProp2().get());
assertEquals("[2]", bean.getProp2().get());
}
use of org.gradle.api.internal.provider.DefaultProviderFactory in project gradle by gradle.
the class AsmBackedClassGeneratorTest method addsSetterMethodsForPropertyWhoseTypeIsProperty.
@Test
public void addsSetterMethodsForPropertyWhoseTypeIsProperty() throws Exception {
DefaultProviderFactory providerFactory = new DefaultProviderFactory();
BeanWithProperty bean = generator.newInstance(BeanWithProperty.class, TestUtil.objectFactory());
DynamicObject dynamicObject = ((DynamicObjectAware) bean).getAsDynamicObject();
dynamicObject.setProperty("prop", "value");
assertEquals("value", bean.getProp().get());
dynamicObject.setProperty("prop", providerFactory.provider(new Callable<String>() {
int count;
@Override
public String call() throws Exception {
return "[" + String.valueOf(++count) + "]";
}
}));
assertEquals("[1]", bean.getProp().get());
assertEquals("[2]", bean.getProp().get());
}
Aggregations