Author: jjankovi
Date: 2011-09-14 09:43:58 -0400 (Wed, 14 Sep 2011)
New Revision: 34726
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean2.java.cdi
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java
Log:
New test operating on cdi quick fix test added and QuickFixTest refactoring
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean.java.cdi 2011-09-14
13:43:58 UTC (rev 34726)
@@ -0,0 +1,14 @@
+package org.cdi.test;
+import javax.enterprise.inject.Specializes;
+import javax.interceptor.Interceptor;
+
+
+@Interceptor
+@AnyBinding
+@Specializes
+public class TestBean extends AnyBean{
+
+ public String produce(){
+ return "a";
+ }
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean2.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean2.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean2.java.cdi 2011-09-14
13:43:58 UTC (rev 34726)
@@ -0,0 +1,13 @@
+package org.cdi.test;
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Specializes;
+import javax.inject.Inject;
+
+@Decorator
+@Specializes
+public class TestBean extends AnyBean{
+
+ @Inject @Delegate String str;
+
+}
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-09-14
13:38:36 UTC (rev 34725)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-09-14
13:43:58 UTC (rev 34726)
@@ -16,6 +16,7 @@
import org.jboss.tools.ui.bot.ext.view.ProblemsView;
import org.junit.After;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -36,8 +37,9 @@
private static final String PACKAGE_NAME = "org.cdi.test";
private static SWTBotTreeItem[] problemsTrees;
private static final String LINE_SEPARATOR =
System.getProperty("line.separator");
- private enum ANNOTATIONS {TARGET, RETENTION, NAMED, TYPED, DISPOSES, OBSERVES,
INTERCEPTOR, DECORATOR}
- private enum CDICOMPONENT {STEREOSCOPE, QUALIFIER, SCOPE, BEAN}
+ private enum ANNOTATIONS {TARGET, RETENTION, NAMED, TYPED, DISPOSES, OBSERVES,
INTERCEPTOR,
+ SPECIALIZES, DECORATOR}
+ private enum CDICOMPONENT {STEREOSCOPE, QUALIFIER, SCOPE, BEAN, ANNOTATION,
INTERBINDING}
private SWTBotEclipseEditor ed;
@BeforeClass
@@ -51,7 +53,7 @@
public void waitForJobs() {
util.waitForNonIgnoredJobs();
}
-
+
@Test
public void testSerializableQF() {
createComponent(CDICOMPONENT.BEAN, "B1");
@@ -146,23 +148,23 @@
"BrokenFarm.java", "CDI Problem");
assertTrue(problemsTrees.length == 0);
}
-
+
@Test
public void testStereoscopeQF() {
String className = "S1";
prepareCdiComponent(CDICOMPONENT.STEREOSCOPE, className);
// 1.QF -
https://issues.jboss.org/browse/JBIDE-7630
- checkTargetAnnotation(CDICOMPONENT.STEREOSCOPE, ed, className);
+ checkTargetAnnotation(CDICOMPONENT.STEREOSCOPE, className);
// 2.QF -
https://issues.jboss.org/browse/JBIDE-7631
- checkRetentionAnnotation(CDICOMPONENT.STEREOSCOPE, ed, className);
+ checkRetentionAnnotation(CDICOMPONENT.STEREOSCOPE, className);
// 3.QF -
https://issues.jboss.org/browse/JBIDE-7634
- checkNamedAnnotation(CDICOMPONENT.STEREOSCOPE, ed, className);
+ checkNamedAnnotation(CDICOMPONENT.STEREOSCOPE, className);
// 4.QF -
https://issues.jboss.org/browse/JBIDE-7640
- checkTypedAnnotation(CDICOMPONENT.STEREOSCOPE, ed, className);
+ checkTypedAnnotation(CDICOMPONENT.STEREOSCOPE, className);
}
@Test
@@ -171,10 +173,10 @@
prepareCdiComponent(CDICOMPONENT.QUALIFIER, className);
// 1.QF -
https://issues.jboss.org/browse/JBIDE-7631
- checkRetentionAnnotation(CDICOMPONENT.QUALIFIER, ed, className);
+ checkRetentionAnnotation(CDICOMPONENT.QUALIFIER, className);
// 2.QF -
https://issues.jboss.org/browse/JBIDE-7632
- checkTargetAnnotation(CDICOMPONENT.QUALIFIER, ed, className);
+ checkTargetAnnotation(CDICOMPONENT.QUALIFIER, className);
}
@Test
@@ -183,10 +185,10 @@
prepareCdiComponent(CDICOMPONENT.SCOPE, className);
// 1.QF -
https://issues.jboss.org/browse/JBIDE-7631
- checkRetentionAnnotation(CDICOMPONENT.SCOPE, ed, className);
+ checkRetentionAnnotation(CDICOMPONENT.SCOPE, className);
// 2.QF -
https://issues.jboss.org/browse/JBIDE-7633
- checkTargetAnnotation(CDICOMPONENT.SCOPE, ed, className);
+ checkTargetAnnotation(CDICOMPONENT.SCOPE, className);
}
@Test
@@ -195,19 +197,19 @@
prepareCdiComponent(CDICOMPONENT.BEAN, className);
// 1.QF -
https://issues.jboss.org/browse/JBIDE-7664
- checkConstructor(CDICOMPONENT.BEAN, ed, className);
+ checkConstructor(CDICOMPONENT.BEAN, className);
// 2.QF -
https://issues.jboss.org/browse/JBIDE-7665
- checkProducerMethod(CDICOMPONENT.BEAN, ANNOTATIONS.DISPOSES, ed, className);
+ checkProducerMethod(CDICOMPONENT.BEAN, ANNOTATIONS.DISPOSES, className);
// 3.QF -
https://issues.jboss.org/browse/JBIDE-7667
- checkObserverDisposerMethod(CDICOMPONENT.BEAN, ed, className);
+ checkObserverDisposerMethod(CDICOMPONENT.BEAN, className);
// 4.QF -
https://issues.jboss.org/browse/JBIDE-7668
- checkObserWithDisposParamMethod(CDICOMPONENT.BEAN, ed, className);
+ checkObserWithDisposParamMethod(CDICOMPONENT.BEAN, className);
// 5.QF -
https://issues.jboss.org/browse/JBIDE-7680
- checkSessionBean(CDICOMPONENT.BEAN, ed, className);
+ checkSessionBean(CDICOMPONENT.BEAN, className);
}
@Test
@@ -216,18 +218,21 @@
prepareCdiComponent(CDICOMPONENT.BEAN, className);
// 1.QF -
https://issues.jboss.org/browse/JBIDE-7636
- checkNamedAnnotation(CDICOMPONENT.BEAN, ed, className);
+ checkNamedAnnotation(CDICOMPONENT.BEAN, className);
// 2.QF -
https://issues.jboss.org/browse/JBIDE-7683
- checkProducerMethod(CDICOMPONENT.BEAN, ANNOTATIONS.INTERCEPTOR, ed, className);
+ checkProducerMethod(CDICOMPONENT.BEAN, ANNOTATIONS.INTERCEPTOR, className);
// 3.QF -
https://issues.jboss.org/browse/JBIDE-7684
- checkDisposesAnnotation(CDICOMPONENT.BEAN, ed, className);
+ checkDisposesAnnotation(CDICOMPONENT.BEAN, className);
// 4.QF -
https://issues.jboss.org/browse/JBIDE-7685
- checkObserveAnnotation(CDICOMPONENT.BEAN, ed, className);
+ checkObserveAnnotation(CDICOMPONENT.BEAN, className);
// 5.QF -
https://issues.jboss.org/browse/JBIDE-7686
+ checkSpecializeAnnotation(CDICOMPONENT.BEAN, "TestBean");
+
+ //
https://issues.jboss.org/browse/JBIDE-7641 - NIE INTER DECOR
}
private void prepareCdiComponent(CDICOMPONENT component, String name) {
@@ -261,12 +266,17 @@
CDIUtil.bean(PACKAGE_NAME, name, true, false, false, false, null,
null, null, null).finish();
break;
+ case INTERBINDING:
+ CDIUtil.binding(PACKAGE_NAME, name, null, true, false).finish();
+ break;
+ case ANNOTATION:
+
}
util.waitForNonIgnoredJobs();
ed = bot.activeEditor().toTextEditor();
}
- private void prepareNamedAnnotation(SWTBotEclipseEditor ed, CDICOMPONENT comp,
+ private void prepareNamedAnnotation(CDICOMPONENT comp,
String className, boolean add) {
if (comp == CDICOMPONENT.BEAN) {
CDIUtil.insertInEditor(ed, bot, 1, 0, "import javax.inject.Named;" +
LINE_SEPARATOR);
@@ -291,32 +301,32 @@
}
}
- private void prepareTypedAnnotation(SWTBotEclipseEditor ed) {
+ private void prepareTypedAnnotation() {
CDIUtil.insertInEditor(ed, bot, ed.getLineCount()-4 , 0, "@Typed" +
LINE_SEPARATOR);
CDIUtil.insertInEditor(ed, bot, 6 , 0, "import
javax.enterprise.inject.Typed;" + LINE_SEPARATOR);
}
- private void prepareInjectAnnot(SWTBotEclipseEditor ed) {
+ private void prepareInjectAnnot() {
CDIUtil.insertInEditor(ed, bot, 3 , 1, "@Inject" + LINE_SEPARATOR);
CDIUtil.insertInEditor(ed, bot, 1 , 0, "import javax.inject.Inject;" +
LINE_SEPARATOR);
CDIUtil.insertInEditor(ed, bot, 6 , 15, "String aaa");
}
- private void prepareProducer(SWTBotEclipseEditor ed) {
+ private void prepareProducer() {
CDIUtil.copyResourceToClass(ed, CDIQuickFixTest.class
.getResourceAsStream("/resources/cdi/MyBean.java.cdi"), false);
}
- private void prepareObserverDisposer(SWTBotEclipseEditor ed) {
- prepareProducer(ed);
+ private void prepareObserverDisposer() {
+ prepareProducer();
CDIUtil.replaceInEditor(ed, bot, "@Produces", "@Inject");
CDIUtil.replaceInEditor(ed, bot, "import javax.enterprise.inject.Produces;",
"");
CDIUtil.replaceInEditor(ed, bot, "String produceString", "void
method");
CDIUtil.replaceInEditor(ed, bot, "return \"test\";",
"");
}
- private void prepareObserWithDisposParam(SWTBotEclipseEditor ed) {
- prepareProducer(ed);
+ private void prepareObserWithDisposParam() {
+ prepareProducer();
CDIUtil.replaceInEditor(ed, bot, "import javax.inject.Inject;", "import
javax.enterprise.event.Observes;" +
LINE_SEPARATOR + "import javax.enterprise.inject.Disposes;" +
LINE_SEPARATOR);
CDIUtil.replaceInEditor(ed, bot, "@Inject", "");
@@ -336,18 +346,26 @@
}
}
- private void prepareDisposesAnnot(SWTBotEclipseEditor ed) {
+ private void prepareDisposesAnnot() {
CDIUtil.copyResourceToClass(ed, CDIQuickFixTest.class
.getResourceAsStream("/resources/cdi/InterDecor.java.cdi"), false);
}
+
+ private void prepareComponentsForSpecializeAnnotation(String testBeanName) {
+ createComponent(CDICOMPONENT.BEAN, "AnyBean");
+ createComponent(CDICOMPONENT.INTERBINDING, "AnyBinding");
+ createComponent(CDICOMPONENT.BEAN, testBeanName);
+ CDIUtil.copyResourceToClass(ed, CDIQuickFixTest.class
+ .getResourceAsStream("/resources/cdi/TestBean.java.cdi"), false);
+ }
- private void checkTargetAnnotation(CDICOMPONENT comp, SWTBotEclipseEditor ed, String
className) {
- checkTargetAnnotWithReplac(comp, ed, className, "@Target({TYPE, FIELD})");
- checkTargetAnnotWithReplac(comp, ed, className, "");
+ private void checkTargetAnnotation(CDICOMPONENT comp, String className) {
+ checkTargetAnnotWithAddon(comp, className, "@Target({TYPE, FIELD})");
+ checkTargetAnnotWithAddon(comp, className, "");
}
- private void checkTargetAnnotWithReplac(CDICOMPONENT comp, SWTBotEclipseEditor ed,
- String className, String replacement) {
+ private void checkTargetAnnotWithAddon(CDICOMPONENT comp, String className,
+ String replacement) {
switch (comp) {
case STEREOSCOPE:
case SCOPE:
@@ -376,16 +394,16 @@
CDIUtil.replaceInEditor(ed, bot,
"import static java.lang.annotation.ElementType.FIELD;", "");
}
- checkQuickFix(ANNOTATIONS.TARGET, comp, className, replacement, ed);
+ checkQuickFix(ANNOTATIONS.TARGET, comp, className, replacement);
}
- private void checkRetentionAnnotation(CDICOMPONENT comp, SWTBotEclipseEditor ed, String
className) {
- checkRetenAnnotWithReplac(comp, ed, className, "@Retention(CLASS)");
- checkRetenAnnotWithReplac(comp, ed, className, "");
+ private void checkRetentionAnnotation(CDICOMPONENT comp, String className) {
+ checkRetentionAnnotWithAddon(comp, className, "@Retention(CLASS)");
+ checkRetentionAnnotWithAddon(comp, className, "");
}
- private void checkRetenAnnotWithReplac(CDICOMPONENT comp, SWTBotEclipseEditor ed,
- String className, String replacement) {
+ private void checkRetentionAnnotWithAddon(CDICOMPONENT comp, String className,
+ String replacement) {
CDIUtil.replaceInEditor(ed, bot, "@Retention(RUNTIME)", replacement);
if (replacement.equals("@Retention(CLASS)")) {
CDIUtil.replaceInEditor(ed, bot,
@@ -398,69 +416,68 @@
CDIUtil.replaceInEditor(ed, bot,
"import java.lang.annotation.Retention;", "");
}
- checkQuickFix(ANNOTATIONS.RETENTION, comp, className, replacement, ed);
+ checkQuickFix(ANNOTATIONS.RETENTION, comp, className, replacement);
}
- private void checkNamedAnnotation(CDICOMPONENT comp, SWTBotEclipseEditor ed,String
className) {
+ private void checkNamedAnnotation(CDICOMPONENT comp, String className) {
if (className.equals("InterDecor")) {
- prepareNamedAnnotation(ed, comp, className, true);
- checkNamedAnnotWithReplac(comp, ed, className, "@Named");
- prepareNamedAnnotation(ed, comp, className, false);
- checkNamedAnnotWithReplac(comp, ed, className, "@Named");
+ prepareNamedAnnotation(comp, className, true);
+ checkNamedAnnotWithAddon(comp, className, "@Named");
+ prepareNamedAnnotation(comp, className, false);
+ checkNamedAnnotWithAddon(comp, className, "@Named");
} else {
- prepareNamedAnnotation(ed, comp, className, true);
- checkNamedAnnotWithReplac(comp, ed, className, "@Named");
- prepareNamedAnnotation(ed, comp, className, false);
- prepareNamedAnnotation(ed, comp, className, true);
- checkNamedAnnotWithReplac(comp, ed, className, "");
+ prepareNamedAnnotation(comp, className, true);
+ checkNamedAnnotWithAddon(comp, className, "@Named");
+ prepareNamedAnnotation(comp, className, false);
+ prepareNamedAnnotation(comp, className, true);
+ checkNamedAnnotWithAddon(comp, className, "");
}
}
- private void checkNamedAnnotWithReplac(CDICOMPONENT comp, SWTBotEclipseEditor ed,
- String className, String replacement) {
- checkQuickFix(ANNOTATIONS.NAMED, comp, className, replacement, ed);
+ private void checkNamedAnnotWithAddon(CDICOMPONENT comp, String className,
+ String replacement) {
+ checkQuickFix(ANNOTATIONS.NAMED, comp, className, replacement);
}
- private void checkTypedAnnotation(CDICOMPONENT comp, SWTBotEclipseEditor ed, String
className) {
- prepareTypedAnnotation(ed);
- checkTypedAnnotWithReplac(comp, ed, className, "");
+ private void checkTypedAnnotation(CDICOMPONENT comp, String className) {
+ prepareTypedAnnotation();
+ checkTypedAnnotWithAddon(comp, className, "");
}
- private void checkTypedAnnotWithReplac(CDICOMPONENT comp, SWTBotEclipseEditor ed,
- String className, String replacement) {
- checkQuickFix(ANNOTATIONS.TYPED, comp, className, replacement, ed);
+ private void checkTypedAnnotWithAddon(CDICOMPONENT comp, String className,
+ String replacement) {
+ checkQuickFix(ANNOTATIONS.TYPED, comp, className, replacement);
}
- private void checkConstructor(CDICOMPONENT comp, SWTBotEclipseEditor ed, String
className) {
- prepareInjectAnnot(ed);
- checkConstructorWithReplac(comp, ed, className, "@Disposes");
- checkConstructorWithReplac(comp, ed, className, "@Observes");
+ private void checkConstructor(CDICOMPONENT comp, String className) {
+ prepareInjectAnnot();
+ checkConstructorWithAddon(comp, className, "@Disposes");
+ checkConstructorWithAddon(comp, className, "@Observes");
}
- private void checkConstructorWithReplac(CDICOMPONENT comp, SWTBotEclipseEditor ed,
+ private void checkConstructorWithAddon(CDICOMPONENT comp,
String className, String replacement) {
CDIUtil.insertInEditor(ed, bot, 6, 15, replacement + " ");
- dispObserCompletion(comp, ed, className, replacement);
+ dispObserCompletion(comp, className, replacement);
}
- private void checkProducerMethod(CDICOMPONENT comp, ANNOTATIONS annonType,
SWTBotEclipseEditor ed,
- String className) {
+ private void checkProducerMethod(CDICOMPONENT comp, ANNOTATIONS annonType, String
className) {
if (className.equals("InterDecor")) {
- prepareProducer(ed);
+ prepareProducer();
CDIUtil.replaceInEditor(ed, bot, "MyBean", "InterDecor");
- checkProducerWithReplac(comp, annonType, ed, className, "@Interceptor");
- prepareProducer(ed);
+ checkProducerWithAddon(comp, annonType, className, "@Interceptor");
+ prepareProducer();
CDIUtil.replaceInEditor(ed, bot, "MyBean", "InterDecor");
- checkProducerWithReplac(comp, annonType, ed, className, "@Decorator");
+ checkProducerWithAddon(comp, annonType, className, "@Decorator");
} else {
- prepareProducer(ed);
- checkProducerWithReplac(comp, annonType, ed, className, "@Disposes");
- checkProducerWithReplac(comp, annonType, ed, className, "@Observes");
+ prepareProducer();
+ checkProducerWithAddon(comp, annonType, className, "@Disposes");
+ checkProducerWithAddon(comp, annonType, className, "@Observes");
}
}
- private void checkProducerWithReplac(CDICOMPONENT comp, ANNOTATIONS annonType,
- SWTBotEclipseEditor ed, String className, String replacement) {
+ private void checkProducerWithAddon(CDICOMPONENT comp, ANNOTATIONS annonType,
+ String className, String replacement) {
if (className.equals("InterDecor")) {
String annot =
replacement.equals("@Interceptor")?"@Interceptor":"@Decorator";
String importAnnot = replacement.equals("@Interceptor")?
@@ -469,85 +486,85 @@
CDIUtil.insertInEditor(ed, bot, 3, 0, annot + LINE_SEPARATOR);
CDIUtil.insertInEditor(ed, bot, 1, 0, importAnnot + LINE_SEPARATOR);
checkQuickFix(replacement.equals("(a)Interceptor")?ANNOTATIONS.INTERCEPTOR:
- ANNOTATIONS.DECORATOR, comp, className, replacement, ed);
+ ANNOTATIONS.DECORATOR, comp, className, replacement);
} else {
CDIUtil.insertInEditor(ed, bot, 11, 29, replacement + " ");
- dispObserCompletion(comp, ed, className, replacement);
+ dispObserCompletion(comp, className, replacement);
}
}
- private void checkObserverDisposerMethod(CDICOMPONENT comp, SWTBotEclipseEditor ed,
String className) {
- prepareObserverDisposer(ed);
- checkObserverDisposerWithReplac(comp, ed, className, "@Disposes");
- checkObserverDisposerWithReplac(comp, ed, className, "@Observes");
+ private void checkObserverDisposerMethod(CDICOMPONENT comp, String className) {
+ prepareObserverDisposer();
+ checkObserverDisposerWithAddon(comp, className, "@Disposes");
+ checkObserverDisposerWithAddon(comp, className, "@Observes");
}
- private void checkObserverDisposerWithReplac(CDICOMPONENT comp,
- SWTBotEclipseEditor ed, String className, String replacement) {
+ private void checkObserverDisposerWithAddon(CDICOMPONENT comp,
+ String className, String replacement) {
CDIUtil.insertInEditor(ed, bot, 10, 20, replacement + " ");
- dispObserCompletion(comp, ed, className, replacement);
+ dispObserCompletion(comp, className, replacement);
}
- private void checkObserWithDisposParamMethod(CDICOMPONENT comp, SWTBotEclipseEditor ed,
String className) {
- prepareObserWithDisposParam(ed);
- checkObserWithDisposParamWithReplac(comp, ed, className, "@Disposes");
- checkObserWithDisposParamWithReplac(comp, ed, className, "@Observes");
+ private void checkObserWithDisposParamMethod(CDICOMPONENT comp, String className) {
+ prepareObserWithDisposParam();
+ checkObserWithDisposParamWithAddon(comp, className, "@Disposes");
+ checkObserWithDisposParamWithAddon(comp, className, "@Observes");
}
- private void checkObserWithDisposParamWithReplac(CDICOMPONENT comp,
- SWTBotEclipseEditor ed, String className, String replacement) {
+ private void checkObserWithDisposParamWithAddon(CDICOMPONENT comp,
+ String className, String replacement) {
if (replacement.equals("@Observes")) {
CDIUtil.insertInEditor(ed, bot, 3, 0, "import
javax.enterprise.inject.Disposes;");
CDIUtil.insertInEditor(ed, bot, 6, 46, "@Disposes ");
}
checkQuickFix(replacement.equals("@Disposes")?ANNOTATIONS.DISPOSES:ANNOTATIONS.OBSERVES,
- CDICOMPONENT.BEAN, className, "", ed);
+ CDICOMPONENT.BEAN, className, "");
}
- private void checkSessionBean(CDICOMPONENT comp, SWTBotEclipseEditor ed, String
className) {
- checkSessionBeanWithReplac(comp, ed, className, "@Decorator");
- checkSessionBeanWithReplac(comp, ed, className, "@Interceptor");
+ private void checkSessionBean(CDICOMPONENT comp, String className) {
+ checkSessionBeanWithAddon(comp, className, "@Decorator");
+ checkSessionBeanWithAddon(comp, className, "@Interceptor");
}
- private void checkSessionBeanWithReplac(CDICOMPONENT comp, SWTBotEclipseEditor ed,
+ private void checkSessionBeanWithAddon(CDICOMPONENT comp,
String className, String replacement) {
prepareCheckSessionBean(replacement);
checkQuickFix(replacement.equals("@Decorator")?ANNOTATIONS.DECORATOR:ANNOTATIONS.INTERCEPTOR,
- comp, className, replacement, ed);
+ comp, className, replacement);
}
- private void dispObserCompletion(CDICOMPONENT comp, SWTBotEclipseEditor ed, String
className, String replacement) {
+ private void dispObserCompletion(CDICOMPONENT comp, String className, String
replacement) {
CDIUtil.insertInEditor(ed, bot, 2 , 0, "import javax.enterprise." +
(replacement.contains("Disposes")?"inject.":"event.") +
(replacement.substring(1) + ";" + LINE_SEPARATOR));
ANNOTATIONS annonType =
(replacement.equals("@Disposes")?ANNOTATIONS.DISPOSES:ANNOTATIONS.OBSERVES);
- checkQuickFix(annonType, comp, className, replacement, ed);
+ checkQuickFix(annonType, comp, className, replacement);
}
- private void checkDisposesAnnotation(CDICOMPONENT comp, SWTBotEclipseEditor ed, String
className) {
- checkDisposesAnnotWithReplac(comp, ed, className, "@Decorator");
- checkDisposesAnnotWithReplac(comp, ed, className, "@Interceptor");
+ private void checkDisposesAnnotation(CDICOMPONENT comp, String className) {
+ checkDisposesAnnotWithAddon(comp, className, "@Decorator");
+ checkDisposesAnnotWithAddon(comp, className, "@Interceptor");
}
- private void checkDisposesAnnotWithReplac(CDICOMPONENT comp, SWTBotEclipseEditor ed,
- String className, String replacement) {
- prepareDisposesAnnot(ed);
+ private void checkDisposesAnnotWithAddon(CDICOMPONENT comp, String className,
+ String replacement) {
+ prepareDisposesAnnot();
String annot = replacement;
String importAnnot = "import javax." + replacement.substring(1).toLowerCase()
+ "." + replacement.substring(1) + ";";
CDIUtil.insertInEditor(ed, bot, 2, 0, annot + LINE_SEPARATOR);
CDIUtil.insertInEditor(ed, bot, 1, 0, importAnnot + LINE_SEPARATOR);
- checkQuickFix(ANNOTATIONS.DECORATOR, comp, className, replacement, ed);
+ checkQuickFix(ANNOTATIONS.DECORATOR, comp, className, replacement);
}
- private void checkObserveAnnotation(CDICOMPONENT comp, SWTBotEclipseEditor ed, String
className) {
- checkObserveAnnotWithReplac(comp, ed, className, "@Decorator");
- checkObserveAnnotWithReplac(comp, ed, className, "@Interceptor");
+ private void checkObserveAnnotation(CDICOMPONENT comp, String className) {
+ checkObserveAnnotWithAddon(comp, className, "@Decorator");
+ checkObserveAnnotWithAddon(comp, className, "@Interceptor");
}
- private void checkObserveAnnotWithReplac(CDICOMPONENT comp, SWTBotEclipseEditor ed,
- String className, String replacement) {
- prepareDisposesAnnot(ed);
+ private void checkObserveAnnotWithAddon(CDICOMPONENT comp, String className,
+ String replacement) {
+ prepareDisposesAnnot();
CDIUtil.replaceInEditor(ed, bot, "@Disposes", "@Observes");
CDIUtil.replaceInEditor(ed, bot, "import javax.enterprise.inject.Disposes;",
"import javax.enterprise.event.Observes;");
@@ -557,15 +574,30 @@
+ "." + replacement.substring(1) + ";";
CDIUtil.insertInEditor(ed, bot, 2, 0, annot + LINE_SEPARATOR);
CDIUtil.insertInEditor(ed, bot, 1, 0, importAnnot + LINE_SEPARATOR);
- checkQuickFix(ANNOTATIONS.DECORATOR, comp, className, replacement, ed);
+ checkQuickFix(ANNOTATIONS.DECORATOR, comp, className, replacement);
}
- private void checkQuickFix(ANNOTATIONS annonType, CDICOMPONENT comp, String className,
String replacement,
- SWTBotEclipseEditor ed) {
+ private void checkSpecializeAnnotation(CDICOMPONENT comp, String className) {
+ prepareComponentsForSpecializeAnnotation(className);
+ checkSpecializeAnnotWithAddon(comp, className, "@Interceptor");
+ checkSpecializeAnnotWithAddon(comp, className, "@Decorator");
+ }
+
+ private void checkSpecializeAnnotWithAddon(CDICOMPONENT comp, String className,
+ String replacement) {
+ if (replacement.equals("@Decorator")) {
+ CDIUtil.copyResourceToClass(ed,
+ CDIQuickFixTest.class.getResourceAsStream("/resources/cdi/TestBean2.java.cdi"),
false);
+ }
+ checkQuickFix(ANNOTATIONS.SPECIALIZES, comp, className, replacement);
+ }
+
+ private void checkQuickFix(ANNOTATIONS annonType, CDICOMPONENT comp,
+ String className, String replacement) {
String componentClass = className + ".java";
problemsTrees = getProblems(annonType, comp, componentClass);
assertTrue(problemsTrees.length != 0);
- resolveQuickFix(annonType, comp, replacement, ed);
+ resolveQuickFix(annonType, comp, replacement);
problemsTrees = getProblems(annonType, comp, componentClass);
assertTrue(problemsTrees.length == 0);
}
@@ -575,6 +607,7 @@
boolean warningType = true;
switch (annonType) {
case NAMED:
+ case SPECIALIZES:
warningType = ((comp == CDICOMPONENT.BEAN)?true:false);
break;
case TYPED:
@@ -587,6 +620,9 @@
}
String problemsContains = null;
if (warningType) {
+ if (annonType == ANNOTATIONS.SPECIALIZES) {
+ problemsContains = "@Specializes";
+ }
problemsTree = ProblemsView.getFilteredWarningsTreeItems(bot, problemsContains,
"/"
+ PROJECT_NAME, className, "CDI Problem");
} else {
@@ -607,8 +643,7 @@
return problemsTree;
}
- private void resolveQuickFix(ANNOTATIONS annonType, CDICOMPONENT comp, String
replacement,
- SWTBotEclipseEditor ed) {
+ private void resolveQuickFix(ANNOTATIONS annonType, CDICOMPONENT comp, String
replacement) {
int index = indexDetermine(annonType, comp, replacement);
resolve(annonType, replacement, index);
}