def testItShouldSetArgumentsOfInvoke(self):
        factory = self.factory.invoke(987654321, "myMethod")
        factory.setArguments(
            [ReflectedType.fromNative(5, reflector=None), ReflectedType.fromNative("aString", reflector=None)]
        )
        message = factory.builder

        assert message.reflection_request.invoke.argument[0].type == Message.Argument.PRIMITIVE
        assert message.reflection_request.invoke.argument[0].primitive.type == Message.Primitive.INT
        assert message.reflection_request.invoke.argument[0].primitive.int == 5
        assert message.reflection_request.invoke.argument[1].type == Message.Argument.STRING
        assert message.reflection_request.invoke.argument[1].string == "aString"
    def testItShouldSetArgumentsOfInvoke(self):
        factory = self.factory.invoke(987654321, "myMethod")
        factory.setArguments([
            ReflectedType.fromNative(5, reflector=None),
            ReflectedType.fromNative("aString", reflector=None)
        ])
        message = factory.builder

        assert message.reflection_request.invoke.argument[
            0].type == Message.Argument.PRIMITIVE
        assert message.reflection_request.invoke.argument[
            0].primitive.type == Message.Primitive.INT
        assert message.reflection_request.invoke.argument[0].primitive.int == 5
        assert message.reflection_request.invoke.argument[
            1].type == Message.Argument.STRING
        assert message.reflection_request.invoke.argument[
            1].string == "aString"
Example #3
0
    def arg(self, native, obj_type=None):
        """
        Utility method to build a ReflectedType from a native value.

        This should be used to force an object to assume a particular data type
        in Java.
        """

        return ReflectedType.fromNative(native, reflector=self.__reflector, obj_type=obj_type)
    def testItShouldBuildASetPropertyMessage(self):
        message = self.factory.setProperty(987654321, "myProperty", ReflectedType.fromNative(5, reflector=None)).builder

        assert message.type == Message.REFLECTION_REQUEST
        assert message.reflection_request.type == Message.ReflectionRequest.SET_PROPERTY
        assert message.reflection_request.set_property.object.reference == 987654321
        assert message.reflection_request.set_property.property == "myProperty"
        assert message.reflection_request.set_property.value.type == Message.Argument.PRIMITIVE
        assert message.reflection_request.set_property.value.primitive.type == Message.Primitive.INT
        assert message.reflection_request.set_property.value.primitive.int == 5
    def testItShouldBuildASetPropertyMessage(self):
        message = self.factory.setProperty(
            987654321, "myProperty",
            ReflectedType.fromNative(5, reflector=None)).builder

        assert message.type == Message.REFLECTION_REQUEST
        assert message.reflection_request.type == Message.ReflectionRequest.SET_PROPERTY
        assert message.reflection_request.set_property.object.reference == 987654321
        assert message.reflection_request.set_property.property == "myProperty"
        assert message.reflection_request.set_property.value.type == Message.Argument.PRIMITIVE
        assert message.reflection_request.set_property.value.primitive.type == Message.Primitive.INT
        assert message.reflection_request.set_property.value.primitive.int == 5