/**
   * When loading profiles, check that XMI profile dependency resolution is handled correctly when
   * two user defined profiles are handed to {@link ProfileManagerImpl#loadProfiles(List)} in two
   * calls, with the first call handing the dependent profile of the second and only on the second
   * call being handed the profile from which the first depends.
   *
   * @throws IOException when file IO goes wrong...
   * @throws UmlException when UML manipulation goes wrong...
   */
  public void
      testXmiProfileDependencyResolutionWithProfilesHandedInReverseOrderOfDependencyInTwoCalls()
          throws IOException, UmlException {
    List<Profile> registeredProfiles = manager.getRegisteredProfiles();
    int numRegisteredBefore = registeredProfiles.size();

    ProfileMother mother = new ProfileMother();
    List<File> profileFiles = mother.createUnloadedProfilePairWith2ndDependingOn1stViaXmi();
    File dependentProfileFile = profileFiles.get(1);
    File baseProfileFile = profileFiles.get(0);
    ArrayList<File> dependentProfileList = new ArrayList<File>();
    dependentProfileList.add(dependentProfileFile);

    ProfileManagerImpl managerImpl = (ProfileManagerImpl) manager;
    manager.addSearchPathDirectory(baseProfileFile.getParent());
    managerImpl.loadProfiles(dependentProfileList);
    assertEquals(
        "We should have one more registered profiles as in the beginning.",
        numRegisteredBefore + 1,
        manager.getRegisteredProfiles().size());

    ArrayList<File> baseProfileList = new ArrayList<File>();
    baseProfileList.add(baseProfileFile);
    managerImpl.loadProfiles(baseProfileList);
    assertEquals(
        "Now we should have two more registered profiles.",
        numRegisteredBefore + 2,
        manager.getRegisteredProfiles().size());
    manager.removeSearchPathDirectory(baseProfileFile.getParent());
  }
  /**
   * When loading profiles, check that XMI profile dependency resolution is handled correctly when
   * two user defined profiles are handed to {@link ProfileManagerImpl#loadProfiles(List)} with the
   * first being the dependent profile of the second.
   *
   * @throws IOException when file IO goes wrong...
   * @throws UmlException when UML manipulation goes wrong...
   */
  public void
      testXmiProfileDependencyResolutionWithProfilesHandedInReverseOrderOfDependencyInOneCall()
          throws IOException, UmlException {
    List<Profile> registeredProfiles = manager.getRegisteredProfiles();
    int numRegisteredBefore = registeredProfiles.size();
    ProfileMother mother = new ProfileMother();
    List<File> profileFiles = mother.createUnloadedProfilePairWith2ndDependingOn1stViaXmi();
    Collections.reverse(profileFiles);

    ProfileManagerImpl managerImpl = (ProfileManagerImpl) manager;
    manager.addSearchPathDirectory(profileFiles.get(0).getParent());
    manager.addSearchPathDirectory(profileFiles.get(1).getParent());
    managerImpl.loadProfiles(profileFiles);

    List<Profile> registeredProfilesAfter = manager.getRegisteredProfiles();
    assertEquals(
        "Now we should have two more registered profiles.",
        numRegisteredBefore + 2,
        registeredProfilesAfter.size());
    manager.removeSearchPathDirectory(profileFiles.get(0).getParent());
    manager.removeSearchPathDirectory(profileFiles.get(1).getParent());
  }