Search in sources :

Example 31 with Binding

use of org.apache.tapestry5.Binding in project tapestry-5 by apache.

the class PropBindingFactoryTest method method_not_found_in_terminal.

@Test
public void method_not_found_in_terminal() {
    TargetBean bean = new TargetBean();
    ComponentResources resources = mockComponentResources();
    Location l = mockLocation();
    train_getComponent(resources, bean);
    replay();
    try {
        factory.newBinding("test binding", resources, null, "stringHolder.isThatRealBlood()", l);
        unreachable();
    } catch (RuntimeException ex) {
        assertMessageContains(ex, "StringHolder", "does not contain a public method", "isThatRealBlood()");
    }
    verify();
}
Also used : ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Example 32 with Binding

use of org.apache.tapestry5.Binding in project tapestry-5 by apache.

the class PropBindingFactoryTest method read_only_property.

@Test
public void read_only_property() {
    TargetBean bean = new TargetBean();
    ComponentResources resources = newComponentResources(bean);
    Location l = mockLocation();
    replay();
    Binding binding = factory.newBinding("test binding", resources, null, "readOnly", l);
    assertEquals(binding.get(), "ReadOnly");
    try {
        binding.set("fail");
        unreachable();
    } catch (TapestryException ex) {
        assertEquals(ex.getMessage(), "Expression 'readOnly' for class org.apache.tapestry5.internal.bindings.TargetBean is read-only.");
        assertEquals(ex.getLocation(), l);
    }
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Example 33 with Binding

use of org.apache.tapestry5.Binding in project tapestry-5 by apache.

the class PropBindingFactoryTest method object_property.

@Test
public void object_property() {
    TargetBean bean = new TargetBean();
    ComponentResources resources = newComponentResources(bean);
    Location l = mockLocation();
    replay();
    Binding binding = factory.newBinding("test binding", resources, null, "objectValue", l);
    assertSame(binding.getBindingType(), String.class);
    bean.setObjectValue("first");
    assertEquals(binding.get(), "first");
    binding.set("second");
    assertEquals(bean.getObjectValue(), "second");
    assertEquals(InternalUtils.locationOf(binding), l);
    assertEquals(binding.toString(), "PropBinding[test binding foo.Bar:baz(objectValue)]");
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Example 34 with Binding

use of org.apache.tapestry5.Binding in project tapestry-5 by apache.

the class PropBindingFactoryTest method property_path_through_missing_property.

@Test
public void property_path_through_missing_property() {
    TargetBean bean = new TargetBean();
    ComponentResources resources = mockComponentResources();
    Location l = mockLocation();
    train_getComponent(resources, bean);
    replay();
    String propertyPath = "stringHolder.missingProperty.terminalProperty";
    try {
        factory.newBinding("test binding", resources, null, propertyPath, l);
        unreachable();
    } catch (RuntimeException ex) {
        assertMessageContains(ex, "Class org.apache.tapestry5.internal.bindings.StringHolder does not contain a property", "\'missingProperty\'");
    }
    verify();
}
Also used : ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Example 35 with Binding

use of org.apache.tapestry5.Binding in project tapestry-5 by apache.

the class PropBindingFactoryTest method annotation_from_write_only_property.

@Test
public void annotation_from_write_only_property() {
    TargetBean bean = new TargetBean();
    ComponentResources resources = newComponentResources(bean);
    Location l = mockLocation();
    replay();
    Binding binding = factory.newBinding("test binding", resources, null, "writeOnly", l);
    assertEquals(binding.getAnnotation(Validate.class).value(), "writeonly");
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Aggregations

Binding (com.google.iam.v1.Binding)71 Policy (com.google.iam.v1.Policy)68 Test (org.junit.Test)51 AbstractMessage (com.google.protobuf.AbstractMessage)47 Test (org.testng.annotations.Test)38 Binding (org.apache.tapestry5.Binding)34 ComponentResources (org.apache.tapestry5.ComponentResources)33 SetIamPolicyRequest (com.google.iam.v1.SetIamPolicyRequest)30 Location (org.apache.tapestry5.commons.Location)30 GetIamPolicyRequest (com.google.iam.v1.GetIamPolicyRequest)26 ResourceName (com.google.api.resourcenames.ResourceName)20 ByteString (com.google.protobuf.ByteString)20 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)12 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)10 BindingFactory (org.apache.tapestry5.services.BindingFactory)10 Component (org.apache.tapestry5.runtime.Component)8 CryptoKeyName (com.google.cloud.kms.v1.CryptoKeyName)6 KeyManagementServiceClient (com.google.cloud.kms.v1.KeyManagementServiceClient)6 InternalPropBinding (org.apache.tapestry5.internal.bindings.InternalPropBinding)6 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)6