1 17 package org.alfresco.repo.action; 18 19 import java.util.List ; 20 21 import org.alfresco.service.cmr.action.Action; 22 import org.alfresco.service.cmr.action.ActionCondition; 23 import org.alfresco.util.GUID; 24 25 28 public class ActionImplTest extends BaseParameterizedItemImplTest 29 { 30 private static final String ID_COND1 = "idCond1"; 31 private static final String ID_COND2 = "idCond2"; 32 private static final String ID_COND3 = "idCond3"; 33 private static final String NAME_COND1 = "nameCond1"; 34 private static final String NAME_COND2 = "nameCond2"; 35 private static final String NAME_COND3 = "nameCond3"; 36 37 40 @Override 41 protected ParameterizedItemImpl create() 42 { 43 return new ActionImpl( 44 ID, 45 NAME, 46 null, 47 this.paramValues); 48 } 49 50 public void testGetRuleActionDefintion() 51 { 52 Action temp = (Action)create(); 53 assertEquals(NAME, temp.getActionDefinitionName()); 54 } 55 56 public void testSimpleProperties() 57 { 58 Action action = (Action)create(); 59 60 assertFalse(action.getExecuteAsychronously()); 62 assertNull(action.getCompensatingAction()); 63 64 action.setTitle("title"); 66 action.setDescription("description"); 67 action.setExecuteAsynchronously(true); 68 Action compensatingAction = new ActionImpl(GUID.generate(), "actionDefintionName", null); 69 action.setCompensatingAction(compensatingAction); 70 71 assertEquals("title", action.getTitle()); 73 assertEquals("description", action.getDescription()); 74 assertTrue(action.getExecuteAsychronously()); 75 assertEquals(compensatingAction, action.getCompensatingAction()); 76 } 77 78 public void testActionConditions() 79 { 80 ActionCondition cond1 = new ActionConditionImpl(ID_COND1, NAME_COND1, this.paramValues); 81 ActionCondition cond2 = new ActionConditionImpl(ID_COND2, NAME_COND2, this.paramValues); 82 ActionCondition cond3 = new ActionConditionImpl(ID_COND3, NAME_COND3, this.paramValues); 83 84 Action action = (Action)create(); 85 86 assertFalse(action.hasActionConditions()); 88 List <ActionCondition> noConditions = action.getActionConditions(); 89 assertNotNull(noConditions); 90 assertEquals(0, noConditions.size()); 91 92 action.addActionCondition(cond1); 94 action.addActionCondition(cond2); 95 action.addActionCondition(cond3); 96 97 assertTrue(action.hasActionConditions()); 99 List <ActionCondition> actionConditions = action.getActionConditions(); 100 assertNotNull(actionConditions); 101 assertEquals(3, actionConditions.size()); 102 int counter = 0; 103 for (ActionCondition condition : actionConditions) 104 { 105 if (counter == 0) 106 { 107 assertEquals(cond1, condition); 108 } 109 else if (counter == 1) 110 { 111 assertEquals(cond2, condition); 112 } 113 else if (counter == 2) 114 { 115 assertEquals(cond3, condition); 116 } 117 counter+=1; 118 } 119 assertEquals(cond1, action.getActionCondition(0)); 120 assertEquals(cond2, action.getActionCondition(1)); 121 assertEquals(cond3, action.getActionCondition(2)); 122 123 action.removeActionCondition(cond3); 125 assertEquals(2, action.getActionConditions().size()); 126 127 action.setActionCondition(1, cond3); 129 assertEquals(cond1, action.getActionCondition(0)); 130 assertEquals(cond3, action.getActionCondition(1)); 131 132 assertEquals(0, action.indexOfActionCondition(cond1)); 134 assertEquals(1, action.indexOfActionCondition(cond3)); 135 136 action.addActionCondition(1, cond2); 138 assertEquals(3, action.getActionConditions().size()); 139 assertEquals(cond1, action.getActionCondition(0)); 140 assertEquals(cond2, action.getActionCondition(1)); 141 assertEquals(cond3, action.getActionCondition(2)); 142 143 action.removeAllActionConditions(); 145 assertFalse(action.hasActionConditions()); 146 assertEquals(0, action.getActionConditions().size()); 147 } 148 } 149 | Popular Tags |