Exemplo n.º 1
0
 public static @NonNull URI getASURI(@NonNull URI uri) {
   if (uri.fragment() != null) {
     logger.error("Unexpected fragment ignored for '" + uri.toString() + "'");
     uri = uri.trimFragment();
   }
   URI asURI = uri.appendFileExtension(PivotConstants.OCL_AS_FILE_EXTENSION);
   if (!isASURI(asURI)) {
     asURI = uri.appendSegment(PivotConstants.DOT_OCL_AS_FILE_EXTENSION);
   }
   assert isASURI(asURI);
   return asURI;
 }
 public static URI getCacheFile(URI uri) {
   return CACHE_FOLDER.appendSegment(IOUtil.encodeFileName(uri.toString()));
 }
  /** 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");
    }
  }
Exemplo n.º 4
0
 private String computeDefaultURI() {
   String ext = currentResource.getURI().fileExtension();
   URI uri = currentResource.getURI().trimSegments(1);
   uri = uri.appendSegment(defaultName).appendFileExtension(ext);
   return uri.toString();
 }