PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/java/com/atlassian/jira/plugins/bitbucket/pageobjects/page/BitBucketConfigureRepositoriesPage.java

https://bitbucket.org/atlassian/jira-bitbucket-connector/
Java | 120 lines | 68 code | 17 blank | 35 comment | 0 complexity | 72e1151bad6d5a33c2ddf77043e0fb6b MD5 | raw file
  1. package com.atlassian.jira.plugins.bitbucket.pageobjects.page;
  2. import org.hamcrest.Matchers;
  3. import org.hamcrest.core.IsEqual;
  4. import org.openqa.selenium.By;
  5. import com.atlassian.pageobjects.elements.ElementBy;
  6. import com.atlassian.pageobjects.elements.Options;
  7. import com.atlassian.pageobjects.elements.PageElement;
  8. import com.atlassian.pageobjects.elements.query.Poller;
  9. /**
  10. * Represents the page to link repositories to projects
  11. */
  12. public class BitBucketConfigureRepositoriesPage extends BaseConfigureRepositoriesPage
  13. {
  14. @ElementBy(id = "bbUsername")
  15. PageElement bbUsernameInput;
  16. @ElementBy(id = "bbPassword")
  17. PageElement bbPasswordInput;
  18. /**
  19. * Links a public repository to the given JIRA project
  20. *
  21. * @param projectKey The JIRA project key
  22. * @param url The url to the bitucket public repo
  23. * @param adminUsername username used to install the service (postcommit hook)
  24. * @param adminPassword password used to install the service (postcommit hook)
  25. * @return BitBucketConfigureRepositoriesPage
  26. */
  27. @Override
  28. public String addPublicRepoToProjectAndInstallService(String projectKey, String url, String adminUsername,
  29. String adminPassword)
  30. {
  31. urlTextbox.clear().type(url);
  32. projectSelect.select(Options.value(projectKey));
  33. addRepositoryButton.click();
  34. Poller.waitUntil(addedRepositoryH2.timed().getText(), IsEqual.equalTo("New Bitbucket repository"));
  35. // postcommit hook
  36. addPostCommitServiceCheckbox.click();
  37. adminUsernameTextbox.clear().type(adminUsername);
  38. adminPasswordTextbox.clear().type(adminPassword);
  39. // add
  40. addRepositoryButton.click();
  41. checkSyncProcessSuccess();
  42. return addedRepositoryIdSpan.timed().getValue().byDefaultTimeout();
  43. }
  44. /**
  45. * Links a public repository to the given JIRA project
  46. *
  47. * @param projectKey The JIRA project key
  48. * @param url The url to the bitucket public repo
  49. * @return BitBucketConfigureRepositoriesPage
  50. */
  51. @Override
  52. public BaseConfigureRepositoriesPage addPublicRepoToProjectSuccessfully(String projectKey, String url)
  53. {
  54. projectSelect.select(Options.value(projectKey));
  55. urlTextbox.clear().type(url);
  56. addRepositoryButton.click();
  57. Poller.waitUntil(addedRepositoryH2.timed().getText(), IsEqual.equalTo("New Bitbucket repository"));
  58. addRepositoryButton.click();
  59. checkSyncProcessSuccess();
  60. return this;
  61. }
  62. /**
  63. * Links a public repository to the given JIRA project
  64. *
  65. * @param projectKey The JIRA project key
  66. * @param url The url to the bitucket public repo
  67. * @return BitBucketConfigureRepositoriesPage
  68. */
  69. @Override
  70. public BitBucketConfigureRepositoriesPage addRepoToProjectFailingStep1(String projectKey, String url)
  71. {
  72. projectSelect.select(Options.value(projectKey));
  73. urlTextbox.clear().type(url);
  74. addRepositoryButton.click();
  75. Poller.waitUntilTrue("Expected Error message while connecting repository", messageBarDiv.find(By.tagName("strong")).timed().hasText("Error!"));
  76. return this;
  77. }
  78. @Override
  79. public BaseConfigureRepositoriesPage addRepoToProjectFailingStep2(String projectKey, String url)
  80. {
  81. return this;
  82. }
  83. /**
  84. * Links a public repository to the given JIRA project
  85. *
  86. * @param projectKey The JIRA project key
  87. * @param url The url to the bitucket public repo
  88. * @return BitBucketConfigureRepositoriesPage
  89. */
  90. @Override
  91. public BitBucketConfigureRepositoriesPage addPrivateRepoToProjectSuccessfully(String projectKey, String url)
  92. {
  93. projectSelect.select(Options.value(projectKey));
  94. urlTextbox.clear().type(url);
  95. addRepositoryButton.click();
  96. Poller.waitUntil(addedRepositoryH2.timed().getText(), IsEqual.equalTo("New Bitbucket repository"));
  97. bbUsernameInput.type("jirabitbucketconnector");
  98. bbPasswordInput.type("jirabitbucketconnector");
  99. addRepositoryButton.click();
  100. checkSyncProcessSuccess();
  101. return this;
  102. }
  103. }