/**
   * Tests whether the refactoring merges the constants of two enumerations correctly. The generated
   * enumeration must contain the constants from all variants.
   *
   * @throws Exception In case of an unexpected exception.
   */
  @Test
  public void testRefactorCaseEnumerationAddEnumConstant() throws Exception {
    VariationPoint vp =
        RefactoringTestUtil.getEnumerationAddEnumConstantCase(VariabilityType.OPTXOR);
    IfStaticConfigClassEnumerationInMemberContainer refactoring =
        new IfStaticConfigClassEnumerationInMemberContainer();
    refactoring.refactor(vp, null);

    // location has one member (the enumeration)
    MemberContainer vpLocation =
        (MemberContainer) ((JaMoPPJavaSoftwareElement) vp.getLocation()).getJamoppElement();
    assertThat(vpLocation.getMembers().size(), equalTo(1));

    // member is an enumeration
    assertThat(vpLocation.getMembers().get(0), instanceOf(Enumeration.class));

    Enumeration enumeration = (Enumeration) vpLocation.getMembers().get(0);

    // enumeration has the correct name and the two constants from the base and the integration
    assertThat(enumeration.getName(), equalTo("A"));
    assertThat(enumeration.getConstants().size(), equalTo(2));
    assertThat(enumeration.getConstants().get(0).getName(), anyOf(equalTo("A"), equalTo("B")));
    assertThat(enumeration.getConstants().get(1).getName(), anyOf(equalTo("A"), equalTo("B")));
    assertThat(
        enumeration.getConstants().get(0).getName(),
        not(equalTo(enumeration.getConstants().get(1).getName())));

    // verify correct VPM
    RefactoringTestUtil.assertValidVPM(vp);
  }
  /**
   * Tests whether the canBeApplied method returns false for variation points that have a location
   * that is not supported by the refactoring.
   */
  @Test
  public void testIfCanBeAppliedWithInvalidLocation() {
    Commentable location = MembersFactory.eINSTANCE.createClassMethod();
    Enumeration implEl1 = ClassifiersFactory.eINSTANCE.createEnumeration();
    Enumeration implEl2 = ClassifiersFactory.eINSTANCE.createEnumeration();

    implEl1.setName("A");
    implEl2.setName("B");

    VariationPoint vpMock =
        RefactoringTestUtil.getSimpleVPMock(
            VariabilityType.OPTXOR,
            Extensible.NO,
            BindingTime.COMPILE_TIME,
            location,
            implEl1,
            implEl2);

    IfStaticConfigClassEnumerationInMemberContainer refactoring =
        new IfStaticConfigClassEnumerationInMemberContainer();

    assertThat(refactoring.canBeAppliedTo(vpMock).getSeverity(), is(Diagnostic.ERROR));
  }