/** Make sure the invited to map is still usable after re-opening of a review. */ @Test public void testReviewReopening() { // From Objects to Disk R4EReviewGroup loadedGroup = null; try { loadedGroup = GoldenStubHandler.serializeStub(); } catch (ResourceHandlingException e) { e.printStackTrace(); fail("Exception"); } catch (CompatibilityException e) { e.printStackTrace(); fail("Exception"); } // initialise local refs String dReviewName = "ReviewTwo"; String dUser = "******"; // Save a reference to the initial review R4EReview oReview = loadedGroup.getUserReviews().get(dUser).getInvitedToMap().get(dReviewName); R4EReview nReview = null; // Action: Close the review fFactory.closeR4EReview(oReview); try { nReview = fFactory.openR4EReview(loadedGroup, dReviewName); } catch (ResourceHandlingException e) { e.printStackTrace(); fail("Exception"); } catch (CompatibilityException e) { e.printStackTrace(); fail("Exception"); } assertNotNull("Opened Review is null", nReview); // A new instance of the review should have been created assertNotSame(oReview, nReview); // Read the review reference available in the invitedto map R4EReview wasInvitedTo = loadedGroup.getUserReviews().get(dUser).getInvitedToMap().get(dReviewName); // The reference resolved from the invited to, shall be the same as the new one re-opened and // without manually // refreshing the reference to the new instance assertSame(nReview, wasInvitedTo); // The container group shall be re-initialised as part of the review opening sequence EObject rContainer = nReview.eContainer(); assertNotNull(rContainer); // Make sure that the reference to the parent group is updated to the original parent group assertSame(loadedGroup, nReview.eContainer()); }
/** 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"); } }