KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > model > repository > test > TestValidator


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.model.repository.test;
8
9
10 import java.util.Map JavaDoc;
11
12 import junit.framework.Assert;
13
14 import com.inversoft.verge.mvc.controller.Action;
15 import com.inversoft.verge.mvc.validator.Validator;
16 import com.inversoft.verge.repository.test.SimpleItem;
17 import com.inversoft.verge.util.WebBeanProperty;
18
19
20 /**
21  * <p>
22  * This class is a test validator
23  * </p>
24  *
25  * @author Brian Pontarelli
26  * @since 2.0
27  * @version 2.0
28  */

29 public class TestValidator implements Validator {
30
31     public static boolean conversion = false;
32
33
34     /**
35      * Constructor for TestValidator.
36      */

37     public TestValidator() {
38         super();
39     }
40     
41
42     /**
43      * Does nothing right now
44      */

45     public boolean validate(Map JavaDoc modelObjects, Action action) {
46         return false;
47     }
48
49     /**
50      * This gets caled by the model handler
51      */

52     public void handleConversion(Object JavaDoc model, WebBeanProperty property,
53             Action action) {
54         conversion = true;
55         Assert.assertTrue("model should be instance of SimpleItem", model instanceof SimpleItem);
56         Assert.assertTrue("property should be integer", property.getPropertyName().equals("age"));
57         Assert.assertTrue("property should be integer", property.getPropertyType() == Integer JavaDoc.class);
58         Assert.assertTrue("RequestContext should never be null", action.getRequestContext() != null);
59     }
60 }
61
Popular Tags