/** test remove profile */
 public void testRemoveProfileThatIsntDefault() {
   Profile gpProfile = manager.getProfileForClass(ProfileGoodPractices.class.getName());
   assertNotNull(gpProfile);
   assertTrue(manager.getRegisteredProfiles().contains(gpProfile));
   manager.removeProfile(gpProfile);
   assertFalse(manager.getRegisteredProfiles().contains(gpProfile));
 }
  /**
   * 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());
  }
  /** Test register and remove a dummy profile. */
  public void testRegisterAndRemoveDummyProfile() {
    Profile testProfile =
        new Profile() {

          @Override
          public String getDisplayName() {
            return "Test Profile";
          }

          @Override
          public Collection getProfilePackages() throws ProfileException {
            return Collections.emptyList();
          }
        };

    manager.registerProfile(testProfile);
    assertTrue(manager.getRegisteredProfiles().contains(testProfile));

    manager.addToDefaultProfiles(testProfile);
    assertTrue(manager.getDefaultProfiles().contains(testProfile));

    manager.removeProfile(testProfile);
    assertFalse(manager.getRegisteredProfiles().contains(testProfile));
    assertFalse(manager.getDefaultProfiles().contains(testProfile));
  }
 /** test profile manager */
 public void testProfileManagerImpl() {
   List<Profile> registeredProfiles = manager.getRegisteredProfiles();
   assertTrue(1 <= registeredProfiles.size());
   Set<String> internalProfileNameSet = new HashSet<String>();
   for (Profile profile : registeredProfiles) {
     if (profile.getDisplayName().equals(ProfileUML.NAME_UML14)) {
       internalProfileNameSet.add(profile.getDisplayName());
     }
   }
   assertEquals(1, internalProfileNameSet.size());
 }
  /**
   * 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());
  }
 /** Test remove the base UML profile. */
 public void testRemoveDefaultProfile() {
   Profile umlProfile = manager.getProfileForClass(ProfileUML.class.getName());
   assertNotNull(umlProfile);
   assertTrue(manager.getRegisteredProfiles().contains(umlProfile));
   assertTrue(manager.getDefaultProfiles().contains(umlProfile));
   manager.removeProfile(umlProfile);
   assertTrue(manager.getRegisteredProfiles().contains(umlProfile));
   assertTrue(manager.getDefaultProfiles().contains(umlProfile));
 }