Author: jjankovi
Date: 2012-01-16 08:48:45 -0500 (Mon, 16 Jan 2012)
New Revision: 37861
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/AnimalWithQualifier.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/BrokenFarm.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/BrokenFarmWithQualifier.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/Dog.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/DogWithQualifier.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeansXMLQuickFixTestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/EligibleInjectionQuickFixTestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/IValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationProblem.java
Removed:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/addQualifier/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/removeQualifier/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/base/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/requirements.properties
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/BeansXMLValidationErrors.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/injection/ProblemEligibleInjectionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/BeanValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/BeansXMLValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/DecoratorValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/IBindingValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/InterceptorValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/QualifierValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/ScopeValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/StereotypeValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeanValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeansXmlValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt
Log:
Huge refactoring of all CDI QuickFix-like test + moving resources for QuickFix tests into
one folder
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/requirements.properties
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/requirements.properties 2012-01-16
11:59:04 UTC (rev 37860)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/requirements.properties 2012-01-16
13:48:45 UTC (rev 37861)
@@ -1 +1,2 @@
-requirements=jbossas-6.0.0.Final
\ No newline at end of file
+#requirements=jbossas-6.0.0.Final
+requirements=jbossas
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/AnimalWithQualifier.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/AnimalWithQualifier.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/AnimalWithQualifier.java.cdi 2012-01-16
13:48:45 UTC (rev 37861)
@@ -0,0 +1,7 @@
+package cdi;
+
+@Q1
+public class Animal {
+
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/BrokenFarm.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/BrokenFarm.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/BrokenFarm.java.cdi 2012-01-16
13:48:45 UTC (rev 37861)
@@ -0,0 +1,9 @@
+package cdi;
+
+import javax.inject.Inject;
+
+public class BrokenFarm {
+ @SuppressWarnings("unused")
+ @Inject private Animal animal;
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/BrokenFarmWithQualifier.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/BrokenFarmWithQualifier.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/BrokenFarmWithQualifier.java.cdi 2012-01-16
13:48:45 UTC (rev 37861)
@@ -0,0 +1,9 @@
+package cdi;
+
+import javax.inject.Inject;
+
+public class BrokenFarm {
+ @SuppressWarnings("unused")
+ @Inject @Q1 private Animal animal;
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/Dog.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/Dog.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/Dog.java.cdi 2012-01-16
13:48:45 UTC (rev 37861)
@@ -0,0 +1,9 @@
+package cdi;
+
+public class Dog extends Animal {
+
+ public Dog() {
+
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/DogWithQualifier.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/DogWithQualifier.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/injection/DogWithQualifier.java.cdi 2012-01-16
13:48:45 UTC (rev 37861)
@@ -0,0 +1,6 @@
+package cdi;
+
+@Q1
+public class Dog extends Animal {
+
+}
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -11,6 +11,8 @@
package org.jboss.tools.cdi.bot.test;
+import java.util.Arrays;
+import java.util.List;
import java.util.logging.Logger;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
@@ -29,6 +31,14 @@
@SuiteClasses({ CDIAllBotTests.class })
public class CDITestBase extends CDIBase {
+ protected static final String BEANS_XML = "beans.xml";
+ protected static final String CLASS_END_TAG = "</class>";
+ protected static final String CLASS_OPEN_TAG = "<class>";
+ protected static final String STEREOTYPE_END_TAG = "</stereotype>";
+ protected static final String STEREOTYPE_OPEN_TAG = "<stereotype>";
+ protected static final List<String> BEANS_XML_TAGS = Arrays.asList(
+ "alternatives", "decorators", "interceptors");
+
private String projectName = "CDIProject";
private String packageName = "cdi";
protected final String LINE_SEPARATOR = System.getProperty("line.separator");
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/BeansXMLValidationErrors.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/BeansXMLValidationErrors.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/BeansXMLValidationErrors.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -13,6 +13,19 @@
public enum BeansXMLValidationErrors {
- ALTERNATIVE, DECORATOR, INTERCEPTOR, NO_SUCH_CLASS
+ ALTERNATIVE("must specify the name of an alternative bean class"),
+ DECORATOR("must specify the name of a decorator bean class"),
+ INTERCEPTOR("must specify the name of an interceptor class"),
+ NO_SUCH_CLASS("There is no class with the specified name");
+ private String validationError;
+
+ private BeansXMLValidationErrors(String validationError) {
+ this.validationError = validationError;
+ }
+
+ public String message() {
+ return validationError;
+ }
+
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -14,6 +14,7 @@
public enum CDIAnnotationsType {
SERIALIZABLE, TARGET, RETENTION, NAMED, TYPED, DISPOSES, OBSERVES, INTERCEPTOR,
- SPECIALIZES, DECORATOR, PRODUCES, NONBINDING, STATELESS, INJECT;
+ SPECIALIZES, DECORATOR, PRODUCES, NONBINDING, STATELESS, INJECT,
+ MULTIPLE_BEAN_ELIGIBLE, NO_BEAN_ELIGIBLE;
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -33,8 +33,6 @@
public class BeansXMLCompletionTest extends CDITestBase {
- private static final List<String> BEANS_XML_TAGS = Arrays.asList(
- "alternatives", "decorators", "interceptors");
private static final List<String> INTERCEPTOR_NAMES = Arrays.asList(
"I1", "I2", "I3");
private static final List<String> DECORATORS_NAMES = Arrays.asList(
@@ -43,10 +41,6 @@
"A1", "A2", "A3");
private static final List<String> STEREOTYPES_NAMES = Arrays.asList(
"S1", "S2", "S3");
- private static final String BEANS_XML = "beans.xml";
- private static final String CLASS_END_TAG = "</class>";
- private static final String STEREOTYPE_END_TAG = "</stereotype>";
-
@Override
public String getProjectName() {
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeansXMLQuickFixTestBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeansXMLQuickFixTestBase.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeansXMLQuickFixTestBase.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.BeansXmlValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.IValidationProvider;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardBase;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.QuickFixDialogWizard;
+
+public class BeansXMLQuickFixTestBase extends QuickFixTestBase {
+
+ private static IValidationProvider validationProvider = new
BeansXmlValidationProvider();
+
+ public IValidationProvider validationProvider() {
+ return validationProvider;
+ }
+
+ /**
+ * Method firstly gets beans.xml validation problem. Then
+ * it opens quick fix wizard, selects default value and
+ * press finish button
+ */
+ private void openBeanXMLValidationProblem(ValidationType validationProblemType) {
+
+ SWTBotTreeItem validationProblem = getProblem(validationProblemType);
+ assertNotNull(validationProblem);
+
+ quickFixHelper.openQuickFix(validationProblem);
+ QuickFixDialogWizard qfWizard = new QuickFixDialogWizard();
+ qfWizard.setFix(qfWizard.getAvailableFixes().get(0));
+ qfWizard.setResource(qfWizard.getResources().get(0));
+ qfWizard.finish();
+ }
+
+ /**
+ * Method checks if there is no beans.xml validation error
+ * @return
+ */
+ public boolean isBeanXMLValidationProblemsEmpty() {
+ for (ValidationType validationType:
validationProvider().getAllValidationProblemsType()) {
+ if (getProblem(validationType) != null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Method resolves validation error where there is no such Alternative as
+ * configured in beans.xml. It opens quick fix and through finish button
+ * the Bean Wizard dialog is opened where both parameters are used to create
+ * the new alternative bean
+ * @param name
+ * @param pkg
+ */
+ public void resolveAddNewAlternative(String name, String pkg) {
+
+ openBeanXMLValidationProblem(ValidationType.NO_CLASS);
+ CDIWizardBase cdiWizardBase = new CDIWizardBase(CDIWizardType.BEAN);
+ if (cdiWizardBase.isAlternative() && cdiWizardBase.canFinish()) {
+ cdiWizardBase.setName(name).setPackage(pkg).finish();
+ }else {
+ fail("Dialog can't be finished");
+ }
+
+ }
+
+ /**
+ * Method resolves validation error where there is no such Stereotype as
+ * configured in beans.xml. It opens quick fix and through finish button
+ * the Stereotype Wizard dialog is opened where both parameters are used to create
+ * the new stereotype annotation
+ * @param name
+ * @param pkg
+ */
+ public void resolveAddNewStereotype(String name, String pkg) {
+
+ openBeanXMLValidationProblem(ValidationType.NO_ANNOTATION);
+ CDIWizardBase cdiWizardBase = new CDIWizardBase(CDIWizardType.STEREOTYPE);
+ if (cdiWizardBase.isAlternative() && cdiWizardBase.canFinish()) {
+ cdiWizardBase.setName(name).setPackage(pkg).finish();
+ }else {
+ fail("Dialog can't be finished");
+ }
+
+ }
+
+ /**
+ * Method resolves validation error where there is no such decorator as
+ * configured in beans.xml. It opens quick fix and through finish button
+ * the Decorator Wizard dialog is opened where both parameters are used to create
+ * the new decorator. Interface "java.util.List" is automatically used.
+ * @param name
+ * @param pkg
+ */
+ public void resolveAddNewDecorator(String name, String pkg) {
+
+ openBeanXMLValidationProblem(ValidationType.NO_CLASS);
+ CDIWizardBase cdiWizardBase = new CDIWizardBase(CDIWizardType.DECORATOR);
+ cdiWizardBase.addInterface("java.util.List");
+ if (cdiWizardBase.canFinish()) {
+ cdiWizardBase.setName(name).setPackage(pkg).finish();
+ } else {
+ fail("Dialog can't be finished");
+ }
+
+ }
+
+ /**
+ * Method resolves validation error where there is no such Interceptor as
+ * configured in beans.xml. It opens quick fix and through finish button
+ * the Interceptor Wizard dialog is opened where both parameters are used to create
+ * the new Interceptor
+ * @param name
+ * @param pkg
+ */
+ public void resolveAddNewInterceptor(String name, String pkg) {
+
+ openBeanXMLValidationProblem(ValidationType.NO_CLASS);
+ CDIWizardBase cdiWizardBase = new CDIWizardBase(CDIWizardType.INTERCEPTOR);
+ if (cdiWizardBase.canFinish()) {
+ cdiWizardBase.setName(name).setPackage(pkg).finish();
+ }else {
+ fail("Dialog can't be finished");
+ }
+
+ }
+
+ /**
+ * Method corrects Bean which has no @Alternative annotation in it
+ * by adding these parameter.
+ * @param name
+ * @param pkg
+ */
+ public void resolveAddAlternativeToBean(String name) {
+
+ openBeanXMLValidationProblem(ValidationType.ALTERNATIVE_BEAN_XML);
+ String content = bot.editorByTitle(name + ".java").toTextEditor().getText();
+ assertTrue(content.contains("@Alternative"));
+
+ }
+
+ /**
+ * Method corrects Stereotype which has no @Alternative annotation in it
+ * by adding these parameter.
+ * @param name
+ * @param pkg
+ */
+ public void resolveAddAlternativeToStereotype(String name) {
+
+ openBeanXMLValidationProblem(ValidationType.ALTERNATIVE_STEREOTYPE_BEAN_XML);
+ String content = bot.editorByTitle(name + ".java").toTextEditor().getText();
+ assertTrue(content.contains("@Alternative"));
+
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/EligibleInjectionQuickFixTestBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/EligibleInjectionQuickFixTestBase.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/EligibleInjectionQuickFixTestBase.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+import org.jboss.tools.cdi.bot.test.quickfix.injection.QualifierOperation;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.BeanValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.IValidationProvider;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.QuickFixDialogWizard;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.SpecifyBeanDialogWizard;
+import org.jboss.tools.ui.bot.ext.Timing;
+
+public class EligibleInjectionQuickFixTestBase extends QuickFixTestBase{
+
+ private static IValidationProvider validationProvider = new BeanValidationProvider();
+
+ public IValidationProvider validationProvider() {
+ return validationProvider;
+ }
+
+ /**
+ * Method resolves multiple bean injection problem. By setting class which
+ * should be more qualified and qualifier name it resolves this problem.
+ * If qualifier doesn't exist, by using qualifier wizard it creates the new
+ * one and uses it to resolve problem
+ * @param classToQualify
+ * @param qualifier
+ */
+ public void resolveMultipleBeans(ValidationType validationType, String classToQualify,
+ String qualifier, QualifierOperation operation) {
+
+ SWTBotTreeItem validationProblem = getProblem(validationType);
+ assertNotNull(validationProblem);
+
+ quickFixHelper.openQuickFix(validationProblem);
+ QuickFixDialogWizard quickFixWizard = new QuickFixDialogWizard();
+ for (String availableFix : quickFixWizard.getAvailableFixes()) {
+ if (availableFix.contains(classToQualify)) {
+ quickFixWizard.setFix(availableFix).
+ setResource(quickFixWizard.getResources().get(0)).
+ finish();
+ }
+ }
+
+ SpecifyBeanDialogWizard spBeanDialogWizard = new SpecifyBeanDialogWizard();
+ if (operation == QualifierOperation.ADD) {
+ boolean qualifFound = false;
+ for (String availQualifer : spBeanDialogWizard.getAvailableQualifiers()) {
+ if (availQualifer.equals(qualifier + " - " + getPackageName())) {
+ qualifFound = true;
+ spBeanDialogWizard.addQualifier(availQualifer);
+ }
+ }
+ // there was no such qualifer, it has to be created, after creation it
+ // has to be added to in Bean qualifiers
+ if (!qualifFound) {
+ spBeanDialogWizard.createNewQualifier(qualifier, getPackageName()).
+ setName(qualifier).finish();
+ bot.sleep(Timing.time2S());
+ for (String availQualifer : spBeanDialogWizard.getAvailableQualifiers()) {
+ if (availQualifer.equals(qualifier + " - " + getPackageName())) {
+ spBeanDialogWizard.addQualifier(availQualifer);
+ }
+ }
+ }
+
+ } else {
+ for (String inBeanQualifer : spBeanDialogWizard.getInBeanQualifiers()) {
+ if (inBeanQualifer.equals(qualifier + " - " + getPackageName())) {
+ spBeanDialogWizard.removeQualifier(inBeanQualifer);
+ }
+ }
+ }
+
+ spBeanDialogWizard.finish();
+
+ bot.sleep(Timing.time1S());
+ util.waitForNonIgnoredJobs();
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix;
+
+
+import java.util.List;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.IValidationProvider;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.QuickFixDialogWizard;
+import org.junit.BeforeClass;
+
+/**
+ * Test base for all QuickFix-like tests
+ *
+ * @author Jaroslav Jankovic
+ */
+
+public abstract class QuickFixTestBase extends CDITestBase {
+
+ @BeforeClass
+ public static void setup() {
+ problems.show();
+ }
+
+ protected abstract IValidationProvider validationProvider();
+
+ /**
+ * checkQuickFix is the most important method in this class. It
+ * gets validation error prior to component type and annotation type,
+ * then it resolve validation error through quick fix
+ * wizard and finally check if validation errors was fixed through
+ * this wizard
+ * @param validationType
+ * @param compType
+ */
+ public void checkQuickFix(ValidationType validationType) {
+ SWTBotTreeItem validationProblem = getProblem(validationType);
+ assertNotNull(validationProblem);
+ resolveQuickFix(validationProblem);
+ validationProblem = getProblem(validationType);
+ assertNull(validationProblem);
+ }
+
+ /**
+ * Methods gets the particular validation problem located in Problems View by
+ * using specific ValidationErrorsProvider
+ * @param validationType
+ * @param compType
+ * @return
+ */
+ protected SWTBotTreeItem getProblem(ValidationType validationType) {
+ IValidationProvider validationErrorsProvider = validationProvider();
+ List<String> validationProblems = null;
+ SWTBotTreeItem[] problemsInProblemsView = null;
+ if (validationErrorsProvider.getAllWarningsAnnotation().contains(validationType)) {
+ validationProblems =
validationErrorsProvider.getAllWarningForAnnotationType(validationType);
+ problemsInProblemsView = quickFixHelper.getProblems(ProblemsType.WARNINGS,
getProjectName());
+ } else {
+ validationProblems =
validationErrorsProvider.getAllErrorsForAnnotationType(validationType);
+ problemsInProblemsView = quickFixHelper.getProblems(ProblemsType.ERRORS,
getProjectName());
+ }
+ for (SWTBotTreeItem ti: problemsInProblemsView) {
+ for (String validationProblem: validationProblems) {
+ if (ti.getText().contains(validationProblem)) {
+ return ti;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Method resolves particular validation problem (parameter ti).
+ * It simply open context menu for param "ti", open menu "Quick Fix"
and
+ * chooses first option and confirms it (resolve it)
+ * @param ti
+ */
+ private void resolveQuickFix(SWTBotTreeItem ti) {
+ quickFixHelper.openQuickFix(ti);
+
+ QuickFixDialogWizard qfWizard = new QuickFixDialogWizard();
+
+ String firstFix = qfWizard.getAvailableFixes().get(0);
+ String firstResource = qfWizard.getResources().get(0);
+
+ qfWizard.setFix(firstFix).setResource(firstResource).finish();
+
+ util.waitForNonIgnoredJobs();
+ }
+
+}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/injection/ProblemEligibleInjectionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/injection/ProblemEligibleInjectionTest.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/injection/ProblemEligibleInjectionTest.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -12,7 +12,8 @@
package org.jboss.tools.cdi.bot.test.quickfix.injection;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
-import org.jboss.tools.cdi.bot.test.quickfix.base.EligibleInjectionQuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+import org.jboss.tools.cdi.bot.test.quickfix.EligibleInjectionQuickFixTestBase;
import org.junit.After;
import org.junit.Test;
@@ -52,14 +53,14 @@
wizard.createCDIComponentWithContent(CDIWizardType.BEAN, DOG,
getPackageName(), null, "/resources/quickfix/" +
- "injection/addQualifier/Dog.java.cdi");
+ "injection/Dog.java.cdi");
wizard.createCDIComponentWithContent(CDIWizardType.BEAN, BROKEN_FARM,
getPackageName(), null, "/resources/quickfix/" +
- "injection/addQualifier/BrokenFarm.java.cdi");
+ "injection/BrokenFarm.java.cdi");
- resolveMultipleBeans(DOG, QUALIFIER, QualifierOperation.ADD);
+ resolveMultipleBeans(ValidationType.MULTIPLE_BEAN_ELIGIBLE, DOG, QUALIFIER,
QualifierOperation.ADD);
bot.editorByTitle(BROKEN_FARM + ".java").show();
setEd(bot.activeEditor().toTextEditor());
@@ -70,56 +71,56 @@
}
@Test
- public void testMultipleBeansRemovingExistingQualifier() {
+ public void testMultipleBeansAddingNonExistingQualifier() {
- wizard.createCDIComponent(CDIWizardType.QUALIFIER, QUALIFIER,
+ wizard.createCDIComponent(CDIWizardType.BEAN, ANIMAL,
getPackageName(), null);
- wizard.createCDIComponentWithContent(CDIWizardType.BEAN, ANIMAL,
- getPackageName(), null, "/resources/quickfix/" +
- "injection/removeQualifier/Animal.java.cdi");
-
wizard.createCDIComponentWithContent(CDIWizardType.BEAN, DOG,
getPackageName(), null, "/resources/quickfix/" +
- "injection/removeQualifier/Dog.java.cdi");
+ "injection/Dog.java.cdi");
+
wizard.createCDIComponentWithContent(CDIWizardType.BEAN, BROKEN_FARM,
getPackageName(), null, "/resources/quickfix/" +
- "injection/removeQualifier/BrokenFarm.java.cdi");
+ "injection/BrokenFarm.java.cdi");
+
+ resolveMultipleBeans(ValidationType.MULTIPLE_BEAN_ELIGIBLE, DOG, QUALIFIER,
QualifierOperation.ADD);
- resolveMultipleBeans(DOG, QUALIFIER, QualifierOperation.REMOVE);
-
bot.editorByTitle(BROKEN_FARM + ".java").show();
setEd(bot.activeEditor().toTextEditor());
String code = getEd().getText();
- assertTrue(code.contains("@Inject private") || code.contains("@Inject
private"));
+ assertTrue(code.contains("@Inject @" + QUALIFIER));
code = bot.editorByTitle(DOG + ".java").toTextEditor().getText();
- assertTrue(!code.contains("@" + QUALIFIER));
+ assertTrue(code.contains("@" + QUALIFIER));
}
@Test
- public void testMultipleBeansAddingNonExistingQualifier() {
+ public void testMultipleBeansRemovingExistingQualifier() {
- wizard.createCDIComponent(CDIWizardType.BEAN, ANIMAL,
+ wizard.createCDIComponent(CDIWizardType.QUALIFIER, QUALIFIER,
getPackageName(), null);
+ wizard.createCDIComponentWithContent(CDIWizardType.BEAN, ANIMAL,
+ getPackageName(), null, "/resources/quickfix/" +
+ "injection/AnimalWithQualifier.java.cdi");
+
wizard.createCDIComponentWithContent(CDIWizardType.BEAN, DOG,
getPackageName(), null, "/resources/quickfix/" +
- "injection/addQualifier/Dog.java.cdi");
+ "injection/DogWithQualifier.java.cdi");
-
wizard.createCDIComponentWithContent(CDIWizardType.BEAN, BROKEN_FARM,
getPackageName(), null, "/resources/quickfix/" +
- "injection/addQualifier/BrokenFarm.java.cdi");
+ "injection/BrokenFarmWithQualifier.java.cdi");
+
+ resolveMultipleBeans(ValidationType.MULTIPLE_BEAN_ELIGIBLE, DOG, QUALIFIER,
QualifierOperation.REMOVE);
- resolveMultipleBeans(DOG, QUALIFIER, QualifierOperation.ADD);
-
bot.editorByTitle(BROKEN_FARM + ".java").show();
setEd(bot.activeEditor().toTextEditor());
String code = getEd().getText();
- assertTrue(code.contains("@Inject @" + QUALIFIER));
+ assertTrue(code.contains("@Inject private") || code.contains("@Inject
private"));
code = bot.editorByTitle(DOG + ".java").toTextEditor().getText();
- assertTrue(code.contains("@" + QUALIFIER));
+ assertTrue(!code.contains("@" + QUALIFIER));
}
@Test
@@ -133,14 +134,14 @@
wizard.createCDIComponentWithContent(CDIWizardType.BEAN, DOG,
getPackageName(), null, "/resources/quickfix/" +
- "injection/addQualifier/Dog.java.cdi");
+ "injection/Dog.java.cdi");
wizard.createCDIComponentWithContent(CDIWizardType.BEAN, BROKEN_FARM,
getPackageName(), null, "/resources/quickfix/" +
- "injection/addQualifier/BrokenFarmWithQualifier.java.cdi");
+ "injection/BrokenFarmWithQualifier.java.cdi");
- resolveMultipleBeans(DOG, QUALIFIER, QualifierOperation.ADD);
+ resolveMultipleBeans(ValidationType.NO_BEAN_ELIGIBLE, DOG, QUALIFIER,
QualifierOperation.ADD);
bot.editorByTitle(BROKEN_FARM + ".java").show();
setEd(bot.activeEditor().toTextEditor());
@@ -152,28 +153,32 @@
}
@Test
- public void testNoBeanEligibleAddingNonExistingQualifier() {
+ public void testNoBeanEligibleRemovingExistingQualifier() {
- wizard.createCDIComponent(CDIWizardType.BEAN, ANIMAL,
+ wizard.createCDIComponent(CDIWizardType.QUALIFIER, QUALIFIER,
getPackageName(), null);
+ wizard.createCDIComponentWithContent(CDIWizardType.BEAN, ANIMAL,
+ getPackageName(), null, "/resources/quickfix/" +
+ "injection/AnimalWithQualifier.java.cdi");
+
wizard.createCDIComponentWithContent(CDIWizardType.BEAN, DOG,
getPackageName(), null, "/resources/quickfix/" +
- "injection/addQualifier/Dog.java.cdi");
+ "injection/DogWithQualifier.java.cdi");
wizard.createCDIComponentWithContent(CDIWizardType.BEAN, BROKEN_FARM,
getPackageName(), null, "/resources/quickfix/" +
- "injection/addQualifier/BrokenFarmWithQualifier.java.cdi");
+ "injection/BrokenFarm.java.cdi");
- resolveMultipleBeans(DOG, QUALIFIER, QualifierOperation.ADD);
+ resolveMultipleBeans(ValidationType.NO_BEAN_ELIGIBLE, DOG, QUALIFIER,
QualifierOperation.REMOVE);
bot.editorByTitle(BROKEN_FARM + ".java").show();
setEd(bot.activeEditor().toTextEditor());
String code = getEd().getText();
- assertTrue(code.contains("@Inject @" + QUALIFIER));
+ assertTrue(code.contains("@Inject private") || code.contains("@Inject
private"));
code = bot.editorByTitle(DOG + ".java").toTextEditor().getText();
- assertTrue(code.contains("@" + QUALIFIER));
+ assertFalse(code.contains("@" + QUALIFIER));
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/BeanValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/BeanValidationQuickFixTest.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/BeanValidationQuickFixTest.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -12,9 +12,11 @@
package org.jboss.tools.cdi.bot.test.quickfix.test;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
-import org.jboss.tools.cdi.bot.test.quickfix.base.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+import org.jboss.tools.cdi.bot.test.quickfix.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.BeanValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.IValidationProvider;
import org.junit.Test;
/**
@@ -25,11 +27,16 @@
public class BeanValidationQuickFixTest extends QuickFixTestBase {
+ private static IValidationProvider validationProvider = new BeanValidationProvider();
@Override
public String getProjectName() {
return "CDIQuickFixBeanTest";
}
+
+ public IValidationProvider validationProvider() {
+ return validationProvider;
+ }
//
https://issues.jboss.org/browse/JBIDE-8550
@Test
@@ -41,11 +48,10 @@
getPackageName(), null,
"/resources/quickfix/bean/SerializableBean.java.cdi");
editResourceUtil.replaceInEditor("BeanComponent", className);
- checkQuickFix(CDIAnnotationsType.SERIALIZABLE, CDIWizardType.BEAN);
+ checkQuickFix(ValidationType.SERIALIZABLE);
}
-
//
https://issues.jboss.org/browse/JBIDE-7664
@Test
public void testConstructor() {
@@ -56,7 +62,7 @@
getPackageName(), null,
"/resources/quickfix/bean/ConstructorWithParam.java.cdi");
editResourceUtil.replaceInEditor("BeanComponent", className);
- checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.BEAN);
+ checkQuickFix(ValidationType.DISPOSES);
editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
.getResourceAsStream("/resources/quickfix/bean/ConstructorWithParam.java.cdi"),
false);
@@ -66,7 +72,7 @@
"import javax.enterprise.event.Observes;");
editResourceUtil.replaceInEditor("BeanComponent", className);
- checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+ checkQuickFix(ValidationType.OBSERVES);
}
//
https://issues.jboss.org/browse/JBIDE-7665
@@ -80,7 +86,7 @@
editResourceUtil.replaceInEditor("BeanComponent", className);
- checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.BEAN);
+ checkQuickFix(ValidationType.DISPOSES);
editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
.getResourceAsStream("/resources/quickfix/bean/ProducerWithParam.java.cdi"),
false);
@@ -90,7 +96,7 @@
editResourceUtil.replaceInEditor("import javax.enterprise.inject.Disposes;",
"import javax.enterprise.event.Observes;");
- checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+ checkQuickFix(ValidationType.OBSERVES);
}
@@ -105,7 +111,7 @@
editResourceUtil.replaceInEditor("BeanComponent", className);
- checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.BEAN);
+ checkQuickFix(ValidationType.DISPOSES);
}
@@ -123,7 +129,7 @@
editResourceUtil.replaceInEditor("@Disposes", "@Observes");
editResourceUtil.replaceInEditor("BeanComponent", className);
- checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+ checkQuickFix(ValidationType.OBSERVES);
}
@@ -138,7 +144,7 @@
editResourceUtil.replaceInEditor("BeanComponent", className);
- checkQuickFix(CDIAnnotationsType.PRODUCES, CDIWizardType.BEAN);
+ checkQuickFix(ValidationType.PRODUCES);
}
@@ -153,7 +159,7 @@
editResourceUtil.replaceInEditor("BeanComponent", className);
- checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+ checkQuickFix(ValidationType.OBSERVES);
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/BeansXMLValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/BeansXMLValidationQuickFixTest.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/BeansXMLValidationQuickFixTest.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -12,7 +12,7 @@
package org.jboss.tools.cdi.bot.test.quickfix.test;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
-import org.jboss.tools.cdi.bot.test.quickfix.base.BeansXMLQuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.quickfix.BeansXMLQuickFixTestBase;
import org.junit.Test;
/**
@@ -60,7 +60,7 @@
beansHelper.createBeansXMLWithAlternative(getProjectName(), getPackageName(), bean);
- resolveAddAlternativeToExistingComponent(bean);
+ resolveAddAlternativeToBean(bean);
assertTrue(isBeanXMLValidationProblemsEmpty());
@@ -75,7 +75,7 @@
beansHelper.createBeansXMLWithStereotype(getProjectName(), getPackageName(),
stereotype);
- resolveAddAlternativeToExistingComponent(stereotype);
+ resolveAddAlternativeToStereotype(stereotype);
assertTrue(isBeanXMLValidationProblemsEmpty());
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/DecoratorValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/DecoratorValidationQuickFixTest.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/DecoratorValidationQuickFixTest.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -12,9 +12,11 @@
package org.jboss.tools.cdi.bot.test.quickfix.test;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
-import org.jboss.tools.cdi.bot.test.quickfix.base.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+import org.jboss.tools.cdi.bot.test.quickfix.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.DecoratorValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.IValidationProvider;
import org.junit.Test;
/**
@@ -25,12 +27,17 @@
public class DecoratorValidationQuickFixTest extends QuickFixTestBase {
+ private static IValidationProvider validationProvider = new
DecoratorValidationProvider();
@Override
public String getProjectName() {
return "CDIQuickFixDecoratorTest";
}
+ public IValidationProvider validationProvider() {
+ return validationProvider;
+ }
+
//
https://issues.jboss.org/browse/JBIDE-7680
@Test
public void testSessionAnnotation() {
@@ -43,7 +50,7 @@
editResourceUtil.replaceInEditor("DecoratorComponent", className);
- checkQuickFix(CDIAnnotationsType.STATELESS, CDIWizardType.DECORATOR);
+ checkQuickFix(ValidationType.STATELESS);
}
@@ -59,7 +66,7 @@
editResourceUtil.replaceInEditor("DecoratorComponent", className);
- checkQuickFix(CDIAnnotationsType.NAMED, CDIWizardType.DECORATOR);
+ checkQuickFix(ValidationType.NAMED);
}
@@ -75,7 +82,7 @@
editResourceUtil.replaceInEditor("DecoratorComponent", className);
- checkQuickFix(CDIAnnotationsType.PRODUCES, CDIWizardType.DECORATOR);
+ checkQuickFix(ValidationType.PRODUCES);
}
@@ -91,7 +98,7 @@
editResourceUtil.replaceInEditor("DecoratorComponent", className);
- checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.DECORATOR);
+ checkQuickFix(ValidationType.DISPOSES);
}
@@ -110,7 +117,7 @@
editResourceUtil.replaceInEditor("@Disposes", "@Observes");
editResourceUtil.replaceInEditor("DecoratorComponent", className);
- checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.DECORATOR);
+ checkQuickFix(ValidationType.OBSERVES);
}
@@ -126,7 +133,7 @@
editResourceUtil.replaceInEditor("DecoratorComponent", className);
- checkQuickFix(CDIAnnotationsType.SPECIALIZES, CDIWizardType.DECORATOR);
+ checkQuickFix(ValidationType.SPECIALIZES);
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/IBindingValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/IBindingValidationQuickFixTest.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/IBindingValidationQuickFixTest.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -12,9 +12,11 @@
package org.jboss.tools.cdi.bot.test.quickfix.test;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
-import org.jboss.tools.cdi.bot.test.quickfix.base.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+import org.jboss.tools.cdi.bot.test.quickfix.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.IValidationProvider;
+import
org.jboss.tools.cdi.bot.test.quickfix.validators.InterceptorBindingValidationProvider;
import org.junit.Test;
/**
@@ -25,12 +27,17 @@
public class IBindingValidationQuickFixTest extends QuickFixTestBase {
+ private static IValidationProvider validationProvider = new
InterceptorBindingValidationProvider();
@Override
public String getProjectName() {
return "CDIQuickFixIBindingTest";
}
+ public IValidationProvider validationProvider() {
+ return validationProvider;
+ }
+
//
https://issues.jboss.org/browse/JBIDE-7641
@Test
public void testNonbindingAnnotation() {
@@ -44,14 +51,14 @@
editResourceUtil.replaceInEditor("IBindingComponent", className);
- checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.INTERCEPTOR_BINDING);
+ checkQuickFix(ValidationType.NONBINDING);
editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
.getResourceAsStream("/resources/quickfix/interceptorBinding/IBindingWithStringArray.java.cdi"),
false);
editResourceUtil.replaceInEditor("IBindingComponent", className);
- checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.INTERCEPTOR_BINDING);
+ checkQuickFix(ValidationType.NONBINDING);
}
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/InterceptorValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/InterceptorValidationQuickFixTest.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/InterceptorValidationQuickFixTest.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -12,9 +12,11 @@
package org.jboss.tools.cdi.bot.test.quickfix.test;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
-import org.jboss.tools.cdi.bot.test.quickfix.base.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+import org.jboss.tools.cdi.bot.test.quickfix.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.IValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.InterceptorValidationProvider;
import org.junit.Test;
/**
@@ -25,12 +27,17 @@
public class InterceptorValidationQuickFixTest extends QuickFixTestBase {
-
+ private static IValidationProvider validationProvider = new
InterceptorValidationProvider();
+
@Override
public String getProjectName() {
return "CDIQuickFixInterceptorTest";
}
+ public IValidationProvider validationProvider() {
+ return validationProvider;
+ }
+
//
https://issues.jboss.org/browse/JBIDE-7680
@Test
public void testSessionAnnotation() {
@@ -43,7 +50,7 @@
editResourceUtil.replaceInEditor("InterceptorComponent", className);
- checkQuickFix(CDIAnnotationsType.STATELESS, CDIWizardType.INTERCEPTOR);
+ checkQuickFix(ValidationType.STATELESS);
}
@@ -59,7 +66,7 @@
editResourceUtil.replaceInEditor("InterceptorComponent", className);
- checkQuickFix(CDIAnnotationsType.NAMED, CDIWizardType.INTERCEPTOR);
+ checkQuickFix(ValidationType.NAMED);
}
@@ -75,7 +82,7 @@
editResourceUtil.replaceInEditor("InterceptorComponent", className);
- checkQuickFix(CDIAnnotationsType.PRODUCES, CDIWizardType.INTERCEPTOR);
+ checkQuickFix(ValidationType.PRODUCES);
}
@@ -91,7 +98,7 @@
editResourceUtil.replaceInEditor("InterceptorComponent", className);
- checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.INTERCEPTOR);
+ checkQuickFix(ValidationType.DISPOSES);
}
@@ -110,7 +117,7 @@
editResourceUtil.replaceInEditor("@Disposes", "@Observes");
editResourceUtil.replaceInEditor("InterceptorComponent", className);
- checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.INTERCEPTOR);
+ checkQuickFix(ValidationType.OBSERVES);
}
@@ -126,7 +133,7 @@
editResourceUtil.replaceInEditor("InterceptorComponent", className);
- checkQuickFix(CDIAnnotationsType.SPECIALIZES, CDIWizardType.INTERCEPTOR);
+ checkQuickFix(ValidationType.SPECIALIZES);
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/QualifierValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/QualifierValidationQuickFixTest.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/QualifierValidationQuickFixTest.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -12,9 +12,11 @@
package org.jboss.tools.cdi.bot.test.quickfix.test;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
-import org.jboss.tools.cdi.bot.test.quickfix.base.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+import org.jboss.tools.cdi.bot.test.quickfix.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.QualifierValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.IValidationProvider;
import org.junit.Test;
/**
@@ -25,11 +27,17 @@
public class QualifierValidationQuickFixTest extends QuickFixTestBase {
+ private static IValidationProvider validationProvider = new
QualifierValidationProvider();
+
@Override
public String getProjectName() {
return "CDIQuickFixQualifierTest";
}
+ public IValidationProvider validationProvider() {
+ return validationProvider;
+ }
+
//
https://issues.jboss.org/browse/JBIDE-7630
@Test
public void testTargetAnnotation() {
@@ -41,11 +49,11 @@
editResourceUtil.replaceInEditor("@Target({ TYPE, METHOD, PARAMETER, FIELD
})",
"@Target({ TYPE, FIELD })");
- checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.QUALIFIER);
+ checkQuickFix(ValidationType.TARGET);
editResourceUtil.replaceInEditor("@Target({TYPE, METHOD, FIELD, PARAMETER})",
"");
- checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.QUALIFIER);
+ checkQuickFix(ValidationType.TARGET);
}
//
https://issues.jboss.org/browse/JBIDE-7631
@@ -58,11 +66,11 @@
editResourceUtil.replaceInEditor("@Retention(RUNTIME)",
"@Retention(CLASS)");
- checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.QUALIFIER);
+ checkQuickFix(ValidationType.RETENTION);
editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "");
- checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.QUALIFIER);
+ checkQuickFix(ValidationType.RETENTION);
}
@@ -79,12 +87,12 @@
editResourceUtil.replaceInEditor("QualifierComponent", className);
- checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.QUALIFIER);
+ checkQuickFix(ValidationType.NONBINDING);
editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
.getResourceAsStream("/resources/quickfix/qualifier/QualifierWithStringArray.java.cdi"),
false);
editResourceUtil.replaceInEditor("QualifierComponent", className);
- checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.QUALIFIER);
+ checkQuickFix(ValidationType.NONBINDING);
}
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/ScopeValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/ScopeValidationQuickFixTest.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/ScopeValidationQuickFixTest.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -12,9 +12,11 @@
package org.jboss.tools.cdi.bot.test.quickfix.test;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
-import org.jboss.tools.cdi.bot.test.quickfix.base.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+import org.jboss.tools.cdi.bot.test.quickfix.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.ScopeValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.IValidationProvider;
import org.junit.Test;
/**
@@ -25,11 +27,17 @@
public class ScopeValidationQuickFixTest extends QuickFixTestBase {
+ private static IValidationProvider validationProvider = new ScopeValidationProvider();
+
@Override
public String getProjectName() {
return "CDIQuickFixScopeTest";
}
+ public IValidationProvider validationProvider() {
+ return validationProvider;
+ }
+
//
https://issues.jboss.org/browse/JBIDE-7633
@Test
public void testTargetAnnotation() {
@@ -41,11 +49,11 @@
editResourceUtil.replaceInEditor("@Target({ TYPE, METHOD, FIELD })",
"@Target({ TYPE, FIELD })");
- checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.SCOPE);
+ checkQuickFix(ValidationType.TARGET);
editResourceUtil.replaceInEditor("@Target({TYPE, METHOD, FIELD})",
"");
- checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.SCOPE);
+ checkQuickFix(ValidationType.TARGET);
}
//
https://issues.jboss.org/browse/JBIDE-7631
@@ -58,11 +66,11 @@
editResourceUtil.replaceInEditor("@Retention(RUNTIME)",
"@Retention(CLASS)");
- checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.SCOPE);
+ checkQuickFix(ValidationType.RETENTION);
editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "");
- checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.SCOPE);
+ checkQuickFix(ValidationType.RETENTION);
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/StereotypeValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/StereotypeValidationQuickFixTest.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/test/StereotypeValidationQuickFixTest.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -12,9 +12,11 @@
package org.jboss.tools.cdi.bot.test.quickfix.test;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
-import org.jboss.tools.cdi.bot.test.quickfix.base.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+import org.jboss.tools.cdi.bot.test.quickfix.QuickFixTestBase;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.StereotypeValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.IValidationProvider;
import org.junit.Test;
/**
@@ -25,11 +27,17 @@
public class StereotypeValidationQuickFixTest extends QuickFixTestBase {
+ private static IValidationProvider validationProvider = new
StereotypeValidationProvider();
+
@Override
public String getProjectName() {
return "CDIQuickFixStereotypeTest";
}
+ public IValidationProvider validationProvider() {
+ return validationProvider;
+ }
+
//
https://issues.jboss.org/browse/JBIDE-7630
@Test
public void testTargetAnnotation() {
@@ -41,11 +49,11 @@
editResourceUtil.replaceInEditor("@Target({ TYPE, METHOD, FIELD })",
"@Target({ TYPE, FIELD })");
- checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.STEREOTYPE);
+ checkQuickFix(ValidationType.TARGET);
editResourceUtil.replaceInEditor("@Target({TYPE, METHOD, FIELD})",
"");
- checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.STEREOTYPE);
+ checkQuickFix(ValidationType.TARGET);
}
//
https://issues.jboss.org/browse/JBIDE-7631
@@ -58,11 +66,11 @@
editResourceUtil.replaceInEditor("@Retention(RUNTIME)",
"@Retention(CLASS)");
- checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.STEREOTYPE);
+ checkQuickFix(ValidationType.RETENTION);
editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "");
- checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.STEREOTYPE);
+ checkQuickFix(ValidationType.RETENTION);
}
@@ -77,7 +85,7 @@
editResourceUtil.replaceInEditor("StereotypeComponent", className);
- checkQuickFix(CDIAnnotationsType.NAMED, CDIWizardType.STEREOTYPE);
+ checkQuickFix(ValidationType.NAMED);
}
@@ -92,7 +100,7 @@
editResourceUtil.replaceInEditor("StereotypeComponent", className);
- checkQuickFix(CDIAnnotationsType.TYPED, CDIWizardType.STEREOTYPE);
+ checkQuickFix(ValidationType.TYPED);
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -12,54 +12,72 @@
package org.jboss.tools.cdi.bot.test.quickfix.validators;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.List;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
-public abstract class AbstractValidationProvider implements ValidationErrorProvider {
+public abstract class AbstractValidationProvider implements IValidationProvider {
- protected static Map<String, ArrayList<String>> validationErrors = null;
- protected static ArrayList<String> warningsForAnnotationType = null;
- protected static ArrayList<String> errorsForAnnotationType = null;
- protected static ArrayList<CDIAnnotationsType> warningsAnnotation = null;
- protected static ArrayList<CDIAnnotationsType> errorsAnnotation = null;
+ protected static List<ValidationProblem> problems = null;
- public AbstractValidationProvider() {
- validationErrors = new LinkedHashMap<String, ArrayList<String>>();
- warningsForAnnotationType = new ArrayList<String>();
- errorsForAnnotationType = new ArrayList<String>();
- warningsAnnotation = new ArrayList<CDIAnnotationsType>();
- errorsAnnotation = new ArrayList<CDIAnnotationsType>();
-
- validationErrors.put("Warnings", new ArrayList<String>());
- validationErrors.put("Errors", new ArrayList<String>());
-
+ public AbstractValidationProvider() {
+ problems = new ArrayList<ValidationProblem>();
init();
}
abstract void init();
- public Map<String, ArrayList<String>> getAllValidationErrors() {
- return validationErrors;
+ public List<String> getAllErrorsForAnnotationType(
+ ValidationType annotationType) {
+ List<String> messages = new ArrayList<String>();
+ for (ValidationProblem problem: problems) {
+ if (problem.getProblemType() == ProblemsType.ERRORS &&
+ problem.getValidationType() == annotationType) {
+ messages.add(problem.getMessage());
+ }
+ }
+ return messages;
}
- public ArrayList<String> getAllErrorsForAnnotationType(
- CDIAnnotationsType annotationType) {
- return errorsForAnnotationType;
+ public List<String> getAllWarningForAnnotationType(
+ ValidationType annotationType) {
+ List<String> messages = new ArrayList<String>();
+ for (ValidationProblem problem: problems) {
+ if (problem.getProblemType() == ProblemsType.WARNINGS &&
+ problem.getValidationType() == annotationType) {
+ messages.add(problem.getMessage());
+ }
+ }
+ return messages;
}
-
- public ArrayList<String> getAllWarningForAnnotationType(
- CDIAnnotationsType annotationType) {
- return warningsForAnnotationType;
+
+ public List<ValidationType> getAllWarningsAnnotation() {
+ List<ValidationType> annotations = new ArrayList<ValidationType>();
+ for (ValidationProblem problem: problems) {
+ if (problem.getProblemType() == ProblemsType.WARNINGS) {
+ annotations.add(problem.getValidationType());
+ }
+ }
+ return annotations;
}
-
- public ArrayList<CDIAnnotationsType> getAllWarningsAnnotation() {
- return warningsAnnotation;
+
+ public List<ValidationType> getAllErrorsAnnotation() {
+ List<ValidationType> annotations = new ArrayList<ValidationType>();
+ for (ValidationProblem problem: problems) {
+ if (problem.getProblemType() == ProblemsType.ERRORS) {
+ annotations.add(problem.getValidationType());
+ }
+ }
+ return annotations;
}
-
- public ArrayList<CDIAnnotationsType> getAllErrorsAnnotation() {
- return errorsAnnotation;
+
+ public List<ValidationType> getAllValidationProblemsType() {
+ List<ValidationType> annotations = new ArrayList<ValidationType>();
+ for (ValidationProblem problem: problems) {
+ annotations.add(problem.getValidationType());
+ }
+ return annotations;
}
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeanValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeanValidationProvider.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeanValidationProvider.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -11,10 +11,9 @@
package org.jboss.tools.cdi.bot.test.quickfix.validators;
-import java.util.ArrayList;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
-
public class BeanValidationProvider extends AbstractValidationProvider {
public BeanValidationProvider() {
@@ -23,74 +22,39 @@
@Override
void init() {
- validationErrors.get("Warnings").add("which declares a passivating scope
SessionScoped " +
- "must be passivation capable");
- validationErrors.get("Warnings").add("Multiple beans are eligible for
injection to " +
- "the injection point");
- validationErrors.get("Warnings").add("No bean is eligible for injection
to " +
- "the injection point");
- validationErrors.get("Errors").add("Bean constructor cannot have a
parameter annotated " +
- "@Disposes");
- validationErrors.get("Errors").add("Bean constructor cannot have a
parameter annotated " +
- "@Observes");
- validationErrors.get("Errors").add("Producer method has a parameter
annotated @Disposes");
- validationErrors.get("Errors").add("Producer method has a parameter
annotated @Observes");
- validationErrors.get("Errors").add("Disposer method cannot be annotated
@Inject");
- validationErrors.get("Errors").add("Observer method cannot be annotated
@Inject");
- validationErrors.get("Errors").add("Observer method has a parameter
annotated @Disposes");
- validationErrors.get("Errors").add("Producer method or field cannot be
annotated @Inject");
- warningsAnnotation.add(CDIAnnotationsType.SERIALIZABLE);
- warningsAnnotation.add(CDIAnnotationsType.INJECT);
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.SERIALIZABLE,
+ "which declares a passivating scope SessionScoped "));
- errorsAnnotation.add(CDIAnnotationsType.DISPOSES);
- errorsAnnotation.add(CDIAnnotationsType.OBSERVES);
- errorsAnnotation.add(CDIAnnotationsType.PRODUCES);
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS,
ValidationType.MULTIPLE_BEAN_ELIGIBLE,
+ "Multiple beans are eligible for injection to the injection point"));
+
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS,
ValidationType.NO_BEAN_ELIGIBLE,
+ "No bean is eligible for injection to the injection point"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.DISPOSES,
+ "Bean constructor cannot have a parameter annotated @Disposes"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.OBSERVES,
+ "Bean constructor cannot have a parameter annotated @Observes"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.DISPOSES,
+ "Producer method has a parameter annotated @Disposes"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.OBSERVES,
+ "Producer method has a parameter annotated @Observes"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.DISPOSES,
+ "Disposer method cannot be annotated @Inject"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.OBSERVES,
+ "Observer method cannot be annotated @Inject"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.OBSERVES,
+ "Observer method has a parameter annotated @Disposes"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.PRODUCES,
+ "Producer method or field cannot be annotated @Inject"));
}
- public ArrayList<String> getAllErrorsForAnnotationType(
- CDIAnnotationsType annotationType) {
- int errorIndex = 0;
- switch(annotationType) {
- case DISPOSES:
- errorIndex = 0;
- errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
- errorIndex = 2;
- errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
- errorIndex = 4;
- break;
- case OBSERVES:
- errorIndex = 1;
- errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
- errorIndex = 3;
- errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
- errorIndex = 5;
- errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
- errorIndex = 6;
- break;
- case PRODUCES:
- errorIndex = 7;
- break;
- }
- errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
- return errorsForAnnotationType;
- }
-
- public ArrayList<String> getAllWarningForAnnotationType(
- CDIAnnotationsType annotationType) {
- int warningIndex = 0;
- switch(annotationType) {
- case SERIALIZABLE:
- warningIndex = 0;
- break;
- case INJECT:
- warningIndex = 1;
- warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
- warningIndex = 2;
- break;
- }
- warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
- return warningsForAnnotationType;
- }
-
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeansXmlValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeansXmlValidationProvider.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeansXmlValidationProvider.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -11,11 +11,10 @@
package org.jboss.tools.cdi.bot.test.quickfix.validators;
-import java.util.ArrayList;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
-
public class BeansXmlValidationProvider extends AbstractValidationProvider {
public BeansXmlValidationProvider() {
@@ -24,19 +23,19 @@
@Override
void init() {
- validationErrors.get("Errors").add("There is no class with the specified
name");
- validationErrors.get("Errors").add("There is no annotation with the
specified name");
- validationErrors.get("Errors").add("<class> element must specify
the name of an " +
- "alternative bean class");
- validationErrors.get("Errors").add("<stereotype> element must
specify the name of " +
- "an @Alternative stereotype annotation");
- errorsAnnotation.add(CDIAnnotationsType.INJECT);
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.NO_CLASS,
+ "There is no class with the specified name"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.NO_ANNOTATION,
+ "There is no annotation with the specified name"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS,
ValidationType.ALTERNATIVE_BEAN_XML,
+ "<class> element must specify the name of an alternative bean
class"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS,
ValidationType.ALTERNATIVE_STEREOTYPE_BEAN_XML,
+ "<stereotype> element must specify the name of an @Alternative stereotype
annotation"));
+
}
- public ArrayList<String> getAllErrorsForAnnotationType(
- CDIAnnotationsType annotationType) {
- return validationErrors.get("Errors");
- }
-
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -11,10 +11,9 @@
package org.jboss.tools.cdi.bot.test.quickfix.validators;
-import java.util.ArrayList;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
-
public class DecoratorValidationProvider extends AbstractValidationProvider {
public DecoratorValidationProvider() {
@@ -23,61 +22,25 @@
@Override
void init() {
- validationErrors.get("Warnings").add("Decorator should not have a
name");
- validationErrors.get("Warnings").add("Decorator should not be annotated
" +
- "@Specializes");
- validationErrors.get("Errors").add("Producer cannot be declared in a
" +
- "decorator");
- validationErrors.get("Errors").add("Decorator has a method annotated
" +
- "@Disposes");
- validationErrors.get("Errors").add("Decorator cannot have a method with
a " +
- "parameter annotated @Observes");
- validationErrors.get("Errors").add("Bean class of a session bean cannot
be annotated " +
- "@Decorator");
- warningsAnnotation.add(CDIAnnotationsType.NAMED);
- warningsAnnotation.add(CDIAnnotationsType.SPECIALIZES);
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.NAMED,
+ "Decorator should not have a name"));
- errorsAnnotation.add(CDIAnnotationsType.PRODUCES);
- errorsAnnotation.add(CDIAnnotationsType.DISPOSES);
- errorsAnnotation.add(CDIAnnotationsType.OBSERVES);
- errorsAnnotation.add(CDIAnnotationsType.STATELESS);
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.SPECIALIZES,
+ "Decorator should not be annotated @Specializes"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.PRODUCES,
+ "Producer cannot be declared in a decorator"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.DISPOSES,
+ "Decorator has a method annotated @Disposes"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.OBSERVES,
+ "Decorator cannot have a method with a parameter annotated @Observes"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.STATELESS,
+ "Bean class of a session bean cannot be annotated @Decorator"));
+
}
- public ArrayList<String> getAllErrorsForAnnotationType(
- CDIAnnotationsType annotationType) {
- int errorIndex = 0;
- switch(annotationType) {
- case PRODUCES:
- errorIndex = 0;
- break;
- case DISPOSES:
- errorIndex = 1;
- break;
- case OBSERVES:
- errorIndex = 2;
- break;
- case STATELESS:
- errorIndex = 3;
- break;
- }
- errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
- return errorsForAnnotationType;
- }
-
- public ArrayList<String> getAllWarningForAnnotationType(
- CDIAnnotationsType annotationType) {
- int warningIndex = 0;
- switch(annotationType) {
- case NAMED:
- warningIndex = 0;
- break;
- case SPECIALIZES:
- warningIndex = 1;
- break;
- }
- warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
- return warningsForAnnotationType;
- }
-
}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/IValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/IValidationProvider.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/IValidationProvider.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.List;
+
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+
+public interface IValidationProvider {
+
+ /**
+ * Method gets all validation problems type for component
+ *
+ * @param annotationType
+ * @return
+ */
+ List<ValidationType> getAllValidationProblemsType();
+
+ /**
+ * Method gets all validation errors showed in Problems View as warnings
+ * according to entered annotation
+ *
+ * @param annotationType
+ * @return
+ */
+ List<String> getAllWarningForAnnotationType(ValidationType annotationType);
+
+ /**
+ * Method gets all validation errors showed in Problems View as errors
+ * according to entered annotation
+ *
+ * @param annotationType
+ * @return
+ */
+ List<String> getAllErrorsForAnnotationType(ValidationType annotationType);
+
+ /**
+ * Method gets all annotations for which exist validation errors showed in Problems
View
+ * marked as warning
+ *
+ * @return
+ */
+ List<ValidationType> getAllWarningsAnnotation();
+
+ /**
+ * Method gets all annotations for which exist validation errors showed in Problems
View
+ * marked as errors
+ *
+ * @return
+ */
+ List<ValidationType> getAllErrorsAnnotation();
+
+}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -11,10 +11,9 @@
package org.jboss.tools.cdi.bot.test.quickfix.validators;
-import java.util.ArrayList;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
-
public class InterceptorBindingValidationProvider extends AbstractValidationProvider {
public InterceptorBindingValidationProvider() {
@@ -23,17 +22,13 @@
@Override
void init() {
- validationErrors.get("Warnings").add("Annotation-valued member of an
interceptor " +
- "binding type should be annotated @Nonbinding");
- validationErrors.get("Warnings").add("Array-valued member of an
interceptor " +
- "binding type must be annotated @Nonbinding");
- warningsAnnotation.add(CDIAnnotationsType.NONBINDING);
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.NONBINDING,
+ "Annotation-valued member of an interceptor binding type should be annotated
@Nonbinding"));
+
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.NONBINDING,
+ "Array-valued member of an interceptor binding type must be annotated
@Nonbinding"));
+
}
- public ArrayList<String> getAllWarningForAnnotationType(
- CDIAnnotationsType annotationType) {
- return validationErrors.get("Warnings");
- }
-
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -11,10 +11,9 @@
package org.jboss.tools.cdi.bot.test.quickfix.validators;
-import java.util.ArrayList;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
-
public class InterceptorValidationProvider extends AbstractValidationProvider {
public InterceptorValidationProvider() {
@@ -23,62 +22,26 @@
@Override
void init() {
- validationErrors.get("Warnings").add("Interceptor should not have a
name");
- validationErrors.get("Warnings").add("Interceptor should not be
annotated " +
- "@Specializes");
- validationErrors.get("Errors").add("Producer cannot be declared in an
" +
- "interceptor");
- validationErrors.get("Errors").add("Interceptor has a method annotated
" +
- "@Disposes");
- validationErrors.get("Errors").add("Interceptor cannot have a method
with a " +
- "parameter annotated @Observes");
- validationErrors.get("Errors").add("Bean class of a session bean cannot
be annotated " +
- "@Interceptor");
- warningsAnnotation.add(CDIAnnotationsType.NAMED);
- warningsAnnotation.add(CDIAnnotationsType.SPECIALIZES);
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.NAMED,
+ "Interceptor should not have a name"));
- errorsAnnotation.add(CDIAnnotationsType.PRODUCES);
- errorsAnnotation.add(CDIAnnotationsType.DISPOSES);
- errorsAnnotation.add(CDIAnnotationsType.OBSERVES);
- errorsAnnotation.add(CDIAnnotationsType.STATELESS);
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.SPECIALIZES,
+ "Interceptor should not be annotated @Specializes"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.PRODUCES,
+ "Producer cannot be declared in an interceptor"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.DISPOSES,
+ "Interceptor has a method annotated @Disposes"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.OBSERVES,
+ "Interceptor cannot have a method with a parameter annotated @Observes"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.STATELESS,
+ "Bean class of a session bean cannot be annotated @Interceptor"));
+
}
- public ArrayList<String> getAllErrorsForAnnotationType(
- CDIAnnotationsType annotationType) {
- int errorIndex = 0;
- switch(annotationType) {
- case PRODUCES:
- errorIndex = 0;
- break;
- case DISPOSES:
- errorIndex = 1;
- break;
- case OBSERVES:
- errorIndex = 2;
- break;
- case STATELESS:
- errorIndex = 3;
- break;
- }
- errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
- return errorsForAnnotationType;
- }
-
- public ArrayList<String> getAllWarningForAnnotationType(
- CDIAnnotationsType annotationType) {
- int warningIndex = 0;
- switch(annotationType) {
- case NAMED:
- warningIndex = 0;
- break;
- case SPECIALIZES:
- warningIndex = 1;
- break;
- }
- warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
- return warningsForAnnotationType;
- }
-
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -11,10 +11,9 @@
package org.jboss.tools.cdi.bot.test.quickfix.validators;
-import java.util.ArrayList;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
-
public class QualifierValidationProvider extends AbstractValidationProvider {
public QualifierValidationProvider() {
@@ -23,23 +22,19 @@
@Override
void init() {
- validationErrors.get("Warnings").add("Qualifier annotation type must be
annotated " +
- "with @Retention(RUNTIME)");
- validationErrors.get("Warnings").add("Qualifier annotation type must be
annotated with " +
- "@Target");
- validationErrors.get("Warnings").add("Annotation-valued member of a
qualifier type " +
- "should be annotated @Nonbinding");
- validationErrors.get("Warnings").add("Array-valued member of a qualifier
type " +
- "should be annotated @Nonbinding");
- warningsAnnotation.add(CDIAnnotationsType.RETENTION);
- warningsAnnotation.add(CDIAnnotationsType.TARGET);
- warningsAnnotation.add(CDIAnnotationsType.NONBINDING);
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.RETENTION,
+ "Qualifier annotation type must be annotated with @Retention(RUNTIME)"));
+
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.TARGET,
+ "Qualifier annotation type must be annotated with @Target"));
+
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.NONBINDING,
+ "Annotation-valued member of a qualifier type should be annotated
@Nonbinding"));
+
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.NONBINDING,
+ "Array-valued member of a qualifier type should be annotated
@Nonbinding"));
+
}
- public ArrayList<String> getAllWarningForAnnotationType(
- CDIAnnotationsType annotationType) {
- return validationErrors.get("Warnings");
- }
-
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -11,10 +11,9 @@
package org.jboss.tools.cdi.bot.test.quickfix.validators;
-import java.util.ArrayList;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
-
public class ScopeValidationProvider extends AbstractValidationProvider {
public ScopeValidationProvider() {
@@ -23,18 +22,13 @@
@Override
void init() {
- validationErrors.get("Warnings").add("Scope annotation type must be
annotated " +
- "with @Retention(RUNTIME)");
- validationErrors.get("Warnings").add("Scope annotation type must be
annotated with " +
- "@Target");
- warningsAnnotation.add(CDIAnnotationsType.RETENTION);
- warningsAnnotation.add(CDIAnnotationsType.TARGET);
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.RETENTION,
+ "Scope annotation type must be annotated with @Retention(RUNTIME)"));
+
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.TARGET,
+ "Scope annotation type must be annotated with @Target"));
+
}
- public ArrayList<String> getAllWarningForAnnotationType(
- CDIAnnotationsType annotationType) {
- return validationErrors.get("Warnings");
- }
-
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -11,10 +11,9 @@
package org.jboss.tools.cdi.bot.test.quickfix.validators;
-import java.util.ArrayList;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
-
public class StereotypeValidationProvider extends AbstractValidationProvider {
public StereotypeValidationProvider() {
@@ -23,47 +22,19 @@
@Override
void init() {
- validationErrors.get("Warnings").add("Stereotype annotation type must be
annotated with one of");
- validationErrors.get("Warnings").add("Stereotype annotation type must be
annotated " +
- "with @Retention(RUNTIME)");
- validationErrors.get("Warnings").add("A stereotype should not be
annotated @Typed");
- validationErrors.get("Errors").add("Stereotype declares a non-empty
@Named annotation");
- warningsAnnotation.add(CDIAnnotationsType.TARGET);
- warningsAnnotation.add(CDIAnnotationsType.RETENTION);
- warningsAnnotation.add(CDIAnnotationsType.TYPED);
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.TARGET,
+ "Stereotype annotation type must be annotated with one of"));
- errorsAnnotation.add(CDIAnnotationsType.NAMED);
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.RETENTION,
+ "Stereotype annotation type must be annotated with @Retention(RUNTIME)"));
+
+ problems.add(new ValidationProblem(ProblemsType.WARNINGS, ValidationType.TYPED,
+ "A stereotype should not be annotated @Typed"));
+
+ problems.add(new ValidationProblem(ProblemsType.ERRORS, ValidationType.NAMED,
+ "Stereotype declares a non-empty @Named annotation"));
+
}
-
- public ArrayList<String> getAllErrorsForAnnotationType(
- CDIAnnotationsType annotationType) {
- int errorIndex = 0;
- switch (annotationType) {
- case NAMED:
- errorIndex = 0;
- break;
- }
- errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
- return errorsForAnnotationType;
- }
-
- public ArrayList<String> getAllWarningForAnnotationType(
- CDIAnnotationsType annotationType) {
- int warningIndex = 0;
- switch(annotationType) {
- case TARGET:
- warningIndex = 0;
- break;
- case RETENTION:
- warningIndex = 1;
- break;
- case TYPED:
- warningIndex = 2;
- break;
- }
- warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
- return warningsForAnnotationType;
- }
}
Deleted:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.cdi.bot.test.quickfix.validators;
-
-import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-public interface ValidationErrorProvider {
-
- /**
- * Method gets all validation errors showed in Problems View for actual component
- * @return
- */
- Map<String, ArrayList<String>> getAllValidationErrors();
-
- /**
- * Method gets all validation errors showed in Problems View as warnings
- * according to entered annotation
- *
- * @param annotationType
- * @return
- */
- ArrayList<String> getAllWarningForAnnotationType(CDIAnnotationsType
annotationType);
-
- /**
- * Method gets all validation errors showed in Problems View as errors
- * according to entered annotation
- *
- * @param annotationType
- * @return
- */
- ArrayList<String> getAllErrorsForAnnotationType(CDIAnnotationsType
annotationType);
-
- /**
- * Method gets all annotations for which exist validation errors showed in Problems
View
- * marked as warning
- *
- * @return
- */
- ArrayList<CDIAnnotationsType> getAllWarningsAnnotation();
-
- /**
- * Method gets all annotations for which exist validation errors showed in Problems
View
- * marked as errors
- *
- * @return
- */
- ArrayList<CDIAnnotationsType> getAllErrorsAnnotation();
-
-}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationProblem.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationProblem.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationProblem.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.annotations.ValidationType;
+
+public class ValidationProblem {
+
+ private ProblemsType problemType;
+
+ private ValidationType validationType;
+
+ private String message;
+
+ public ValidationProblem(ProblemsType problemType, ValidationType validationType, String
message) {
+ this.problemType = problemType;
+ this.validationType = validationType;
+ this.message = message;
+ }
+
+ public ProblemsType getProblemType() {
+ return problemType;
+ }
+
+ public ValidationType getValidationType() {
+ return validationType;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -48,24 +48,9 @@
*/
public boolean checkValidationErrorInBeansXML(String projectName,
BeansXMLValidationErrors validationError) {
- SWTBotTreeItem[] validationErrors = getBeansXMLValidationErrors(projectName);
- String error = null;
- switch (validationError) {
- case NO_SUCH_CLASS:
- error = "There is no class with the specified name";
- break;
- case ALTERNATIVE:
- error = "must specify the name of an alternative bean class";
- break;
- case DECORATOR:
- error = "must specify the name of a decorator bean class";
- break;
- case INTERCEPTOR:
- error = "must specify the name of an interceptor class";
- break;
- }
+ SWTBotTreeItem[] validationErrors = getBeansXMLValidationErrors(projectName);
return ((validationErrors.length == 1) &&
- (validationErrors[0].getText().contains(error)));
+ (validationErrors[0].getText().contains(validationError.message())));
}
/**
@@ -123,7 +108,7 @@
*/
public SWTBotTreeItem[] getBeansXMLValidationErrors(String projectName) {
return ProblemsView.getFilteredErrorsTreeItems(bot, null, "/"
- + projectName + "/WebContent/WEB-INF", "beans.xml", "CDI
Problem");
+ + projectName, "beans.xml", "CDI Problem");
}
/**
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -20,10 +20,12 @@
public class DynamicWebProjectWizard extends Wizard {
- private static final String PROJECT_NAME = "Project name:";
- private static final String CDI_PRESET = "Dynamic Web Project " +
+ private final String PROJECT_NAME = "Project name:";
+ private final String CDI_PRESET = "Dynamic Web Project " +
"with CDI (Context and Dependency Injection)";
- private static final String CDI_FACET = "CDI (Contexts and Dependency
Injection)";
+ private final String CDI_FACET = "CDI (Contexts and Dependency Injection)";
+ private final String CONFIGURATION = "Configuration";
+ private final String PROJECT_FACETS = "Project Facets";
public DynamicWebProjectWizard() {
super(new SWTBot().activeShell().widget);
@@ -36,7 +38,7 @@
}
public DynamicWebProjectWizard setCDIPreset() {
- bot().comboBoxInGroup("Configuration", 0).
+ bot().comboBoxInGroup(CONFIGURATION, 0).
setSelection(CDI_PRESET);
return this;
}
@@ -49,7 +51,7 @@
}
private void setCDIFacetInFacets(SWTBot bot) {
- assertTrue(bot.activeShell().getText().equals("Project Facets"));
+ assertTrue(bot.activeShell().getText().equals(PROJECT_FACETS));
SWTBot facetsBot = bot.activeShell().bot();
SWTBotTree tree= facetsBot.tree();
for (SWTBotTreeItem ti: tree.getAllItems()) {
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java 2012-01-16
11:59:04 UTC (rev 37860)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java 2012-01-16
13:48:45 UTC (rev 37861)
@@ -34,7 +34,7 @@
public class WizardTest extends CDITestBase {
public String getProjectName() {
- return "CDIwizardExtTest";
+ return "CDIWizardTest";
}
@Override
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt 2012-01-16 11:59:04 UTC (rev
37860)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt 2012-01-16 13:48:45 UTC (rev
37861)
@@ -2,13 +2,8 @@
what tests have to be done(JBDS50_0010):
* Validations works good for Inconsistent specialization,
Ambiguous EL names, Unproxyable bean types, Decorator resolution
- * Quick fixes for problem markers in
beans.xml(https://issues.jboss.org/browse/JBIDE-9833)
- * CDI @Named beans are renamed via refactoring and shows up correctly
- when using Find References for EL Expressions
* Create new decorator from existing Web Bean
- * EL refactoring for @Named beans works
-
what tests have to be done(JBDS50_0015):
* OpenOn works for injected classes
* OpenOn works in Seam Config for given beans