Search in sources :

Example 1 with Issue

use of spock.lang.Issue in project gradle by gradle.

the class AsmBackedClassGeneratorTest method appliesConventionMappingToGroovyBoolean.

@Test
@Issue("GRADLE-2163")
public void appliesConventionMappingToGroovyBoolean() throws Exception {
    BeanWithGroovyBoolean bean = generator.generate(BeanWithGroovyBoolean.class).newInstance();
    assertTrue(bean instanceof IConventionAware);
    assertThat(bean.getSmallB(), equalTo(false));
    assertThat(bean.getBigB(), nullValue());
    assertThat(bean.getMixedB(), equalTo(false));
    IConventionAware conventionAware = (IConventionAware) bean;
    conventionAware.getConventionMapping().map("smallB", new Callable<Object>() {

        public Object call() throws Exception {
            return true;
        }
    });
    assertThat(bean.isSmallB(), equalTo(true));
    assertThat(bean.getSmallB(), equalTo(true));
    bean.setSmallB(false);
    assertThat(bean.isSmallB(), equalTo(false));
    assertThat(bean.getSmallB(), equalTo(false));
    conventionAware.getConventionMapping().map("bigB", new Callable<Object>() {

        public Object call() throws Exception {
            return Boolean.TRUE;
        }
    });
    assertThat(bean.getBigB(), equalTo(Boolean.TRUE));
    bean.setBigB(Boolean.FALSE);
    assertThat(bean.getBigB(), equalTo(Boolean.FALSE));
    conventionAware.getConventionMapping().map("mixedB", new Callable<Object>() {

        public Object call() throws Exception {
            return Boolean.TRUE;
        }
    });
    assertThat(bean.getMixedB(), equalTo(true));
    assertThat(bean.isMixedB(), equalTo(Boolean.TRUE));
}
Also used : BeanWithGroovyBoolean(org.gradle.api.internal.AbstractClassGeneratorTestGroovy.BeanWithGroovyBoolean) BeanDynamicObject(org.gradle.internal.metaobject.BeanDynamicObject) GroovyObject(groovy.lang.GroovyObject) DslObject(org.gradle.api.internal.plugins.DslObject) DynamicObject(org.gradle.internal.metaobject.DynamicObject) MissingMethodException(groovy.lang.MissingMethodException) ObjectInstantiationException(org.gradle.internal.reflect.ObjectInstantiationException) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException) Issue(spock.lang.Issue) Test(org.junit.Test)

Aggregations

GroovyObject (groovy.lang.GroovyObject)1 MissingMethodException (groovy.lang.MissingMethodException)1 IOException (java.io.IOException)1 GradleException (org.gradle.api.GradleException)1 BeanWithGroovyBoolean (org.gradle.api.internal.AbstractClassGeneratorTestGroovy.BeanWithGroovyBoolean)1 DslObject (org.gradle.api.internal.plugins.DslObject)1 BeanDynamicObject (org.gradle.internal.metaobject.BeanDynamicObject)1 DynamicObject (org.gradle.internal.metaobject.DynamicObject)1 ObjectInstantiationException (org.gradle.internal.reflect.ObjectInstantiationException)1 Test (org.junit.Test)1 Issue (spock.lang.Issue)1