Document toolboxDocument toolbox

Developer Best Practices

Development Practice

Follow the same procedure as described in the Synapse-Services-Repository Developer Best Practices

Read about GWT Development with Activities and Places

Use SafeHtml

Read this document on use of SafeHtml in GWT and adhere strictly to the contracts described. Apply true escaping methods to any user-generated value in the system.  

Testing

See the general Synapse testing philosophy on the Synapse-Services-Repository Developer Best Practices page.

Specifics For GWT Testing

  • Put all business logic into Presenters and make them JRE testable (aka JUnit). 
    • This means that Presenters can not deal with class instances that rely upon GWT.create(...) calls. For the rare case when this is necessary, create a GWTTestCase. Be aware that these tests take significant time to spin up.
    • The philosophy of our architecture and this testing technique is described here
  • To mock callbacks, such as with RPC services, use AsyncMockStubber's static methods. 

    // Example call onSuccess(..)
    AsyncMockStubber.callSuccessWith("Result Object").when(mockService).getSomething(eq("someInputParam"), any(AsyncCallback.class)); 
     
    // Example call onFailure(..)
    AsyncMockStubber.callFailureWith(new Throwable("error message")).when(mockService).getSomething(eq("someInputParam"), any(AsyncCallback.class));