Oscar Bou created ISIS-405:
------------------------------

             Summary: Clearer messages for Validation exceptions including 
field or parameter name and class/action name
                 Key: ISIS-405
                 URL: https://issues.apache.org/jira/browse/ISIS-405
             Project: Isis
          Issue Type: Improvement
          Components: Core
    Affects Versions: core-1.1.0
         Environment: Testing against the 1.0.2 quickstart prototype.
            Reporter: Oscar Bou
            Assignee: Dan Haywood


The following exception message is shown when a mandatory field is not entered 
(trace shown generated from a JUnit viewer test):

org.apache.isis.progmodel.wrapper.applib.InvalidException: Mandatory
        at 
org.apache.isis.progmodel.wrapper.metamodel.internal.DomainObjectInvocationHandler.toException(DomainObjectInvocationHandler.java:561)
        at 
org.apache.isis.progmodel.wrapper.metamodel.internal.DomainObjectInvocationHandler.notifyListenersAndVetoIfRequired(DomainObjectInvocationHandler.java:533)
        at 
org.apache.isis.progmodel.wrapper.metamodel.internal.DomainObjectInvocationHandler.handleActionMethod(DomainObjectInvocationHandler.java:483)
        at 
org.apache.isis.progmodel.wrapper.metamodel.internal.DomainObjectInvocationHandler.invoke(DomainObjectInvocationHandler.java:225)
        at 
org.apache.isis.progmodel.wrapper.metamodel.internal.InvocationHandlerMethodInterceptor.intercept(InvocationHandlerMethodInterceptor.java:37)
        at 
com.xms.framework.architecture.domain.model.technology.NodeFactory$$EnhancerByCGLIB$$a0559340.createNode(<generated>)
        at 
com.xms.framework.architecture.domain.model.technology.tests.NodeTest.testDomainEntity_CreateWithEmptyString(NodeTest.java:295)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
        at 
org.apache.isis.viewer.junit.IsisTestRunner$1.invoke(IsisTestRunner.java:160)
        at 
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:107)
        at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:88)
        at 
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96)
        at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
        at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
        at 
org.apache.isis.viewer.junit.IsisTestRunner.invokeTestMethod(IsisTestRunner.java:124)
        at 
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:61)
        at 
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:54)
        at 
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
        at 
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
        at 
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:52)
        at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
        at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)




It will be a commonly found exception while testing and debugging. 
This exception will be raised , for example, if a programmer forget to annotate 
a field, or if he's migrating its source code from another framework (so by 
default none of the Domain class properties will be annotated as @Optional). 
Same will happen for non-mandatory parameters on actions placed on Entities or 
Services.

A clearer message for Domain Object property validations could be something 
similar to this :

"A Mandatory field (%s) has not been entered for an instance of Class: %s."

And for action parameters something similar to:

"A mandatory parameter (%s) has not been entered while executing action '%s' on 
an instance of Class '%s'"

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to