package de.plushnikov.intellij.plugin.processor.modifier;

import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;

/**
 * @author Alexej Kubarev
 */
public class ValueModifierTest extends LightJavaCodeInsightFixtureTestCase {

  @Override
  protected String getBasePath() {
    return "/plugins/lombok/testData/augment/modifier";
  }

  @Override
  public void setUp() throws Exception {
    super.setUp();
    myFixture.addClass("package lombok;\npublic @interface Value { }");
  }

  public void testValueModifiers() {

    PsiFile file = myFixture.configureByFile(getTestName(false) + ".java");

    PsiField field = PsiTreeUtil.getParentOfType(file.findElementAt(myFixture.getCaretOffset()), PsiField.class);

    assertNotNull(field);
    assertNotNull(field.getModifierList());

    assertTrue("@Value should make variable final", field.getModifierList().hasModifierProperty(PsiModifier.FINAL));
    assertTrue("@Value should make variable private", field.getModifierList().hasModifierProperty(PsiModifier.PRIVATE));

    PsiClass clazz = PsiTreeUtil.getParentOfType(field, PsiClass.class);

    assertNotNull(clazz);

    PsiModifierList list = clazz.getModifierList();

    assertNotNull(list);
    assertTrue("@Value should make class final", list.hasModifierProperty(PsiModifier.FINAL));
    assertFalse("@Value should not make class private", list.hasModifierProperty(PsiModifier.PRIVATE));
    assertFalse("@Value should not make class static", list.hasModifierProperty(PsiModifier.STATIC));
  }

  public void testValueModifiersStatic() {
    PsiFile file = myFixture.configureByFile(getTestName(false) + ".java");

    PsiField field = PsiTreeUtil.getParentOfType(file.findElementAt(myFixture.getCaretOffset()), PsiField.class);
    assertNotNull(field);
    assertNotNull(field.getModifierList());

    assertFalse("@Value should not make static variable final", field.getModifierList().hasModifierProperty(PsiModifier.FINAL));
    assertFalse("@Value should not make static variable private", field.getModifierList().hasModifierProperty(PsiModifier.PRIVATE));
  }
}

@@ -159,52 +159,205 @@
 ork.
-fixtures.LightJavaCodeInsightFixtureTestCase
+LightProjectDescriptor;%0Aimport com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;%0Aimport de.plushnikov.intellij.plugin.LombokTestUtil;%0Aimport org.jetbrains.annotations.NotNull
 ;%0A%0A/
@@ -594,135 +594,117 @@
 %0A  p
-ublic void setUp() throws Exception %7B%0A    super.setUp();%0A    myFixture.addClass(%22package lombok;%5Cnpublic @interface Value %7B %7D%22)
+rotected @NotNull LightProjectDescriptor getProjectDescriptor() %7B%0A    return LombokTestUtil.LOMBOK_DESCRIPTOR
 ;%0A  

fix test setup