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.CompositeAction; 23 24 29 public class CompositeActionImplTest extends ActionImplTest 30 { 31 private static final String ACTION1_ID = "action1Id"; 32 private static final String ACTION2_ID = "action2Id"; 33 private static final String ACTION3_ID = "action3Id"; 34 private static final String ACTION1_NAME = "actionName1"; 35 private static final String ACTION2_NAME = "actionName1"; 36 private static final String ACTION3_NAME = "actionName3"; 37 38 public void testActions() 39 { 40 Action action1 = new ActionImpl(ACTION1_ID, ACTION1_NAME, null); 41 Action action2 = new ActionImpl(ACTION2_ID, ACTION2_NAME, null); 42 Action action3 = new ActionImpl(ACTION3_ID, ACTION3_NAME, null); 43 44 CompositeAction compositeAction = new CompositeActionImpl(ID, null); 45 46 assertFalse(compositeAction.hasActions()); 48 List <Action> noActions = compositeAction.getActions(); 49 assertNotNull(noActions); 50 assertEquals(0, noActions.size()); 51 52 compositeAction.addAction(action1); 54 compositeAction.addAction(action2); 55 compositeAction.addAction(action3); 56 57 assertTrue(compositeAction.hasActions()); 59 List <Action> actions = compositeAction.getActions(); 60 assertNotNull(actions); 61 assertEquals(3, actions.size()); 62 int counter = 0; 63 for (Action action : actions) 64 { 65 if (counter == 0) 66 { 67 assertEquals(action1, action); 68 } 69 else if (counter == 1) 70 { 71 assertEquals(action2, action); 72 } 73 else if (counter == 2) 74 { 75 assertEquals(action3, action); 76 } 77 counter+=1; 78 } 79 assertEquals(action1, compositeAction.getAction(0)); 80 assertEquals(action2, compositeAction.getAction(1)); 81 assertEquals(action3, compositeAction.getAction(2)); 82 83 compositeAction.removeAction(action3); 85 assertEquals(2, compositeAction.getActions().size()); 86 87 compositeAction.setAction(1, action3); 89 assertEquals(action1, compositeAction.getAction(0)); 90 assertEquals(action3, compositeAction.getAction(1)); 91 92 assertEquals(0, compositeAction.indexOfAction(action1)); 94 assertEquals(1, compositeAction.indexOfAction(action3)); 95 96 compositeAction.addAction(1, action2); 98 assertEquals(3, compositeAction.getActions().size()); 99 assertEquals(action1, compositeAction.getAction(0)); 100 assertEquals(action2, compositeAction.getAction(1)); 101 assertEquals(action3, compositeAction.getAction(2)); 102 103 compositeAction.removeAllActions(); 105 assertFalse(compositeAction.hasActions()); 106 assertEquals(0, compositeAction.getActions().size()); 107 } 108 } 109 | Popular Tags |