Commits

Robert Massaioli [Atlassian] committed cd9628c

CONNECT-105 - Started writing the integraton tests.

Comments (0)

Files changed (2)

src/test/java/it/RemoteUserChangeTest.java

 package it;
 
 import com.atlassian.jira.pageobjects.JiraTestedProduct;
+import com.atlassian.jira.pageobjects.pages.viewissue.ViewIssuePage;
 import com.atlassian.pageobjects.TestedProductFactory;
+import it.page.ProjectSettingsPage;
+import it.util.FakeMobileDeviceUtil;
+import junit.framework.Assert;
+
+import static junit.framework.Assert.assertEquals;
 
 /**
  * This test case is supposed to prove that you can change the remote user and give feedback successfully. You should not
 public class RemoteUserChangeTest {
     final JiraTestedProduct jira = TestedProductFactory.create(JiraTestedProduct.class);
 
+    private final static String JMC_REMOTE_USER = "jiraconnectuser";
+    private final static String ADMIN_USERNAME = "admin";
+
     public void testCreateDifferentIssuesWithDifferentRemoteUsers() {
         // Go into the project settings page and set the remote user to jiraconnectuser
         // Create some feedback and wait for the issue key to come back.
         // Go to that issue and confirm that the reporter is the remote user.
+        createFeedbackWithRemoteUser(JMC_REMOTE_USER);
 
         // Go back to the project settings page and set the remote user to admin
         // Create some feedback and wait for the issue key to come back.
         // Go to that issue and confirm that the reporter is the admin user.
+        createFeedbackWithRemoteUser(ADMIN_USERNAME);
 
         // Do the first step again to prove that you can set it back and forth.
+        createFeedbackWithRemoteUser(JMC_REMOTE_USER);
+    }
+
+    private ViewIssuePage createFeedbackWithRemoteUser(String remoteUsername) {
+        // Go into the project settings page and set the remote user to jiraconnectuser
+        setRemoteUser(remoteUsername);
+        // Create some feedback and wait for the issue key to come back.
+        final String issueKey = FakeMobileDeviceUtil.sendFeedback();
+        // Go to that issue and confirm that the reporter is the remote user.
+        final ViewIssuePage page = jira.visit(ViewIssuePage.class, issueKey);
+        assertEquals(remoteUsername, page.getPeopleSection().getReporter());
+        return page;
     }
 
     public void testCommentsByRemoteUserAndRemoteUserPersistsOnIssue() {
         // Go into the project settings and change the remote user to anybody but jiraconnectuser
         // Create some feedback and get the issue key.
         // Go to the issue and confirm that the remote user is admin.
+        createFeedbackWithRemoteUser(ADMIN_USERNAME);
         // Make a comment on the issue and confirm that the latest comment was made by admin.
         // Go back to the project settings page and change the remote user to jiraconnectuser
         // Make a comment on the issue and confirm that the latest comment was made by admin. (not jiraconnectuser)
     }
+
+    private ProjectSettingsPage setRemoteUser(final String remoteUsername) {
+        final ProjectSettingsPage page = jira.visit(ProjectSettingsPage.class);
+        page.setRemoteUserTo(remoteUsername);
+        return page;
+    }
 }

src/test/java/it/util/FakeMobileDeviceUtil.java

  * to send.
  */
 public class FakeMobileDeviceUtil {
-    public void sendFeedback() {
+    private FakeMobileDeviceUtil() {}
+
+    /**
+     * This creates a feedback item and returns the issue key.
+     * @return The issue key of the newly created feedback item.
+     */
+    public static String sendFeedback() {
+        return null;
+    }
+
+    public static void sendStacktrace() {
 
     }
 
-    public void sendStacktrace() {
-
-    }
-
-    public void sendComment() {
+    public static void sendComment() {
 
     }
 }