Sunday, March 13, 2016

Test your Business Logic with AMTester (BC4J Tester) in Oracle ADF

     This blog describes how to use the Application Module Tester provided in JDeveloper to test all your business logic. This will let the developer to run, debug and test all the business logic before the designers have worked on Client UI. Also, Model developers don’t have to wait until UI developers finish their job and to report issues in model layer. This reduces the dependency.

     I feel it as a best practice to do in each project. AMTester starts up really fast when compared with full UI web application and it speeds up the debugging time.

     In this blog, I plan to show how to test View Object, View Link, View Criteria and Service Methods. In-order to demo these, I had built a sample workspace in JDeveloper 11.1.7.1.0 using the default HR schema in Oracle DB. Below is what I have in my test Model project and the Application Module definition.


     As you see above, I added EmployeeVO to EmployeeAM. Also, added DepartmentVO and JobsVO to EmployeeVO through view links I created. Also, defined one new service method on EmployeeAM and made it available to Client UI’s. To do so, navigated to Java tab of EmployeeAM definition and shuttled it. Now AM definition is like below.

     Also, defined one new View Criteria on EmployeeVO to return all employees whose first name starts with what user inputs. VC definition is like below.

     Now, let’s proceed testing these...

     Right click on EmployeeAM in Application Navigator window, and chose Run/Debug to run/debug the AMTester respectively as shown below.

     As mentioned earlier, AMTester UI comes up fast and it appears like below.


     To test service methods, right click on EmployeeAM and click Show. EmployeeAM tab appears in right side region. The Method drop down lists all the service methods exposed to client UI. Choose the method you want to test and click on Execute button by providing the input parameters. Result and Return values are shown in the bottom of the page.


     To test View Object, right click on Employee VO instance and click Show. This shows the record by record view of the data. Choose ‘Show Table’ option to view the data in a tabular format. Use right or left arrow marks to move forward or backward in the data set. Click + to insert new VO row. Click X icon remove a row. Click tick icon to validate the data before committing it to DB. You can explore the other options.


     Observe, Find option in above screen print. Click on this option to test View Criteria. Now the screen appears like below.

     
     Shuttle the EmployeeVOCriteria from Available section to Selected Section and click Find button at the bottom. A small popup appears with the list of Bind Variables for which you need to provide input values.

 

     Once value is provided, click OK. Employees whose first name starts with s are listed like below.


     To test View Link, right click on the view links say EmployeeVOToDepartmentVO, EmployeeVOToJobsVO and click Show. It shows both Parent and related Child Objects data together as shown below.

 

     This may not look as much to you, but the advantage of the Application Module Tester is that you can debug the code in the application module methods or view object operation easily. You can set needed variables when calling the methods and use the outcome of the operations in calls to other operations. This way you can easily test the whole business logic without the need to have an UI present.


Thank you for reading through!!!

1 comment: