1   package com.sri.common.controller;
2   
3   import java.util.HashMap;
4   import com.jcorporate.expresso.core.controller.Controller;
5   import com.jcorporate.expresso.core.controller.ExpressoRequest;
6   import com.jcorporate.expresso.core.controller.Transition;
7   import com.jcorporate.expresso.services.controller.DBMaint;
8   import com.jcorporate.expresso.services.dbobj.MimeTypes;
9   import com.jcorporate.expresso.services.test.ControllerTestFixture;
10  import junit.framework.TestCase;
11  
12  /***
13   *
14   * @author Michael Rimov
15   * @version 1.0
16   */
17  public class TestControllerUtil extends TestCase {
18      ControllerTestFixture controllerTestFixture = null;
19  
20  
21      protected void setUp() throws Exception {
22          super.setUp();
23          controllerTestFixture = new ControllerTestFixture();
24          controllerTestFixture.setUp();
25      }
26  
27      protected void tearDown() throws Exception {
28          super.tearDown();
29          controllerTestFixture.tearDown();
30          controllerTestFixture = null;
31      }
32  
33      public void testGenerateReflextiveTransition() throws Exception {
34          Controller dbMaint = controllerTestFixture.buildController(DBMaint.class);
35          assert dbMaint != null;
36          HashMap params = new HashMap();
37          params.put("dbobj", MimeTypes.class.getName());
38          ExpressoRequest controllerRequest = controllerTestFixture.buildControllerRequest( params, "List");
39  
40          Transition result = ControllerUtil.generateReflextiveTransition(controllerRequest.getAllParameters(),DBMaint.class, "List");
41          assertEquals(DBMaint.class.getName(), result.getControllerObject());
42          assertEquals("List", result.getState());
43          assertEquals(MimeTypes.class.getName(), result.getParam("dbobj"));
44      }
45  
46  }