/**
  * Method setUp - Sets up the fixture, for example, open a network connection. This method is
  * called before a test is executed.
  *
  * @throws java.lang.Exception
  */
 @Override
 @Before
 public void setUp() throws Exception {
   fProxy = R4EUITestMain.getInstance();
   createReviewGroups();
   if (((ReviewNavigatorActionGroup) R4EUIModelController.getNavigatorView().getActionSet())
       .isHideDeltasFilterSet()) {
     fProxy.getCommandProxy().toggleHideDeltasFilter();
   }
 }
  /** Method verifyHelp */
  public void verifyHelp() {

    // Verify R4E help is present
    URL openUrl =
        fProxy.getHelp(
            "/org.eclipse.mylyn.reviews.r4e.help/help/Reviews/R4E/User_Guide/User-Guide.html");
    Assert.assertNotNull(openUrl);

    URL ericssonUrl = fProxy.getHelp("/com.ericsson.reviews.r4e.help/doc/r4eEricsson.html");
    Assert.assertNotNull(ericssonUrl);
  }
  /** Method progressLinkedAnomalies */
  private void progressLinkedAnomalies() {
    Assert.assertNotNull(fLinkedAnomaly);
    fProxy.getAnomalyProxy().progressAnomaly(fLinkedAnomaly, TestConstants.ANOMALY_STATE_FIXED);

    Assert.assertEquals(TestConstants.ANOMALY_STATE_FIXED, fLinkedAnomaly.getAnomaly().getState());
    Assert.assertFalse(
        fProxy
            .getCommandProxy()
            .verifyAnnotation(fLinkedAnomaly, true, R4EUIConstants.ANOMALY_OPEN_ANNOTATION_ID));
    Assert.assertTrue(
        fProxy
            .getCommandProxy()
            .verifyAnnotation(fLinkedAnomaly, true, R4EUIConstants.ANOMALY_CLOSED_ANNOTATION_ID));
  }
 /** Method createLinkedAnomalies */
 private void createLinkedAnomalies() {
   R4EUIContent content =
       fItem
           .getFileContexts()
           .get(fAnomalyFileIndex)
           .getContentsContainerElement()
           .getContentsList()
           .get(0);
   fLinkedAnomaly =
       fProxy
           .getAnomalyProxy()
           .createLinkedAnomaly(
               content,
               TestConstants.LINKED_ANOMALY_TEST_TITLE,
               TestConstants.LINKED_ANOMALY_TEST_DESCRIPTION,
               TestConstants.ANOMALY_TEST_CLASS_IMPROVEMENT,
               TestConstants.ANOMALY_TEST_RANK_MAJOR,
               TestConstants.ANOMALY_TEST_DUE_DATE,
               TestConstants.PARTICIPANT_ASSIGN_TO,
               null);
   Assert.assertNotNull(fLinkedAnomaly);
   Assert.assertEquals(
       TestConstants.LINKED_ANOMALY_TEST_TITLE, fLinkedAnomaly.getAnomaly().getTitle());
   Assert.assertEquals(
       TestConstants.LINKED_ANOMALY_TEST_DESCRIPTION,
       fLinkedAnomaly.getAnomaly().getDescription());
   Assert.assertEquals(
       TestConstants.ANOMALY_TEST_CLASS_IMPROVEMENT,
       ((R4ECommentType) fLinkedAnomaly.getAnomaly().getType()).getType());
   Assert.assertEquals(
       TestConstants.ANOMALY_TEST_RANK_MAJOR, fLinkedAnomaly.getAnomaly().getRank());
   Assert.assertEquals(
       TestConstants.ANOMALY_TEST_DUE_DATE, fLinkedAnomaly.getAnomaly().getDueDate());
   Assert.assertEquals(
       TestConstants.PARTICIPANT_ASSIGN_TO, fLinkedAnomaly.getAnomaly().getAssignedTo().get(0));
   Assert.assertEquals(
       ((R4EUITextPosition) content.getPosition()).getOffset(),
       ((R4ETextPosition)
               ((R4ETextContent) fLinkedAnomaly.getAnomaly().getLocations().get(0)).getLocation())
           .getStartPosition());
   Assert.assertEquals(
       ((R4EUITextPosition) content.getPosition()).getLength(),
       ((R4ETextPosition)
               ((R4ETextContent) fLinkedAnomaly.getAnomaly().getLocations().get(0)).getLocation())
           .getLength());
   Assert.assertTrue(
       fProxy
           .getCommandProxy()
           .verifyAnnotation(fLinkedAnomaly, true, R4EUIConstants.ANOMALY_OPEN_ANNOTATION_ID));
 }
 /** Method createEditorAnomalies */
 private void createCompareEditorAnomalies() {
   fCompareEditorAnomaly =
       fProxy
           .getAnomalyProxy()
           .createCompareEditorAnomaly(
               fItem.getFileContexts().get(fAnomalyFileIndex),
               20,
               50,
               TestConstants.COMPARE_EDITOR_ANOMALY_TEST_TITLE,
               TestConstants.COMPARE_EDITOR_ANOMALY_TEST_DESCRIPTION,
               TestConstants.ANOMALY_TEST_CLASS_ERRONEOUS,
               TestConstants.ANOMALY_TEST_RANK_MINOR,
               TestConstants.ANOMALY_TEST_DUE_DATE,
               TestConstants.PARTICIPANT_ASSIGN_TO,
               null);
   Assert.assertNotNull(fCompareEditorAnomaly);
   Assert.assertEquals(
       TestConstants.COMPARE_EDITOR_ANOMALY_TEST_TITLE,
       fCompareEditorAnomaly.getAnomaly().getTitle());
   Assert.assertEquals(
       TestConstants.COMPARE_EDITOR_ANOMALY_TEST_DESCRIPTION,
       fCompareEditorAnomaly.getAnomaly().getDescription());
   Assert.assertEquals(
       TestConstants.ANOMALY_TEST_CLASS_ERRONEOUS,
       ((R4ECommentType) fCompareEditorAnomaly.getAnomaly().getType()).getType());
   Assert.assertEquals(
       TestConstants.ANOMALY_TEST_RANK_MINOR, fCompareEditorAnomaly.getAnomaly().getRank());
   Assert.assertEquals(
       TestConstants.ANOMALY_TEST_DUE_DATE, fCompareEditorAnomaly.getAnomaly().getDueDate());
   Assert.assertEquals(
       TestConstants.PARTICIPANT_ASSIGN_TO,
       fCompareEditorAnomaly.getAnomaly().getAssignedTo().get(0));
   Assert.assertEquals(
       20,
       ((R4ETextPosition)
               ((R4ETextContent) fCompareEditorAnomaly.getAnomaly().getLocations().get(0))
                   .getLocation())
           .getStartPosition());
   Assert.assertEquals(
       50,
       ((R4ETextPosition)
               ((R4ETextContent) fCompareEditorAnomaly.getAnomaly().getLocations().get(0))
                   .getLocation())
           .getLength());
   Assert.assertTrue(
       fProxy
           .getCommandProxy()
           .verifyAnnotation(
               fCompareEditorAnomaly, true, R4EUIConstants.ANOMALY_OPEN_ANNOTATION_ID));
 }
 /** Method createExternalAnomalies */
 private void createExternalAnomalies() {
   fExternalAnomaly =
       fProxy
           .getAnomalyProxy()
           .createExternalAnomaly(
               TestUtils.FJavaFile3,
               TestConstants.EXTERNAL_ANOMALY_TEST_TITLE,
               TestConstants.EXTERNAL_ANOMALY_TEST_DESCRIPTION,
               TestConstants.ANOMALY_TEST_CLASS_QUESTION,
               TestConstants.ANOMALY_TEST_RANK_MINOR,
               TestConstants.ANOMALY_TEST_DUE_DATE,
               TestConstants.PARTICIPANT_ASSIGN_TO,
               null);
   Assert.assertNotNull(fExternalAnomaly);
   Assert.assertEquals(
       TestConstants.EXTERNAL_ANOMALY_TEST_TITLE, fExternalAnomaly.getAnomaly().getTitle());
   Assert.assertEquals(
       TestConstants.EXTERNAL_ANOMALY_TEST_DESCRIPTION,
       fExternalAnomaly.getAnomaly().getDescription());
   Assert.assertEquals(
       TestConstants.ANOMALY_TEST_CLASS_QUESTION,
       ((R4ECommentType) fExternalAnomaly.getAnomaly().getType()).getType());
   Assert.assertEquals(
       TestConstants.ANOMALY_TEST_RANK_MINOR, fExternalAnomaly.getAnomaly().getRank());
   Assert.assertEquals(
       TestConstants.ANOMALY_TEST_DUE_DATE, fExternalAnomaly.getAnomaly().getDueDate());
   Assert.assertEquals(
       TestConstants.PARTICIPANT_ASSIGN_TO, fExternalAnomaly.getAnomaly().getAssignedTo().get(0));
   Assert.assertEquals(
       0,
       ((R4ETextPosition)
               ((R4ETextContent) fExternalAnomaly.getAnomaly().getLocations().get(0))
                   .getLocation())
           .getStartPosition());
   Assert.assertEquals(
       755,
       ((R4ETextPosition)
               ((R4ETextContent) fExternalAnomaly.getAnomaly().getLocations().get(0))
                   .getLocation())
           .getLength());
   Assert.assertTrue(
       fProxy
           .getCommandProxy()
           .verifyAnnotation(fExternalAnomaly, false, R4EUIConstants.ANOMALY_OPEN_ANNOTATION_ID));
 }
  /** Method createReviews */
  private void createReviews() {
    // Update Review Group handle
    for (IR4EUIModelElement elem : R4EUIModelController.getRootElement().getChildren()) {
      if (fGroupName.equals(elem.getName())) {
        fGroup = (R4EUIReviewGroup) elem;
      }
    }
    if (!fGroup.isOpen()) {
      fProxy.getCommandProxy().openElement(fGroup);
    }
    Assert.assertTrue(fGroup.isOpen());

    fReview =
        fProxy
            .getReviewProxy()
            .createReview(
                fGroup,
                TestConstants.REVIEW_TEST_TYPE_INFORMAL,
                TestConstants.REVIEW_TEST_NAME_INF,
                TestConstants.REVIEW_TEST_DESCRIPTION,
                TestConstants.REVIEW_TEST_DUE_DATE,
                TestConstants.REVIEW_TEST_PROJECT,
                TestConstants.REVIEW_TEST_COMPONENTS,
                TestConstants.REVIEW_TEST_ENTRY_CRITERIA,
                TestConstants.REVIEW_TEST_OBJECTIVES,
                TestConstants.REVIEW_TEST_REFERENCE_MATERIALS);
    Assert.assertNotNull(fReview);
    Assert.assertNotNull(fReview.getParticipantContainer());
    Assert.assertNotNull(fReview.getAnomalyContainer());
    Assert.assertEquals(TestConstants.REVIEW_TEST_TYPE_INFORMAL, fReview.getReview().getType());
    Assert.assertEquals(TestConstants.REVIEW_TEST_NAME_INF, fReview.getReview().getName());
    Assert.assertEquals(TestConstants.REVIEW_TEST_DESCRIPTION, fReview.getReview().getExtraNotes());
    Assert.assertEquals(TestConstants.REVIEW_TEST_DUE_DATE, fReview.getReview().getDueDate());
    Assert.assertEquals(TestConstants.REVIEW_TEST_PROJECT, fReview.getReview().getProject());
    for (int i = 0; i < TestConstants.REVIEW_TEST_COMPONENTS.length; i++) {
      Assert.assertEquals(
          TestConstants.REVIEW_TEST_COMPONENTS[i], fReview.getReview().getComponents().get(i));
    }
    Assert.assertEquals(
        TestConstants.REVIEW_TEST_ENTRY_CRITERIA, fReview.getReview().getEntryCriteria());
    Assert.assertEquals(TestConstants.REVIEW_TEST_OBJECTIVES, fReview.getReview().getObjectives());
    Assert.assertEquals(
        TestConstants.REVIEW_TEST_REFERENCE_MATERIALS, fReview.getReview().getReferenceMaterial());
    Assert.assertTrue(fReview.isOpen());
  }
  /** Method progressReview */
  private void progressReview() {
    Assert.assertEquals(
        TestConstants.REVIEW_EXIT_DECISION_ACCEPTED,
        fReview.getReview().getDecision().getValue()); // Test the default exit decision

    fProxy.getReviewProxy().progressReview(fReview);
    Assert.assertEquals(
        R4EReviewPhase.COMPLETED, ((R4EReviewState) fReview.getReview().getState()).getState());
    Assert.assertNotNull(fReview.getReview().getEndDate());
  }
  /**
   * Method sendQuestionNotifications
   *
   * @throws CoreException
   */
  private void sendQuestionNotifications() throws CoreException {
    fProxy.getCommandProxy().sendQuestionNotification(fReview);
    Assert.assertEquals(
        TestConstants.SEND_QUESTION_REVIEW_TEST_SOURCE,
        fProxy.getCommandProxy().getEmailDetails().getSource());
    String[] destinations = fProxy.getCommandProxy().getEmailDetails().getDestinations();
    for (int i = 0; i < destinations.length; i++) {
      Assert.assertEquals(TestConstants.SEND_QUESTION_REVIEW_TEST_DESTINATIONS[i], destinations[i]);
    }
    Assert.assertEquals(
        TestConstants.SEND_QUESTION_REVIEW_TEST_SUBJECT_INFORMAL,
        fProxy.getCommandProxy().getEmailDetails().getSubject());
    // TODO:  Assert fails, but Strings seem to be identical???

    //		Assert.assertEquals(TestConstants.SEND_QUESTION_REVIEW_TEST_BODY_INFORMAL,
    // fProxy.getCommandProxy()
    //				.getEmailDetails()
    //				.getBody());

  }
  /** Method createReviewGroups */
  private void createReviewGroups() {

    fGroup = null;

    // Create Review Group
    for (R4EUIReviewGroup group : R4EUIModelController.getRootElement().getGroups()) {
      if (group.getReviewGroup().getName().equals(TestConstants.REVIEW_GROUP_TEST_NAME)) {
        fGroup = group;
        fGroupName = group.getName();
        break;
      }
    }
    if (null == fGroup) {
      fGroup =
          fProxy
              .getReviewGroupProxy()
              .createReviewGroup(
                  TestUtils.FSharedFolder + File.separator + TestConstants.REVIEW_GROUP_TEST_NAME,
                  TestConstants.REVIEW_GROUP_TEST_NAME,
                  TestConstants.REVIEW_GROUP_TEST_DESCRIPTION,
                  TestConstants.REVIEW_GROUP_TEST_ENTRY_CRITERIA,
                  TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS,
                  TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS,
                  new String[0]);
      Assert.assertNotNull(fGroup);
      Assert.assertEquals(TestConstants.REVIEW_GROUP_TEST_NAME, fGroup.getReviewGroup().getName());
      Assert.assertEquals(
          new Path(TestUtils.FSharedFolder).toPortableString()
              + "/"
              + TestConstants.REVIEW_GROUP_TEST_NAME,
          fGroup.getReviewGroup().getFolder());
      Assert.assertEquals(
          TestConstants.REVIEW_GROUP_TEST_DESCRIPTION, fGroup.getReviewGroup().getDescription());
      Assert.assertEquals(
          TestConstants.REVIEW_GROUP_TEST_ENTRY_CRITERIA,
          fGroup.getReviewGroup().getDefaultEntryCriteria());
      for (int i = 0; i < TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS.length; i++) {
        Assert.assertEquals(
            TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS[i],
            fGroup.getReviewGroup().getAvailableProjects().get(i));
      }
      for (int i = 0; i < TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS.length; i++) {
        Assert.assertEquals(
            TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS[i],
            fGroup.getReviewGroup().getAvailableComponents().get(i));
      }
      fGroupName = fGroup.getName();
    }
  }
 /** Method createParticipants */
 private void createParticipants() {
   List<R4EParticipant> participants = new ArrayList<R4EParticipant>(1);
   R4EParticipant participant = RModelFactory.eINSTANCE.createR4EParticipant();
   participant.setId(TestConstants.PARTICIPANT_TEST_ID);
   participant.setEmail(TestConstants.PARTICIPANT_TEST_EMAIL);
   participants.add(participant);
   fParticipant =
       fProxy
           .getParticipantProxy()
           .createParticipant(fReview.getParticipantContainer(), participants);
   Assert.assertNotNull(fParticipant);
   Assert.assertEquals(TestConstants.PARTICIPANT_TEST_ID, fParticipant.getParticipant().getId());
   Assert.assertEquals(
       TestConstants.PARTICIPANT_TEST_EMAIL, fParticipant.getParticipant().getEmail());
   Assert.assertEquals(R4EUserRole.REVIEWER, fParticipant.getParticipant().getRoles().get(0));
 }
 /** Method createComments */
 private void createComments() {
   fComment = fProxy.getCommentProxy().createComment(fLinkedAnomaly, TestConstants.COMMENT_TEST);
   Assert.assertNotNull(fComment);
   Assert.assertEquals(TestConstants.COMMENT_TEST, fComment.getComment().getDescription());
 }
Exemplo n.º 13
0
  /**
   * Method createRuleSetSetup
   *
   * @throws ExecutionException
   * @throws NotDefinedException
   * @throws NotEnabledException
   * @throws NotHandledException
   * @throws ResourceHandlingException
   * @throws OutOfSyncException
   */
  public void createRuleSetSetup() {

    // Create a Rule Set
    R4EUIRuleSet newRuleSet =
        fProxy
            .getRuleSetProxy()
            .createRuleSet(
                TestUtils.FSharedFolder,
                TestConstants.RULE_SET_TEST_NAME,
                TestConstants.RULE_SET_TEST_VERSION);
    Assert.assertNotNull(newRuleSet);
    Assert.assertEquals(TestConstants.RULE_SET_TEST_VERSION, newRuleSet.getRuleSet().getVersion());
    Assert.assertEquals(
        new Path(TestUtils.FSharedFolder).toPortableString(), newRuleSet.getRuleSet().getFolder());
    Assert.assertEquals(TestConstants.RULE_SET_TEST_NAME, newRuleSet.getRuleSet().getName());

    // Create a second Rule Set
    R4EUIRuleSet newRuleSet2 =
        fProxy
            .getRuleSetProxy()
            .createRuleSet(
                TestUtils.FSharedFolder,
                TestConstants.RULE_SET_TEST_NAME2,
                TestConstants.RULE_SET_TEST_VERSION);
    String newRuleSet2Name = newRuleSet2.getName();
    Assert.assertNotNull(newRuleSet2);
    Assert.assertEquals(TestConstants.RULE_SET_TEST_VERSION, newRuleSet2.getRuleSet().getVersion());
    Assert.assertEquals(
        new Path(TestUtils.FSharedFolder).toPortableString(), newRuleSet2.getRuleSet().getFolder());
    Assert.assertEquals(TestConstants.RULE_SET_TEST_NAME2, newRuleSet2.getRuleSet().getName());

    // Create Rule Area
    R4EUIRuleArea newRuleArea =
        fProxy.getRuleAreaProxy().createRuleArea(newRuleSet, TestConstants.RULE_AREA_TEST_NAME);
    Assert.assertNotNull(newRuleArea);
    Assert.assertEquals(TestConstants.RULE_AREA_TEST_NAME, newRuleArea.getArea().getName());

    // Create Rule Violation
    R4EUIRuleViolation newRuleViolation =
        fProxy
            .getRuleViolationProxy()
            .createRuleViolation(newRuleArea, TestConstants.RULE_VIOLATION_TEST_NAME);
    Assert.assertNotNull(newRuleViolation);
    Assert.assertEquals(
        TestConstants.RULE_VIOLATION_TEST_NAME, newRuleViolation.getViolation().getName());

    // Create Rule
    R4EUIRule newRule =
        fProxy
            .getRuleProxy()
            .createRule(
                newRuleViolation,
                TestConstants.RULE_TEST_ID,
                TestConstants.RULE_TEST_TITLE,
                TestConstants.RULE_TEST_DESCRIPTION,
                UIUtils.getClassFromString(TestConstants.RULE_TEST_CLASS),
                UIUtils.getRankFromString(TestConstants.RULE_TEST_RANK));
    Assert.assertNotNull(newRule);
    Assert.assertEquals(TestConstants.RULE_TEST_ID, newRule.getRule().getId());
    Assert.assertEquals(TestConstants.RULE_TEST_TITLE, newRule.getRule().getTitle());
    Assert.assertEquals(TestConstants.RULE_TEST_DESCRIPTION, newRule.getRule().getDescription());
    Assert.assertEquals(
        UIUtils.getClassFromString(TestConstants.RULE_TEST_CLASS), newRule.getRule().getClass_());
    Assert.assertEquals(
        UIUtils.getRankFromString(TestConstants.RULE_TEST_RANK), newRule.getRule().getRank());

    // Close a Rule Set
    fProxy.getCommandProxy().closeElement(newRuleSet);
    Assert.assertFalse(newRuleSet.isOpen());

    // Open the closed Rule Set
    fProxy.getCommandProxy().openElement(newRuleSet);
    Assert.assertTrue(newRuleSet.isOpen());
    Assert.assertEquals(
        TestConstants.RULE_TEST_ID,
        ((R4EUIRule) newRuleSet.getChildren()[0].getChildren()[0].getChildren()[0])
            .getRule()
            .getId());

    // Remove Rule Set from preferences
    String prefsRuleSet = newRuleSet2.getRuleSet().eResource().getURI().toFileString();
    fProxy.getPreferencesProxy().removeRuleSetFromPreferences(prefsRuleSet);
    for (R4EUIRuleSet ruleSet : R4EUIModelController.getRootElement().getRuleSets()) {
      if (ruleSet.getRuleSet().getName().equals(newRuleSet2.getRuleSet().getName())) {
        fail(
            "RuleSet "
                + prefsRuleSet
                + " should not be present since it was removed from preferences");
      }
    }

    // Add back Rule Set to preferences
    boolean ruleSetFound = false;
    fProxy.getPreferencesProxy().addRuleSetToPreferences(prefsRuleSet);
    for (R4EUIRuleSet ruleSet : R4EUIModelController.getRootElement().getRuleSets()) {
      if (ruleSet.getRuleSet().getName().equals(newRuleSet2.getRuleSet().getName())) {
        ruleSetFound = true;
        break;
      }
    }
    Assert.assertTrue(ruleSetFound);

    for (IR4EUIModelElement elem : R4EUIModelController.getRootElement().getChildren()) {
      if (newRuleSet2Name.equals(elem.getName())) {
        newRuleSet2 = (R4EUIRuleSet) elem;
      }
    }
    fProxy.getCommandProxy().openElement(newRuleSet2);
    Assert.assertTrue(newRuleSet2.isOpen());
  }
  /** Method createReviewItems */
  private void createReviewItems() throws CoreException {
    fItem = fProxy.getItemProxy().createCommitItem(TestUtils.FJavaIProject, 0);
    // close and re-open, so the validation takes de-serialized information
    String itemName = fItem.getName();
    fProxy.getCommandProxy().closeElement(fReview);
    fProxy.getCommandProxy().openElement(fReview);
    for (IR4EUIModelElement elem : fReview.getChildren()) {
      if (elem.getName().equals(itemName)) {
        fItem = (R4EUIReviewItem) elem;
      }
    }

    // Now validate
    Assert.assertNotNull(fItem);
    Assert.assertEquals(R4EUIModelController.getReviewer(), fItem.getItem().getAddedById());
    Assert.assertEquals("*****@*****.**", fItem.getItem().getAuthorRep());
    Assert.assertEquals("second Java Commit", fItem.getItem().getDescription());
    Assert.assertEquals(4, fItem.getChildren().length);
    for (int i = 0; i < fItem.getChildren().length; i++) {
      if (((R4EUIFileContext) fItem.getChildren()[i])
          .getName()
          .equals(TestUtils.JAVA_FILE1_PROJ_NAME)) {
        fAnomalyFileIndex = i; // Used later to add anomalies
        Assert.assertEquals(
            TestUtils.JAVA_FILE1_PROJ_NAME,
            fItem.getItem().getFileContextList().get(i).getBase().getName());
        Assert.assertEquals(
            TestUtils.JAVA_FILE1_PROJ_NAME,
            fItem.getItem().getFileContextList().get(i).getTarget().getName());
        Assert.assertEquals(
            606,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(0)
                        .getTarget()
                        .getLocation())
                .getStartPosition());
        Assert.assertEquals(
            25,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(0)
                        .getTarget()
                        .getLocation())
                .getLength());
        Assert.assertEquals(
            665,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(1)
                        .getTarget()
                        .getLocation())
                .getStartPosition());
        Assert.assertEquals(
            63,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(1)
                        .getTarget()
                        .getLocation())
                .getLength());
        Assert.assertEquals(
            733,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(2)
                        .getTarget()
                        .getLocation())
                .getStartPosition());
        Assert.assertEquals(
            61,
            ((R4ETextPosition)
                    fItem
                        .getItem()
                        .getFileContextList()
                        .get(i)
                        .getDeltas()
                        .get(2)
                        .getTarget()
                        .getLocation())
                .getLength());
        Assert.assertTrue(
            fProxy
                .getCommandProxy()
                .verifyAnnotations(
                    ((R4EUIFileContext) fItem.getChildren()[i])
                        .getContentsContainerElement()
                        .getChildren(),
                    true,
                    R4EUIConstants.DELTA_ANNOTATION_ID));
      } else if (((R4EUIFileContext) fItem.getChildren()[i])
          .getName()
          .equals(TestUtils.JAVA_FILE4_PROJ_NAME)) {
        Assert.assertNull(fItem.getItem().getFileContextList().get(i).getBase());
        Assert.assertEquals(
            TestUtils.JAVA_FILE4_PROJ_NAME,
            fItem.getItem().getFileContextList().get(i).getTarget().getName());
      } else if (((R4EUIFileContext) fItem.getChildren()[i])
          .getName()
          .equals(TestUtils.JAVA_FILE3_PROJ_NAME)) {
        Assert.assertNull(fItem.getItem().getFileContextList().get(i).getBase());
        Assert.assertEquals(
            TestUtils.JAVA_FILE3_PROJ_NAME,
            fItem.getItem().getFileContextList().get(i).getTarget().getName());
      } else if (((R4EUIFileContext) fItem.getChildren()[i])
          .getName()
          .equals(TestUtils.JAVA_FILE2_PROJ_NAME)) {
        Assert.assertEquals(
            TestUtils.JAVA_FILE2_PROJ_NAME,
            fItem.getItem().getFileContextList().get(i).getBase().getName());
        Assert.assertNull(fItem.getItem().getFileContextList().get(i).getTarget());
      }
    }

    fItem2 = fProxy.getItemProxy().createManualTreeItem(TestUtils.FJavaFile3);
    Assert.assertNotNull(fItem2);
    Assert.assertEquals(R4EUIModelController.getReviewer(), fItem2.getItem().getAddedById());
    Assert.assertEquals(
        TestUtils.JAVA_FILE3_PROJ_NAME,
        fItem2.getItem().getFileContextList().get(0).getBase().getName());
    Assert.assertEquals(
        TestUtils.JAVA_FILE3_PROJ_NAME,
        fItem2.getItem().getFileContextList().get(0).getTarget().getName());
    Assert.assertEquals(
        0,
        ((R4ETextPosition)
                fItem2
                    .getItem()
                    .getFileContextList()
                    .get(0)
                    .getDeltas()
                    .get(0)
                    .getTarget()
                    .getLocation())
            .getStartPosition());
    Assert.assertEquals(
        755,
        ((R4ETextPosition)
                fItem2
                    .getItem()
                    .getFileContextList()
                    .get(0)
                    .getDeltas()
                    .get(0)
                    .getTarget()
                    .getLocation())
            .getLength());
    Assert.assertTrue(
        fProxy
            .getCommandProxy()
            .verifyAnnotations(
                ((R4EUIFileContext) fItem2.getChildren()[0])
                    .getContentsContainerElement()
                    .getChildren(),
                false,
                R4EUIConstants.SELECTION_ANNOTATION_ID));

    fItem3 = fProxy.getItemProxy().createManualTextItem(TestUtils.FJavaFile4, 50, 20);
    Assert.assertNotNull(fItem3);
    Assert.assertEquals(R4EUIModelController.getReviewer(), fItem3.getItem().getAddedById());
    Assert.assertEquals(
        TestUtils.JAVA_FILE4_PROJ_NAME,
        fItem3.getItem().getFileContextList().get(0).getBase().getName());
    Assert.assertEquals(
        TestUtils.JAVA_FILE4_PROJ_NAME,
        fItem3.getItem().getFileContextList().get(0).getTarget().getName());
    Assert.assertEquals(
        50,
        ((R4ETextPosition)
                fItem3
                    .getItem()
                    .getFileContextList()
                    .get(0)
                    .getDeltas()
                    .get(0)
                    .getTarget()
                    .getLocation())
            .getStartPosition());
    Assert.assertEquals(
        20,
        ((R4ETextPosition)
                fItem3
                    .getItem()
                    .getFileContextList()
                    .get(0)
                    .getDeltas()
                    .get(0)
                    .getTarget()
                    .getLocation())
            .getLength());
    Assert.assertTrue(
        fProxy
            .getCommandProxy()
            .verifyAnnotations(
                ((R4EUIFileContext) fItem3.getChildren()[0])
                    .getContentsContainerElement()
                    .getChildren(),
                true,
                R4EUIConstants.SELECTION_ANNOTATION_ID));
  }
Exemplo n.º 15
0
 /**
  * Method setUp - Sets up the fixture, for example, open a network connection. This method is
  * called before a test is executed.
  *
  * @throws java.lang.Exception
  */
 @Override
 @Before
 public void setUp() throws Exception {
   fProxy = R4EUITestMain.getInstance();
 }
  /** Method verifySorters */
  public void verifySorters() {
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.ALPHA_SORTER_COMMAND));
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.REVIEW_TYPE_SORTER_COMMAND));

    // Alpha sorter On/Off
    fProxy.getCommandProxy().toggleAlphaSorter();
    ViewerComparator activeSorter = fProxy.getCommandProxy().getActiveSorter();
    Assert.assertTrue(
        null != activeSorter
            && activeSorter instanceof NavigatorElementComparator
            && !(activeSorter instanceof ReviewTypeComparator));
    Assert.assertTrue(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.ALPHA_SORTER_COMMAND));
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.REVIEW_TYPE_SORTER_COMMAND));

    fProxy.getCommandProxy().toggleAlphaSorter();
    Assert.assertTrue(null == fProxy.getCommandProxy().getActiveSorter());
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.ALPHA_SORTER_COMMAND));
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.REVIEW_TYPE_SORTER_COMMAND));

    // Review Type sorter On/Off
    fProxy.getCommandProxy().toggleReviewTypeSorter();
    activeSorter = fProxy.getCommandProxy().getActiveSorter();
    Assert.assertTrue(null != activeSorter && activeSorter instanceof ReviewTypeComparator);
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.ALPHA_SORTER_COMMAND));
    Assert.assertTrue(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.REVIEW_TYPE_SORTER_COMMAND));

    fProxy.getCommandProxy().toggleReviewTypeSorter();
    Assert.assertTrue(null == fProxy.getCommandProxy().getActiveSorter());
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.ALPHA_SORTER_COMMAND));
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.REVIEW_TYPE_SORTER_COMMAND));

    // AlphaSorter -> ReviewTypeSorter
    fProxy.getCommandProxy().toggleAlphaSorter();
    activeSorter = fProxy.getCommandProxy().getActiveSorter();
    Assert.assertTrue(
        null != activeSorter
            && activeSorter instanceof NavigatorElementComparator
            && !(activeSorter instanceof ReviewTypeComparator));
    Assert.assertTrue(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.ALPHA_SORTER_COMMAND));
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.REVIEW_TYPE_SORTER_COMMAND));

    fProxy.getCommandProxy().toggleReviewTypeSorter();
    activeSorter = fProxy.getCommandProxy().getActiveSorter();
    Assert.assertTrue(null != activeSorter && activeSorter instanceof ReviewTypeComparator);
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.ALPHA_SORTER_COMMAND));
    Assert.assertTrue(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.REVIEW_TYPE_SORTER_COMMAND));

    // ReviewTypeSorter -> AlphaSorter
    fProxy.getCommandProxy().toggleAlphaSorter();
    activeSorter = fProxy.getCommandProxy().getActiveSorter();
    Assert.assertTrue(
        null != activeSorter
            && activeSorter instanceof NavigatorElementComparator
            && !(activeSorter instanceof ReviewTypeComparator));
    Assert.assertTrue(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.ALPHA_SORTER_COMMAND));
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.REVIEW_TYPE_SORTER_COMMAND));

    // Remove AlphaSorter
    fProxy.getCommandProxy().toggleAlphaSorter();
    Assert.assertTrue(null == fProxy.getCommandProxy().getActiveSorter());
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.ALPHA_SORTER_COMMAND));
    Assert.assertFalse(
        fProxy.getCommandProxy().getCommandState(R4EUIConstants.REVIEW_TYPE_SORTER_COMMAND));
  }
Exemplo n.º 17
0
  /**
   * Method createReviewGroupSetup
   *
   * @throws ExecutionException
   * @throws NotDefinedException
   * @throws NotEnabledException
   * @throws NotHandledException
   * @throws ResourceHandlingException
   * @throws OutOfSyncException
   */
  public void createReviewGroupSetup() {

    // Create Review Group
    R4EUIReviewGroup newGroup =
        fProxy
            .getReviewGroupProxy()
            .createReviewGroup(
                TestUtils.FSharedFolder + File.separator + TestConstants.REVIEW_GROUP_TEST_NAME,
                TestConstants.REVIEW_GROUP_TEST_NAME,
                TestConstants.REVIEW_GROUP_TEST_DESCRIPTION,
                TestConstants.REVIEW_GROUP_TEST_ENTRY_CRITERIA,
                TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS,
                TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS,
                new String[0]);
    Assert.assertNotNull(newGroup);
    Assert.assertEquals(TestConstants.REVIEW_GROUP_TEST_NAME, newGroup.getReviewGroup().getName());
    Assert.assertEquals(
        new Path(TestUtils.FSharedFolder).toPortableString()
            + "/"
            + TestConstants.REVIEW_GROUP_TEST_NAME,
        newGroup.getReviewGroup().getFolder());
    Assert.assertEquals(
        TestConstants.REVIEW_GROUP_TEST_DESCRIPTION, newGroup.getReviewGroup().getDescription());
    Assert.assertEquals(
        TestConstants.REVIEW_GROUP_TEST_ENTRY_CRITERIA,
        newGroup.getReviewGroup().getDefaultEntryCriteria());
    for (int i = 0; i < TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS.length; i++) {
      Assert.assertEquals(
          TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS[i],
          newGroup.getReviewGroup().getAvailableProjects().get(i));
    }
    for (int i = 0; i < TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS.length; i++) {
      Assert.assertEquals(
          TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS[i],
          newGroup.getReviewGroup().getAvailableComponents().get(i));
    }
    String newGroupName = newGroup.getName();

    // Create a second Review Group
    R4EUIReviewGroup newGroup2 =
        fProxy
            .getReviewGroupProxy()
            .createReviewGroup(
                TestUtils.FSharedFolder + File.separator + TestConstants.REVIEW_GROUP_TEST_NAME2,
                TestConstants.REVIEW_GROUP_TEST_NAME2,
                TestConstants.REVIEW_GROUP_TEST_DESCRIPTION,
                TestConstants.REVIEW_GROUP_TEST_ENTRY_CRITERIA,
                TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS,
                TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS,
                new String[0]);
    Assert.assertNotNull(newGroup2);
    Assert.assertEquals(
        TestConstants.REVIEW_GROUP_TEST_NAME2, newGroup2.getReviewGroup().getName());
    Assert.assertEquals(
        new Path(TestUtils.FSharedFolder).toPortableString()
            + "/"
            + TestConstants.REVIEW_GROUP_TEST_NAME2,
        newGroup2.getReviewGroup().getFolder());
    Assert.assertEquals(
        TestConstants.REVIEW_GROUP_TEST_DESCRIPTION, newGroup2.getReviewGroup().getDescription());
    Assert.assertEquals(
        TestConstants.REVIEW_GROUP_TEST_ENTRY_CRITERIA,
        newGroup2.getReviewGroup().getDefaultEntryCriteria());
    for (int i = 0; i < TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS.length; i++) {
      Assert.assertEquals(
          TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS[i],
          newGroup2.getReviewGroup().getAvailableProjects().get(i));
    }
    for (int i = 0; i < TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS.length; i++) {
      Assert.assertEquals(
          TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS[i],
          newGroup2.getReviewGroup().getAvailableComponents().get(i));
    }

    // Close a Review Group
    fProxy.getCommandProxy().closeElement(newGroup);
    Assert.assertFalse(newGroup.isOpen());

    // Open the closed Review Group
    fProxy.getCommandProxy().openElement(newGroup);
    Assert.assertTrue(newGroup.isOpen());

    // Remove Review Group from preferences
    String prefsGroup = newGroup2.getReviewGroup().eResource().getURI().toFileString();
    fProxy.getPreferencesProxy().removeGroupFromPreferences(prefsGroup);
    for (R4EUIReviewGroup group : R4EUIModelController.getRootElement().getGroups()) {
      if (group.getReviewGroup().getName().equals(newGroup2.getReviewGroup().getName())) {
        fail(
            "Group " + prefsGroup + " should not be present since it was removed from preferences");
      }
    }

    // Add back Review Group to preferences
    boolean groupFound = false;
    fProxy.getPreferencesProxy().addGroupToPreferences(prefsGroup);
    for (R4EUIReviewGroup group : R4EUIModelController.getRootElement().getGroups()) {
      if (group.getReviewGroup().getName().equals(newGroup2.getReviewGroup().getName())) {
        groupFound = true;
        break;
      }
    }
    Assert.assertTrue(groupFound);

    // Get back handle to Review Group since view is refreshed
    for (IR4EUIModelElement elem : R4EUIModelController.getRootElement().getChildren()) {
      if (newGroupName.equals(elem.getName())) {
        newGroup = (R4EUIReviewGroup) elem;
      }
    }
    fProxy.getCommandProxy().openElement(newGroup);
    Assert.assertTrue(newGroup.isOpen());

    // Update Review Group properties
    fProxy
        .getReviewGroupProxy()
        .changeReviewGroupDescription(newGroup, TestConstants.REVIEW_GROUP_TEST_DESCRIPTION2);
    Assert.assertEquals(
        TestConstants.REVIEW_GROUP_TEST_DESCRIPTION2, newGroup.getReviewGroup().getDescription());
    fProxy
        .getReviewGroupProxy()
        .changeReviewGroupDefaultEntryCriteria(
            newGroup, TestConstants.REVIEW_GROUP_TEST_ENTRY_CRITERIA2);
    Assert.assertEquals(
        TestConstants.REVIEW_GROUP_TEST_ENTRY_CRITERIA2,
        newGroup.getReviewGroup().getDefaultEntryCriteria());
    fProxy
        .getReviewGroupProxy()
        .removeReviewGroupAvailableProject(
            newGroup, TestConstants.REVIEW_GROUP_TEST_REM_AVAILABLE_PROJECT);
    fProxy
        .getReviewGroupProxy()
        .addReviewGroupAvailableProject(
            newGroup, TestConstants.REVIEW_GROUP_TEST_ADD_AVAILABLE_PROJECT);
    for (int i = 0; i < TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS2.length; i++) {
      Assert.assertEquals(
          TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS2[i],
          newGroup.getReviewGroup().getAvailableProjects().get(i));
    }
    fProxy
        .getReviewGroupProxy()
        .removeReviewGroupAvailableComponent(
            newGroup, TestConstants.REVIEW_GROUP_TEST_REM_AVAILABLE_COMPONENT);
    fProxy
        .getReviewGroupProxy()
        .addReviewGroupAvailableComponent(
            newGroup, TestConstants.REVIEW_GROUP_TEST_ADD_AVAILABLE_COMPONENT);
    for (int i = 0; i < TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS2.length; i++) {
      Assert.assertEquals(
          TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS2[i],
          newGroup.getReviewGroup().getAvailableComponents().get(i));
    }

    for (R4EUIRuleSet ruleSet : R4EUIModelController.getRootElement().getRuleSets()) {
      if (ruleSet.getName().equals(TestConstants.RULE_SET_TEST_NAME2)) {
        fProxy
            .getReviewGroupProxy()
            .addReviewGroupRuleSet(newGroup, ruleSet.getRuleSet().getName());
        Assert.assertEquals(
            ruleSet.getRuleSet().getName(),
            newGroup.getReviewGroup().getDesignRuleLocations().get(0));
        break;
      }
    }

    for (R4EUIRuleSet ruleSet : R4EUIModelController.getRootElement().getRuleSets()) {
      if (ruleSet.getName().equals(TestConstants.RULE_SET_TEST_NAME)) {
        fProxy
            .getReviewGroupProxy()
            .addReviewGroupRuleSet(newGroup, ruleSet.getRuleSet().getName());
      } else if (ruleSet.getName().equals(TestConstants.RULE_SET_TEST_NAME2)) {
        fProxy
            .getReviewGroupProxy()
            .removeReviewGroupRuleSet(newGroup, ruleSet.getRuleSet().getName());
      }
    }

    for (R4EUIRuleSet ruleSet : R4EUIModelController.getRootElement().getRuleSets()) {
      if (ruleSet.getName().equals(TestConstants.RULE_SET_TEST_NAME)) {
        Assert.assertEquals(
            ruleSet.getRuleSet().getName(),
            newGroup.getReviewGroup().getDesignRuleLocations().get(0));
        break;
      }
    }
  }