Пример #1
0
 /**
  * Method getOriginalAnomaly.
  *
  * @param aOriginalReview R4EReview
  * @param aCurrentAnomaly R4EAnomaly
  * @return R4EAnomaly
  */
 public static R4EAnomaly getOriginalAnomaly(
     R4EReview aOriginalReview, R4EAnomaly aCurrentAnomaly) {
   if ((null != aOriginalReview) && (null != aCurrentAnomaly)) {
     // Loop through all anomalies and find the one whose R4EID is the same as the currently
     // imported one
     final String[] origIdTokens =
         aCurrentAnomaly
             .getInfoAtt()
             .get(R4EUIConstants.POSTPONED_ATTR_ORIG_ANOMALY_ID)
             .split(
                 R4EUIConstants
                     .SEPARATOR); // First token is user name, second token is sequence number
     if (null != origIdTokens) {
       final R4EUser origUser = aOriginalReview.getUsersMap().get(origIdTokens[0]);
       if (null != origUser) {
         for (R4EComment anomaly : origUser.getAddedComments()) {
           if (anomaly instanceof R4EAnomaly) {
             Integer id = Integer.valueOf(origIdTokens[1]);
             if (null != id) {
               if (id.intValue() == anomaly.getId().getSequenceID()) {
                 return (R4EAnomaly) anomaly;
               }
             }
           }
         }
       }
     }
   }
   return null;
 }
  /** Build elements one by one */
  public void testGroupReviewCreate() {
    R4EReviewGroup group = null;
    // required folder path and group name to build the new group file
    try {
      group = fFactory.createR4EReviewGroup(fGroupPath, GROUP_NAME);
    } catch (ResourceHandlingException e) {
      e.printStackTrace();
    }

    assertNotNull(group);
    URI uri = group.eResource().getURI();
    String expectedURI = fGroupPath.appendSegment("Group_One_group_root.xrer").toString();
    assertEquals(expectedURI, uri.toString());

    // Deserialise and assert
    group = null;
    try {
      group = fFactory.openR4EReviewGroup(uri);
    } catch (ResourceHandlingException e) {
      e.printStackTrace();
    } catch (CompatibilityException e) {
      e.printStackTrace();
    }

    // validate
    assertNotNull(group);
    assertEquals(GROUP_NAME, group.getName());

    // crate a review
    R4EReview review = null;
    try {
      review = fFactory.createR4EReview(group, REVIEW_NAME1, fUser1);
    } catch (ResourceHandlingException e) {
      e.printStackTrace();
      fail("Exception");
    }

    assertEquals(REVIEW_NAME1, review.getName());

    // re-open the group
    group = null;
    try {
      group = fFactory.openR4EReviewGroup(uri);
    } catch (ResourceHandlingException e) {
      e.printStackTrace();
      fail("Exception");
    } catch (CompatibilityException e) {
      e.printStackTrace();
      fail("Exception");
    }

    uri = review.eResource().getURI();
    // read the review
    try {
      review = fFactory.openR4EReview(group, review.getName());
    } catch (ResourceHandlingException e) {
      e.printStackTrace();
      fail("Exception");
    } catch (CompatibilityException e) {
      e.printStackTrace();
      fail("Exception");
    }

    assertEquals(REVIEW_NAME1, review.getName());

    // read the participant
    R4EUser participant = review.getUsersMap().values().iterator().next();
    uri = participant.eResource().getURI();
    try {
      ResourceSet resSet = participant.eResource().getResourceSet();
      participant = fReader.deserializeTopElement(uri, resSet, R4EParticipant.class);
    } catch (ResourceHandlingException e) {
      e.printStackTrace();
      fail("Exception");
    }

    assertEquals(fUser1, participant.getId());

    // Clean up
    File folder = new File(URI.decode(fGroupPath.devicePath()));
    try {
      FileUtils.deleteDirectory(folder);
    } catch (IOException e) {
      e.printStackTrace();
      fail("Exception");
    }
  }