01: package org.vraptor.plugin.hibernate;
02:
03: import org.hibernate.validator.NotNull;
04: import org.vraptor.AbstractTest;
05: import org.vraptor.component.DefaultLogicMethod;
06: import org.vraptor.component.InvalidComponentException;
07: import org.vraptor.component.LogicMethod;
08: import org.vraptor.component.LogicNotFoundException;
09:
10: public class HibernateComponentTest extends AbstractTest {
11:
12: public static class HouseLogic {
13: @SuppressWarnings("unused")
14: @NotNull
15: private Long id1;
16:
17: @SuppressWarnings("unused")
18: @NotNull
19: private Long id2;
20:
21: @Validate(fields={"id1","id2"})
22: public void action() {
23:
24: }
25:
26: public void noValidation() {
27:
28: }
29: }
30:
31: public void testFindsALogicWithValidation()
32: throws InvalidComponentException, LogicNotFoundException {
33: HibernateComponent component = new HibernateComponent(registry
34: .getComponentManager().getComponentType(
35: HouseLogic.class), new ValidatorLocator());
36: LogicMethod logic = component.getLogic("action");
37: assertEquals(HibernateLogicMethod.class, logic.getClass());
38: }
39:
40: public void testFindsALogicWithoutValidation()
41: throws InvalidComponentException, LogicNotFoundException {
42: HibernateComponent component = new HibernateComponent(registry
43: .getComponentManager().getComponentType(
44: HouseLogic.class), new ValidatorLocator());
45: LogicMethod logic = component.getLogic("noValidation");
46: assertEquals(DefaultLogicMethod.class, logic.getClass());
47: }
48:
49: }
|