PageRenderTime 34ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/jira-project/jira-functional-tests/jira-func-tests/src/main/java/com/atlassian/jira/functest/framework/navigation/BulkChangeWizard.java

https://bitbucket.org/ahmed_bilal_360factors/jira7-core
Java | 309 lines | 72 code | 33 blank | 204 comment | 0 complexity | d74711f61c5cd780f394e94d750ee088 MD5 | raw file
Possible License(s): Apache-2.0
  1. package com.atlassian.jira.functest.framework.navigation;
  2. import java.util.EnumSet;
  3. /**
  4. * Interface for working with the Bulk Change Wizard which is part of the Issue Navigator.
  5. * <p/>
  6. * Promotes a "fluent-style" of usage by returning the stateful object as the result of each operation.
  7. * <p/>
  8. * Stateful. Not injected into test classes.
  9. * <p/>
  10. *
  11. * @see IssueNavigatorNavigation#bulkChange(com.atlassian.jira.functest.framework.navigation.IssueNavigatorNavigation.BulkChangeOption)
  12. * @since v4.2
  13. */
  14. public interface BulkChangeWizard {
  15. /**
  16. * States that the wizard can be in.
  17. */
  18. enum WizardState {
  19. SELECT_ISSUES(1, "Choose Issues"),
  20. CHOOSE_OPERATION(2, "Choose Operation"),
  21. CHOOSE_TARGET_CONTEXTS(3, "Operation Details"),
  22. SET_FIELDS(3, "Operation Details"),
  23. CONFIRMATION(4, "Confirmation"),
  24. COMPLETE(5, null);
  25. public static EnumSet<WizardState> valuesWithLinks() {
  26. return EnumSet.complementOf(EnumSet.of(COMPLETE));
  27. }
  28. private final int stage;
  29. private final String linkText;
  30. WizardState(final int stage, final String linkText) {
  31. this.stage = stage;
  32. this.linkText = linkText;
  33. }
  34. public int getStage() {
  35. return stage;
  36. }
  37. public String getLinkText() {
  38. return linkText;
  39. }
  40. }
  41. interface BulkOperations {
  42. String getRadioValue();
  43. }
  44. /**
  45. * Various operations available in the bulk change wizard.
  46. */
  47. enum BulkOperationsImpl implements BulkOperations {
  48. MOVE("bulk.move.operation.name"),
  49. EDIT("bulk.edit.operation.name"),
  50. TRANSITION("bulk.workflowtransition.operation.name"),
  51. DELETE("bulk.delete.operation.name");
  52. private final String radioValue;
  53. private BulkOperationsImpl(final String radioValue) {
  54. this.radioValue = radioValue;
  55. }
  56. /**
  57. * @return the value of the radio option that corresponds with this operation.
  58. */
  59. public String getRadioValue() {
  60. return radioValue;
  61. }
  62. }
  63. class BulkOperationsCustom implements BulkOperations {
  64. private final String radioValue;
  65. public BulkOperationsCustom(String radioValue) {
  66. this.radioValue = radioValue;
  67. }
  68. @Override
  69. public String getRadioValue() {
  70. return radioValue;
  71. }
  72. }
  73. /**
  74. * Types of inputs for the editing controls in a Bulk Change Wizard form
  75. */
  76. enum InputTypes {
  77. TEXT, SELECT
  78. }
  79. /**
  80. * Selects all issues from the last search to operate on.
  81. * <p/>
  82. * Wizard must be in {@link BulkChangeWizard.WizardState#SELECT_ISSUES} to perform this operation.
  83. * <p/>
  84. * Once selected, the wizard will advance to {@link BulkChangeWizard.WizardState#CHOOSE_OPERATION}.
  85. *
  86. * @return the wizard
  87. */
  88. BulkChangeWizard selectAllIssues();
  89. /**
  90. * Select the bulk operation to perform.
  91. * <p/>
  92. * Wizard must be in {@link BulkChangeWizard.WizardState#CHOOSE_OPERATION} to perform this operation.
  93. * <p/>
  94. * Once selected, the wizard will advance to {@link BulkChangeWizard.WizardState#CHOOSE_TARGET_CONTEXTS}.
  95. *
  96. * @param operation the operation to perform
  97. * @return the wizard
  98. */
  99. BulkChangeWizard chooseOperation(BulkOperations operation);
  100. /**
  101. * Select the workflow transition to perform.
  102. * <p/>
  103. * Wizard must be in {@link BulkChangeWizard.WizardState#CHOOSE_OPERATION} to perform this operation.
  104. * <p/>
  105. * Once selected, the wizard will advance
  106. *
  107. * @param workflowTransition
  108. * @return
  109. */
  110. BulkChangeWizard chooseWorkflowTransition(BulkOperations workflowTransition);
  111. /**
  112. * Chooses the target project for all issues to be moved to. The target issue type will remain as the default selected
  113. * item. This target context will apply to all issues being moved.
  114. * <p/>
  115. * <strong>WARN:</strong> note that this only currently works when you are moving issues from Homosapien project,
  116. * and when that is the only source project context offered on the page.
  117. * <p/>
  118. * Wizard must be in {@link BulkOperationsImpl#MOVE}, {@link BulkChangeWizard.WizardState#CHOOSE_TARGET_CONTEXTS} to
  119. * perform this operation.
  120. * <p/>
  121. * Once selected, the wizard will advance to {@link BulkChangeWizard.WizardState#SET_FIELDS}.
  122. *
  123. * @param projectName the name of the project to use in the target context e.g. <code>monkey</code>
  124. * @return the wizard
  125. */
  126. BulkChangeWizard chooseTargetContextForAll(String projectName);
  127. /**
  128. * Chooses the target project and issue type for all issues to be moved to. The target issue type will remain as the default selected
  129. * item. This target context will apply to all issues being moved.
  130. * <p/>
  131. * <strong>WARN:</strong> note that this only currently works when you are moving issues from Homosapien project,
  132. * and when that is the only source project context offered on the page.
  133. * <p/>
  134. * Wizard must be in {@link BulkOperationsImpl#MOVE}, {@link BulkChangeWizard.WizardState#CHOOSE_TARGET_CONTEXTS} to
  135. * perform this operation.
  136. * <p/>
  137. * Once selected, the wizard will advance to {@link BulkChangeWizard.WizardState#SET_FIELDS}.
  138. *
  139. * @param projectName the name of the project to use in the target context e.g. <code>monkey</code>
  140. * @return the wizard
  141. */
  142. BulkChangeWizard chooseTargetContextForAll(String projectName, String issueType);
  143. /**
  144. * Chooses the target project to be moved to for each of the issue types to be moved. This target context will
  145. * apply to all issues being moved, preserving issue types mapping.
  146. * <p/>
  147. * <strong>WARN:</strong> note that this only currently works when you are moving issues from Homosapien project,
  148. * and when that is the only source project context offered on the page.
  149. * <p/>
  150. * Wizard must be in {@link BulkOperationsImpl#MOVE}, {@link BulkChangeWizard.WizardState#CHOOSE_TARGET_CONTEXTS} to
  151. * perform this operation.
  152. * <p/>
  153. * Once selected, the wizard will advance to {@link BulkChangeWizard.WizardState#SET_FIELDS}.
  154. *
  155. * @param projectName the name of the project to use in the target context e.g. <code>monkey</code>
  156. * @param numContextsToSelect the expected number of contexts to be set.
  157. * @return the wizard
  158. */
  159. BulkChangeWizard chooseTargetContextForEach(int numContextsToSelect, String projectName);
  160. /**
  161. * Set a value for a field. It is assumed that the field is settable via text input.
  162. * <p/>
  163. * Wizard must be in {@link BulkChangeWizard.WizardState#SET_FIELDS} to perform this operation.
  164. * <p/>
  165. * Note: wizard does not advance after this operation; multiple calls to this method can be made. Once finished, call
  166. * {@link #finaliseFields()}.
  167. *
  168. * @param fieldName the name of the field to set e.g. <code>components</code>, <code>timetracking_originalestimate</code>
  169. * @param value the value to set e.g. <code>10000</code>, <code>5h</code>
  170. * @return the wizard
  171. * @see #finaliseFields()
  172. * @see #setFieldValue(com.atlassian.jira.functest.framework.navigation.BulkChangeWizard.InputTypes, String, String)
  173. */
  174. BulkChangeWizard setFieldValue(String fieldName, String value);
  175. /**
  176. * Set a value for a field.
  177. * <p/>
  178. * Wizard must be in {@link BulkChangeWizard.WizardState#SET_FIELDS} to perform this operation.
  179. * <p/>
  180. * Note: wizard does not advance after this operation; multiple calls to this method can be made. Once finished, call
  181. * {@link #finaliseFields()}.
  182. *
  183. * @param inputType the type of control you are using to set the field value
  184. * @param fieldName the name of the field to set e.g. <code>components</code>, <code>timetracking_originalestimate</code>
  185. * @param value the value to set e.g. <code>10000</code>, <code>5h</code>
  186. * @return the wizard
  187. * @see #finaliseFields()
  188. */
  189. BulkChangeWizard setFieldValue(InputTypes inputType, String fieldName, String value);
  190. /**
  191. * Check the "Retain" checkbox for the chosen field.
  192. * <p/>
  193. * Wizard must be in {@link BulkOperationsImpl#MOVE}, {@link BulkChangeWizard.WizardState#SET_FIELDS} to perform this operation.
  194. * <p/>
  195. * Note: wizard does not advance after this operation; multiple calls to this method can be made. Once finished, call
  196. * {@link #finaliseFields()}.
  197. *
  198. * @param fieldName the name of the field
  199. * @return the wizard
  200. */
  201. BulkChangeWizard checkRetainForField(String fieldName);
  202. /**
  203. * Check the "Action" checkbox for the chosen field.
  204. * <p/>
  205. * Wizard must be in {@link BulkOperationsImpl#EDIT}, {@link BulkChangeWizard.WizardState#SET_FIELDS} to perform this operation.
  206. * <p/>
  207. * Note: wizard does not advance after this operation; multiple calls to this method can be made. Once finished, call
  208. * {@link #finaliseFields()}.
  209. *
  210. * @param fieldName the name of the field
  211. * @return the wizard
  212. */
  213. BulkChangeWizard checkActionForField(String fieldName);
  214. /**
  215. * Completes the entering of fields in this screen.
  216. * <p/>
  217. * Wizard must be in {@link BulkChangeWizard.WizardState#SET_FIELDS} to perform this operation.
  218. * <p/>
  219. * If there are more field screens to complete, the wizard will remain in {@link BulkChangeWizard.WizardState#SET_FIELDS}.
  220. * Otherwise, it will advance to {@link BulkChangeWizard.WizardState#CONFIRMATION}.
  221. *
  222. * @return the wizard
  223. */
  224. BulkChangeWizard finaliseFields();
  225. /**
  226. * Completes the wizard and performs the bulk operation.
  227. * <p/>
  228. * Wizard must be in {@link BulkChangeWizard.WizardState#CONFIRMATION} to perform this operation.
  229. * <p/>
  230. * Once performed, the wizard will advance to {@link BulkChangeWizard.WizardState#COMPLETE}. There is no further
  231. * state to advance to after this. This wizard instance should not be used again.
  232. *
  233. * @return the wizard
  234. */
  235. BulkChangeWizard complete();
  236. /**
  237. * Waits until the bulk changes are completed.
  238. * <p>
  239. * Wizard must be in {@link com.atlassian.jira.functest.framework.navigation.BulkChangeWizard.WizardState#COMPLETE} state to
  240. * perform this operation.
  241. * </p>
  242. * <p>
  243. * This operation doesn't change the wizard state.
  244. * </p>
  245. *
  246. * @return the wizard
  247. */
  248. BulkChangeWizard waitForBulkChangeCompletion();
  249. /**
  250. * Reverts the wizard to any given previous stage.
  251. * <p/>
  252. * Wizard must be in any state that is further than the requested state.
  253. * <p/>
  254. * Once performed, wizard will revert to the desired state.
  255. *
  256. * @return the wizard.
  257. */
  258. BulkChangeWizard revertTo(WizardState state);
  259. /**
  260. * Cancels the wizard. Simulates clicking on the cancel link.
  261. * <p/>
  262. * Wizard must be in any state except {@link BulkChangeWizard.WizardState#COMPLETE}.
  263. * <p/>
  264. * Once performed the wizard will set itself to state {@link BulkChangeWizard.WizardState#COMPLETE}.
  265. *
  266. * @return the wizard.
  267. * @see #complete()
  268. */
  269. BulkChangeWizard cancel();
  270. /**
  271. * Returns the current state of the wizard.
  272. *
  273. * @return the state of the wizard.
  274. */
  275. WizardState getState();
  276. }