1 package com.sri.emo.wizard.wizardgateway;
2
3 import java.util.HashMap;
4 import java.util.Map;
5 import com.jcorporate.expresso.core.controller.ControllerException;
6 import com.jcorporate.expresso.core.controller.ExpressoResponse;
7 import com.jcorporate.expresso.core.db.DBException;
8 import com.jcorporate.expresso.services.test.ControllerTestFixture;
9 import com.jcorporate.expresso.services.test.TestSystemInitializer;
10 import com.sri.emo.controller.SelectionWizardManager;
11 import com.sri.emo.test.DatabaseTestFixture;
12 import com.sri.emo.test.EmoTestSuite;
13 import com.sri.emo.wizard.expressoimpl.WizardController;
14 import org.jmock.MockObjectTestCase;
15
16 /***
17 * Test for edit wizard redirection.
18 *
19 * @author Michael Rimov
20 * @version 1.0
21 */
22 public class TestEditWizard extends MockObjectTestCase {
23
24 /***
25 * DBUnit wrapping test fixture.
26 */
27 private DatabaseTestFixture databaseTestFixture;
28
29 /***
30 * Controller test fixture. Used for invoking controllers.
31 */
32 private ControllerTestFixture testFixture;
33
34 protected void setUp() throws Exception {
35 databaseTestFixture = new DatabaseTestFixture(TestSystemInitializer.getTestContext(),
36 EmoTestSuite.class.getResourceAsStream("WizardTestData.xml"));
37 databaseTestFixture.setUp();
38
39
40 testFixture = new ControllerTestFixture();
41 testFixture.setUp();
42 }
43
44 protected void tearDown() throws Exception {
45 databaseTestFixture.tearDown();
46 databaseTestFixture = null;
47
48 testFixture.tearDown();
49 testFixture = null;
50 super.tearDown();
51 }
52
53 public void testNoWizardIdParameterThrowsException() throws Exception {
54 try {
55 testFixture.invokeFacade(WizardGatewayController.class, new HashMap(), EditWizard.STATE_NAME);
56 fail("Should have thrown controller exception.");
57 } catch (ControllerException ex) {
58
59 assertNotNull(ex.getMessage());
60 }
61 }
62
63 public void testSelectionWizardEditTransitionsToSelectionManager() throws DBException, ControllerException {
64 Map params = new HashMap();
65 params.put(WizardController.WIZ_PARAMETER_ID,Integer.toString(DatabaseTestFixture.DEFAULT_WIZ_ID));
66
67 ExpressoResponse response = testFixture.invokeFacade(WizardGatewayController.class, params, EditWizard.STATE_NAME);
68 assertTrue(response != null);
69 assertTrue(response.getErrors() == null || response.getErrors().size() == 0);
70 assertTrue(SelectionWizardManager.class.getName().equals(response.getControllerClass()));
71 }
72
73 public void testCompletionWizardTransitionsToCompletionManager() throws DBException, ControllerException {
74 /***
75 * @todo Complete Me.
76 */
77 }
78
79 }