[jbosstools-commits] JBoss Tools SVN: r43697 - in branches/jbosstools-3.3.x/ws: plugins/org.jboss.tools.ws.jaxrs.core/META-INF and 13 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Fri Sep 14 11:23:29 EDT 2012
Author: xcoulon
Date: 2012-09-14 11:23:28 -0400 (Fri, 14 Sep 2012)
New Revision: 43697
Added:
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/EnumJaxrsElements.java
Modified:
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/.classpath
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/build.properties
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceField.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java
branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/contentassist/PathParamAnnotationValueCompletionProposalComputer.java
branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/.classpath
branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java
branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java
branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java
branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java
branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java
branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java
branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java
branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java
branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java
Log:
Fixed - JBIDE-12619 CLONE - Building JAX-RS metamodel is very slow at times
Fixed - JBIDE-12618 CLONE - Remove need for jax-rs-api.jar
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/.classpath
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/.classpath 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/.classpath 2012-09-14 15:23:28 UTC (rev 43697)
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib" path="lib/jaxrs-api.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF 2012-09-14 15:23:28 UTC (rev 43697)
@@ -26,13 +26,11 @@
org.eclipse.core.resources;bundle-version="3.5.1";visibility:=reexport,
org.eclipse.jst.j2ee;bundle-version="1.1.301";visibility:=reexport,
org.eclipse.emf.ecore;bundle-version="2.5.0";visibility:=reexport,
- org.eclipse.wst.common.frameworks.ui;bundle-version="1.1.301"
+ org.eclipse.wst.common.frameworks.ui;bundle-version="1.1.301",
+ org.eclipse.jface.text;bundle-version="3.7.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Export-Package: javax.ws.rs,
- javax.ws.rs.core,
- javax.ws.rs.ext,
- org.jboss.tools.ws.jaxrs.core;x-friends:="org.jboss.tools.ws.jaxrs.core.test",
+Export-Package: org.jboss.tools.ws.jaxrs.core;x-friends:="org.jboss.tools.ws.jaxrs.core.test",
org.jboss.tools.ws.jaxrs.core.configuration,
org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder;x-friends:="org.jboss.tools.ws.jaxrs.core.test",
org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;x-friends:="org.jboss.tools.ws.jaxrs.core.test",
@@ -40,5 +38,4 @@
org.jboss.tools.ws.jaxrs.core.jdt,
org.jboss.tools.ws.jaxrs.core.metamodel,
org.jboss.tools.ws.jaxrs.core.pubsub
-Bundle-ClassPath: .,
- lib/jaxrs-api.jar
+Bundle-ClassPath: .
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/build.properties
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/build.properties 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/build.properties 2012-09-14 15:23:28 UTC (rev 43697)
@@ -3,7 +3,6 @@
bin.includes = META-INF/,\
plugin.xml,\
plugin.properties,\
- lib/jaxrs-api.jar,\
.
jars.compile.order = .,\
lib/jaxrs-api.jar
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -21,6 +21,7 @@
import static org.eclipse.jdt.core.IJavaElementDelta.CHANGED;
import static org.eclipse.jdt.core.IJavaElementDelta.REMOVED;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_NONE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
import java.util.ArrayList;
import java.util.Collections;
@@ -28,8 +29,6 @@
import java.util.List;
import java.util.Map;
-import javax.ws.rs.HttpMethod;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IAnnotation;
@@ -183,7 +182,7 @@
progressMonitor);
for (IType type : matchingHttpMethodTypes) {
final CompilationUnit ast = JdtUtils.parse(type, progressMonitor);
- final Annotation annotation = JdtUtils.resolveAnnotation(type, ast, HttpMethod.class);
+ final Annotation annotation = JdtUtils.resolveAnnotation(type, ast, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = factory.createHttpMethod(annotation, ast, metamodel);
metamodel.add(httpMethod);
if (httpMethod != null) {
@@ -306,6 +305,7 @@
* @param progressMonitor
* @throws CoreException
*/
+ @SuppressWarnings("incomplete-switch")
private List<JaxrsElementDelta> processAddition(final IAnnotation javaAnnotation, final CompilationUnit ast,
final JaxrsMetamodel metamodel, final IProgressMonitor progressMonitor) throws CoreException {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
@@ -341,6 +341,7 @@
* @throws CoreException
*/
// FIXME : same code as method processAddition(annotation, etc..) ?!?
+ @SuppressWarnings("incomplete-switch")
private List<JaxrsElementDelta> processChange(final IAnnotation javaAnnotation, final CompilationUnit ast,
final JaxrsMetamodel metamodel, final IProgressMonitor progressMonitor) throws CoreException {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -96,20 +96,6 @@
* the progress monitor
*/
private void build(final int buildKind, final IProject project, final IProgressMonitor progressMonitor) {
- /*
- * progressMonitor.beginTask("Building JAX-RS Metamodel", 4 * SCALE);
- * Logger.debug("Building JAX-RS Metamodel for project {}...", project.getName()); // extract the relevant delta
- * bound to this built (some resources or entire project) final List<ResourceDelta> affectedResources =
- * extractAffectedResources(project, progressMonitor); progressMonitor.worked(SCALE); // compute changes on the
- * JAX-RS Application(s), HttpMethods, Resources, etc. final boolean withReset = (buildKind == FULL_BUILD ||
- * buildKind == CLEAN_BUILD); final JaxrsMetamodelDelta metamodelDelta = resourceChangedProcessor
- * .processAffectedResources(project, withReset, affectedResources, new SubProgressMonitor(progressMonitor,
- * SCALE)); progressMonitor.worked(SCALE); new
- * JaxrsMetamodelChangedProcessor().processAffectedMetamodel(metamodelDelta, new
- * SubProgressMonitor(progressMonitor, SCALE)); progressMonitor.worked(SCALE); new
- * JaxrsElementChangedPublisher().publish(metamodelDelta, new SubProgressMonitor(progressMonitor, SCALE));
- * progressMonitor.worked(SCALE);
- */
ResourceChangedBuildJob job = new ResourceChangedBuildJob(project, getResourceChangeEvent(project, buildKind));
job.setRule(MutexJobSchedulingRule.getInstance());
job.schedule();
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -84,6 +84,7 @@
return metamodelDelta;
}
+ @SuppressWarnings("incomplete-switch")
private List<JaxrsEndpointDelta> processEvent(final JaxrsElementDelta event) throws CoreException {
final JaxrsBaseElement element = event.getElement();
final EnumElementKind elementKind = element.getElementKind();
@@ -160,6 +161,7 @@
return changes;
}
+ @SuppressWarnings("incomplete-switch")
private List<JaxrsEndpointDelta> processAddition(final JaxrsResourceMethod resourceMethod) throws CoreException {
final List<JaxrsEndpointDelta> changes = new ArrayList<JaxrsEndpointDelta>();
final JaxrsMetamodel metamodel = (JaxrsMetamodel) resourceMethod.getMetamodel();
@@ -236,6 +238,7 @@
}
// FIXME: support chain of subresource locators
+ @SuppressWarnings("incomplete-switch")
private List<JaxrsEndpointDelta> processSubresourceLocatorAddition(final JaxrsResourceMethod subresourceLocator,
final JaxrsMetamodel metamodel) throws CoreException {
final List<JaxrsEndpointDelta> changes = new ArrayList<JaxrsEndpointDelta>();
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -15,6 +15,7 @@
import static org.eclipse.jdt.core.IJavaElementDelta.REMOVED;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_ELEMENT_KIND;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_FINE_GRAINED;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.APPLICATION;
import java.util.ArrayList;
import java.util.Collection;
@@ -24,13 +25,12 @@
import java.util.Map;
import java.util.Map.Entry;
-import javax.ws.rs.core.Application;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaCore;
@@ -103,18 +103,18 @@
final JaxrsMetamodel metamodel = JaxrsMetamodel.create(JavaCore.create(project));
final JaxrsMetamodelDelta metamodelDelta = new JaxrsMetamodelDelta(metamodel, deltaKind);
try {
- progressMonitor.beginTask("Processing Project '" + project.getName() + "'...", 1);
- Logger.debug("Processing Project '" + project.getName() + "'...");
+ progressMonitor.beginTask("Processing project '" + project.getName() + "'...", 1);
+ Logger.debug("Processing project '" + project.getName() + "'...");
metamodelDelta.addAll(processEvent(new ResourceDelta(project, ADDED, 0), progressMonitor));
if(WtpUtils.hasWebDeploymentDescriptor(project)) {
processEvent(new ResourceDelta(WtpUtils.getWebDeploymentDescriptor(project), ADDED, 0), progressMonitor);
}
progressMonitor.worked(1);
} catch (CoreException e) {
- Logger.error("Failed while processing Resource results", e);
+ Logger.error("Failed while processing resource results", e);
} finally {
progressMonitor.done();
- Logger.debug("Done processing Resource results.");
+ Logger.debug("Done processing resource results.");
}
@@ -145,7 +145,6 @@
elementChanges.addAll(processEvent(event, progressMonitor));
progressMonitor.worked(1);
}
-
} catch (CoreException e) {
Logger.error("Failed while processing Resource results", e);
elementChanges.clear();
@@ -168,7 +167,9 @@
final IJavaElement scope = JavaCore.create(resource);
final JaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(resource.getProject());
final int deltaKind = event.getDeltaKind();
- if (scope != null) {
+ if (scope != null &&
+ // ignore changes on binary files (added/removed/changed jars to improve builder performances)
+ !(scope.getElementType() == IJavaElement.PACKAGE_FRAGMENT_ROOT && ((IPackageFragmentRoot)scope).isArchive())) {
switch (deltaKind) {
case ADDED:
case CHANGED:
@@ -200,7 +201,7 @@
private List<JaxrsElementDelta> processApplicationChangesOnWebxmlAdditionOrChange(IResource resource,
JaxrsMetamodel metamodel, IProgressMonitor progressMonitor) throws CoreException {
- final IType applicationType = JdtUtils.resolveType(Application.class.getName(), metamodel.getJavaProject(),
+ final IType applicationType = JdtUtils.resolveType(APPLICATION.qualifiedName, metamodel.getJavaProject(),
progressMonitor);
// occurs when the project has the jax-rs nature (the builder is called), but no jaxrs library is in the classpath
if(applicationType == null) {
Added: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java (rev 0)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.ws.jaxrs.core.internal.metamodel.domain;
+
+import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
+
+/**
+ * Built-in Http Methods as part of the JAX-RS 1.1 specification
+ * @author Xavier Coulon
+ *
+ */
+public class JaxrsBuiltinHttpMethod extends JaxrsHttpMethod {
+
+ public static final JaxrsHttpMethod GET = new JaxrsBuiltinHttpMethod("javax.ws.rs.GET", "GET");
+ public static final JaxrsHttpMethod POST = new JaxrsBuiltinHttpMethod("javax.ws.rs.POST", "POST");
+ public static final JaxrsHttpMethod PUT = new JaxrsBuiltinHttpMethod("javax.ws.rs.PUT", "PUT");
+ public static final JaxrsHttpMethod DELETE = new JaxrsBuiltinHttpMethod("javax.ws.rs.DELETE", "DELETE");
+ public static final JaxrsHttpMethod OPTIONS = new JaxrsBuiltinHttpMethod("javax.ws.rs.OPTIONS", "OPTIONS");
+ public static final JaxrsHttpMethod HEAD = new JaxrsBuiltinHttpMethod("javax.ws.rs.HEAD", "HEAD");
+
+ private final String annotationName;
+ private final String httpVerb;
+
+ public JaxrsBuiltinHttpMethod(String annotationName, String annotationValue) {
+ super(null, new Annotation(null, annotationName, annotationValue, null), null);
+ this.annotationName = annotationName;
+ this.httpVerb = annotationValue;
+ }
+
+ @Override
+ public String getHttpVerb() {
+ return this.httpVerb;
+ }
+
+ @Override
+ public String getFullyQualifiedName() {
+ return annotationName;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((annotationName == null) ? 0 : annotationName.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ JaxrsBuiltinHttpMethod other = (JaxrsBuiltinHttpMethod) obj;
+ if (annotationName == null) {
+ if (other.annotationName != null) {
+ return false;
+ }
+ } else if (!annotationName.equals(other.annotationName)) {
+ return false;
+ }
+ return true;
+ }
+
+
+
+}
Property changes on: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -1,7 +1,8 @@
/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
+Le * Copyright (c) 2008 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
+ * real racin
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
@@ -13,24 +14,23 @@
import static org.eclipse.jdt.core.IJavaElement.FIELD;
import static org.eclipse.jdt.core.IJavaElement.METHOD;
import static org.eclipse.jdt.core.IJavaElement.TYPE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.APPLICATION_PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.CONSUMES;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.COOKIE_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.DEFAULT_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HEADER_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.MATRIX_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PRODUCES;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.QUERY_PARAM;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.CookieParam;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.MatrixParam;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -71,31 +71,31 @@
return null;
}
final String annotationName = annotation.getName();
- if (annotationName.equals(HttpMethod.class.getName())) {
+ if (annotationName.equals(HTTP_METHOD.qualifiedName)) {
final JaxrsHttpMethod httpMethod = createHttpMethod(annotation, ast, metamodel);
return httpMethod;
- } else if (annotationName.equals(ApplicationPath.class.getName())) {
+ } else if (annotationName.equals(APPLICATION_PATH.qualifiedName)) {
final JaxrsJavaApplication application = createApplication(annotation, ast, metamodel);
return application;
} else {
switch (javaAnnotation.getParent().getElementType()) {
case TYPE:
- if (annotationName.equals(Path.class.getName())) {
+ if (annotationName.equals(PATH.qualifiedName)) {
return createResource(annotation, ast, metamodel);
}
break;
case METHOD:
final JaxrsHttpMethod httpMethod = (JaxrsHttpMethod) metamodel.getHttpMethod(annotationName);
- if (annotationName.equals(Path.class.getName())) {
+ if (annotationName.equals(PATH.qualifiedName)) {
return createResourceMethod(annotation, ast, metamodel);
} else if (httpMethod != null) {
return createResourceMethod(annotation, ast, metamodel);
}
break;
case FIELD:
- if (annotationName.equals(PathParam.class.getName())
- || annotationName.equals(QueryParam.class.getName())
- || annotationName.equals(MatrixParam.class.getName())) {
+ if (annotationName.equals(PATH_PARAM.qualifiedName)
+ || annotationName.equals(QUERY_PARAM.qualifiedName)
+ || annotationName.equals(MATRIX_PARAM.qualifiedName)) {
return createField(annotation, ast, metamodel);
}
break;
@@ -160,11 +160,11 @@
private JaxrsResource internalCreateResource(IType type, CompilationUnit ast, JaxrsMetamodel metamodel)
throws JavaModelException {
- final Map<String, Annotation> annotations = JdtUtils.resolveAnnotations(type, ast, Path.class.getName(),
- Consumes.class.getName(), Produces.class.getName());
- final Annotation pathAnnotation = annotations.get(Path.class.getName());
- final Annotation consumesAnnotation = annotations.get(Consumes.class.getName());
- final Annotation producesAnnotation = annotations.get(Produces.class.getName());
+ final Map<String, Annotation> annotations = JdtUtils.resolveAnnotations(type, ast, PATH.qualifiedName,
+ CONSUMES.qualifiedName, PRODUCES.qualifiedName);
+ final Annotation pathAnnotation = annotations.get(PATH.qualifiedName);
+ final Annotation consumesAnnotation = annotations.get(CONSUMES.qualifiedName);
+ final Annotation producesAnnotation = annotations.get(PRODUCES.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation)
.consumes(consumesAnnotation).produces(producesAnnotation).build();
return resource;
@@ -213,14 +213,14 @@
JaxrsMetamodel metamodel, JaxrsResource parentResource) throws JavaModelException {
final List<String> httpMethodAnnotationNames = new ArrayList<String>();
for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) {
- httpMethodAnnotationNames.add(httpMethod.getJavaElement().getFullyQualifiedName());
+ httpMethodAnnotationNames.add(httpMethod.getFullyQualifiedName());
}
final List<String> annotationNames = new ArrayList<String>();
- annotationNames.addAll(Arrays.asList(Path.class.getName(), Produces.class.getName(), Consumes.class.getName()));
+ annotationNames.addAll(Arrays.asList(PATH.qualifiedName, PRODUCES.qualifiedName, CONSUMES.qualifiedName));
annotationNames.addAll(httpMethodAnnotationNames);
final Map<String, Annotation> annotations = JdtUtils.resolveAnnotations(javaMethod, ast, annotationNames);
Annotation httpMethod = null;
- final Annotation pathAnnotation = annotations.get(Path.class.getName());
+ final Annotation pathAnnotation = annotations.get(PATH.qualifiedName);
for (String httpMethodAnnotationName : httpMethodAnnotationNames) {
if (annotations.containsKey(httpMethodAnnotationName)) {
httpMethod = annotations.get(httpMethodAnnotationName);
@@ -231,8 +231,8 @@
Logger.debug("Cannot create ResourceMethod: no Path annotation nor HttpMethod found on method {}.{}()",
javaMethod.getParent().getElementName(), javaMethod.getElementName());
} else {
- final Annotation producesAnnotation = annotations.get(Produces.class.getName());
- final Annotation consumesAnnotation = annotations.get(Consumes.class.getName());
+ final Annotation producesAnnotation = annotations.get(PRODUCES.qualifiedName);
+ final Annotation consumesAnnotation = annotations.get(CONSUMES.qualifiedName);
final JavaMethodSignature methodSignature = JdtUtils.resolveMethodSignature(javaMethod, ast);
// avoid creating Resource Method when the Java Method cannot be parsed (ie, syntax/compilation error)P
if (methodSignature != null) {
@@ -263,7 +263,7 @@
*/
public JaxrsHttpMethod createHttpMethod(final IType javaType, final CompilationUnit ast,
final JaxrsMetamodel metamodel) throws CoreException {
- Annotation httpMethodAnnotation = JdtUtils.resolveAnnotation(javaType, ast, HttpMethod.class);
+ Annotation httpMethodAnnotation = JdtUtils.resolveAnnotation(javaType, ast, HTTP_METHOD.qualifiedName);
if (httpMethodAnnotation == null) {
return null;
}
@@ -284,7 +284,7 @@
public JaxrsHttpMethod createHttpMethod(final Annotation annotation, final CompilationUnit ast,
final JaxrsMetamodel metamodel) throws CoreException {
if (annotation.getJavaParent() != null && annotation.getJavaParent().getElementType() == IJavaElement.TYPE
- && annotation.getName().equals(HttpMethod.class.getName())) {
+ && annotation.getName().equals(HTTP_METHOD.qualifiedName)) {
return new JaxrsHttpMethod((IType) annotation.getJavaParent(), annotation, metamodel);
}
return null;
@@ -302,7 +302,7 @@
*/
public JaxrsJavaApplication createApplication(final IType javaType, final CompilationUnit ast,
final JaxrsMetamodel metamodel) throws CoreException {
- Annotation applicationPathAnnotation = JdtUtils.resolveAnnotation(javaType, ast, ApplicationPath.class);
+ Annotation applicationPathAnnotation = JdtUtils.resolveAnnotation(javaType, ast, APPLICATION_PATH.qualifiedName);
if (applicationPathAnnotation == null) {
return null;
}
@@ -322,7 +322,7 @@
public JaxrsJavaApplication createApplication(final Annotation annotation, final CompilationUnit ast,
final JaxrsMetamodel metamodel) throws CoreException {
if (annotation.getJavaParent() != null && annotation.getJavaParent().getElementType() == IJavaElement.TYPE
- && annotation.getName().equals(ApplicationPath.class.getName())) {
+ && annotation.getName().equals(APPLICATION_PATH.qualifiedName)) {
return new JaxrsJavaApplication((IType) annotation.getJavaParent(), annotation, metamodel);
}
return null;
@@ -363,13 +363,13 @@
private JaxrsResourceField internalCreateField(IField javaField, CompilationUnit ast, JaxrsMetamodel metamodel,
final JaxrsResource parentResource) throws JavaModelException {
- final List<String> supportedFieldAnnotations = Arrays.asList(MatrixParam.class.getName(),
- QueryParam.class.getName(), PathParam.class.getName(), CookieParam.class.getName(),
- HeaderParam.class.getName(), DefaultValue.class.getName());
+ final List<String> supportedFieldAnnotations = Arrays.asList(MATRIX_PARAM.qualifiedName,
+ QUERY_PARAM.qualifiedName, PATH_PARAM.qualifiedName, COOKIE_PARAM.qualifiedName,
+ HEADER_PARAM.qualifiedName, DEFAULT_VALUE.qualifiedName);
final Map<String, Annotation> annotations = JdtUtils.resolveAnnotations(javaField, ast,
supportedFieldAnnotations);
- if ((annotations.size() == 1 && !annotations.containsKey(DefaultValue.class.getName()))
- || (annotations.size() == 2 && annotations.containsKey(DefaultValue.class.getName()))) {
+ if ((annotations.size() == 1 && !annotations.containsKey(DEFAULT_VALUE.qualifiedName))
+ || (annotations.size() == 2 && annotations.containsKey(DEFAULT_VALUE.qualifiedName))) {
final JaxrsResourceField field = new JaxrsResourceField(javaField, new ArrayList<Annotation>(
annotations.values()), parentResource, metamodel);
return field;
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -18,6 +18,9 @@
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PATH_VALUE;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PRODUCED_MEDIATYPES_VALUE;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_QUERY_PARAM_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.DEFAULT_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.MATRIX_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.QUERY_PARAM;
import java.util.ArrayList;
import java.util.Arrays;
@@ -25,10 +28,6 @@
import java.util.LinkedList;
import java.util.List;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.MatrixParam;
-import javax.ws.rs.QueryParam;
-
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
@@ -259,13 +258,13 @@
for (Iterator<JavaMethodParameter> paramIterator = resourceMethod.getJavaMethodParameters().iterator(); paramIterator
.hasNext();) {
JavaMethodParameter parameter = paramIterator.next();
- if (parameter.getAnnotation(MatrixParam.class.getName()) != null) {
+ if (parameter.getAnnotation(MATRIX_PARAM.qualifiedName) != null) {
matrixParameters.add(parameter);
}
}
for (Iterator<JavaMethodParameter> iterator = matrixParameters.iterator(); iterator.hasNext();) {
JavaMethodParameter matrixParam = iterator.next();
- final Annotation matrixParamAnnotation = matrixParam.getAnnotation(MatrixParam.class.getName());
+ final Annotation matrixParamAnnotation = matrixParam.getAnnotation(MATRIX_PARAM.qualifiedName);
if(matrixParamAnnotation.getValue("value") != null) {
uriPathTemplateBuilder.append(";").append(matrixParamAnnotation.getValue("value")).append("={")
.append(matrixParam.getTypeName()).append("}");
@@ -278,7 +277,7 @@
for (Iterator<JavaMethodParameter> paramIterator = resourceMethod.getJavaMethodParameters().iterator(); paramIterator
.hasNext();) {
JavaMethodParameter parameter = paramIterator.next();
- if (parameter.getAnnotation(QueryParam.class.getName()) != null) {
+ if (parameter.getAnnotation(QUERY_PARAM.qualifiedName) != null) {
queryParameters.add(parameter);
}
}
@@ -286,13 +285,13 @@
uriPathTemplateBuilder.append('?');
for (Iterator<JavaMethodParameter> iterator = queryParameters.iterator(); iterator.hasNext();) {
JavaMethodParameter queryParam = iterator.next();
- final Annotation queryParamAnnotation = queryParam.getAnnotation(QueryParam.class.getName());
+ final Annotation queryParamAnnotation = queryParam.getAnnotation(QUERY_PARAM.qualifiedName);
final String paramName = queryParamAnnotation.getValue("value");
if(paramName != null) {
final String paramType = queryParam.getTypeName();
uriPathTemplateBuilder.append(paramName).append("={");
uriPathTemplateBuilder.append(paramName).append(":").append(paramType);
- final Annotation defaultValueAnnotation = queryParam.getAnnotation(DefaultValue.class.getName());
+ final Annotation defaultValueAnnotation = queryParam.getAnnotation(DEFAULT_VALUE.qualifiedName);
if (defaultValueAnnotation != null) {
uriPathTemplateBuilder.append('=').append(defaultValueAnnotation.getValue("value"));
}
@@ -377,7 +376,7 @@
@Override
public IJavaProject getJavaProject() {
- return this.httpMethod.getJavaElement().getJavaProject();
+ return this.metamodel.getJavaProject();
}
}
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -12,12 +12,11 @@
package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_HTTP_METHOD_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
import java.util.ArrayList;
import java.util.List;
-import javax.ws.rs.HttpMethod;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.jdt.core.IType;
import org.eclipse.wst.validation.ValidatorMessage;
@@ -94,9 +93,9 @@
return OTHER;
}
}
-
- public JaxrsHttpMethod(IType javaType, Annotation httpMehodAnnotation, JaxrsMetamodel metamodel) {
- super(javaType, httpMehodAnnotation, metamodel);
+
+ public JaxrsHttpMethod(IType javaType, Annotation httpMethodAnnotation, JaxrsMetamodel metamodel) {
+ super(javaType, httpMethodAnnotation, metamodel);
}
@Override
@@ -134,7 +133,7 @@
* ()
*/
@Override
- public final String getHttpVerb() {
+ public String getHttpVerb() {
final Annotation httpVerbAnnotation = getHttpMethodAnnotation();
if (httpVerbAnnotation != null) {
return httpVerbAnnotation.getValue("value");
@@ -145,7 +144,7 @@
/** @return the httpVerbAnnotation */
@Override
public Annotation getHttpMethodAnnotation() {
- return getAnnotation(HttpMethod.class.getName());
+ return getAnnotation(HTTP_METHOD.qualifiedName);
}
/*
@@ -156,8 +155,8 @@
* ()
*/
@Override
- public final String getSimpleName() {
- return getJavaElement().getElementName();
+ public String getFullyQualifiedName() {
+ return getJavaElement().getFullyQualifiedName();
}
/*
@@ -167,7 +166,7 @@
*/
@Override
public final String toString() {
- return "HttpMethod [@" + getSimpleName() + ":" + getHttpMethodAnnotation() + "]";
+ return "HttpMethod [@" + getFullyQualifiedName() + ":" + getHttpMethodAnnotation() + "]";
}
@Override
@@ -200,8 +199,8 @@
*/
public int update(JaxrsHttpMethod httpMethod) {
int flags = 0;
- final Annotation annotation = this.getAnnotation(HttpMethod.class.getName());
- final Annotation otherAnnotation = httpMethod.getAnnotation(HttpMethod.class.getName());
+ final Annotation annotation = this.getAnnotation(HTTP_METHOD.qualifiedName);
+ final Annotation otherAnnotation = httpMethod.getAnnotation(HTTP_METHOD.qualifiedName);
if (annotation != null && otherAnnotation != null && !annotation.equals(otherAnnotation)
&& annotation.update(otherAnnotation)) {
flags += F_HTTP_METHOD_VALUE;
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -11,12 +11,11 @@
package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_APPLICATION_PATH_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.APPLICATION_PATH;
import java.util.ArrayList;
import java.util.List;
-import javax.ws.rs.ApplicationPath;
-
import org.eclipse.jdt.core.IType;
import org.eclipse.wst.validation.ValidatorMessage;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
@@ -50,7 +49,7 @@
@Override
public EnumKind getKind() {
- if (getAnnotation(ApplicationPath.class.getName()) != null) {
+ if (getAnnotation(APPLICATION_PATH.qualifiedName) != null) {
return EnumKind.APPLICATION_JAVA;
}
return EnumKind.UNDEFINED;
@@ -66,7 +65,7 @@
* {@inheritDoc}
*/
public String getApplicationPath() {
- final Annotation applicationPathAnnotation = getAnnotation(ApplicationPath.class.getName());
+ final Annotation applicationPathAnnotation = getAnnotation(APPLICATION_PATH.qualifiedName);
if (applicationPathAnnotation != null) {
return applicationPathAnnotation.getValue("value");
}
@@ -82,8 +81,8 @@
*/
public int update(JaxrsJavaApplication application) {
int flags = 0;
- final Annotation annotation = this.getAnnotation(ApplicationPath.class.getName());
- final Annotation otherAnnotation = application.getAnnotation(ApplicationPath.class.getName());
+ final Annotation annotation = this.getAnnotation(APPLICATION_PATH.qualifiedName);
+ final Annotation otherAnnotation = application.getAnnotation(APPLICATION_PATH.qualifiedName);
if (annotation != null && otherAnnotation != null && !annotation.equals(otherAnnotation)
&& annotation.update(otherAnnotation)) {
flags += F_APPLICATION_PATH_VALUE;
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -22,6 +22,15 @@
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PATH_VALUE;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PRODUCED_MEDIATYPES_VALUE;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_QUERY_PARAM_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.APPLICATION_PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.CONSUMES;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.DEFAULT_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.MATRIX_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PRODUCES;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.QUERY_PARAM;
import java.util.Arrays;
import java.util.HashMap;
@@ -30,16 +39,6 @@
import java.util.Map;
import java.util.Map.Entry;
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.MatrixParam;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IMember;
import org.jboss.tools.ws.jaxrs.core.internal.utils.CollectionUtils;
@@ -160,27 +159,27 @@
private int qualifyChange(final String annotationName, EnumKind previousKind) {
int flag = F_NONE;
final EnumKind currentKind = getKind();
- if (annotationName.equals(Path.class.getName())) {
+ if (annotationName.equals(PATH.qualifiedName)) {
flag = F_PATH_VALUE;
- } else if (annotationName.equals(ApplicationPath.class.getName())) {
+ } else if (annotationName.equals(APPLICATION_PATH.qualifiedName)) {
flag = F_APPLICATION_PATH_VALUE;
- } else if (annotationName.equals(HttpMethod.class.getName())) {
+ } else if (annotationName.equals(HTTP_METHOD.qualifiedName)) {
flag = F_HTTP_METHOD_VALUE;
- } else if (annotationName.equals(PathParam.class.getName())) {
+ } else if (annotationName.equals(PATH_PARAM.qualifiedName)) {
flag = F_PATH_PARAM_VALUE;
- } else if (annotationName.equals(QueryParam.class.getName())) {
+ } else if (annotationName.equals(QUERY_PARAM.qualifiedName)) {
flag = F_QUERY_PARAM_VALUE;
- } else if (annotationName.equals(MatrixParam.class.getName())) {
+ } else if (annotationName.equals(MATRIX_PARAM.qualifiedName)) {
flag = F_MATRIX_PARAM_VALUE;
- } else if (annotationName.equals(DefaultValue.class.getName())) {
+ } else if (annotationName.equals(DEFAULT_VALUE.qualifiedName)) {
flag = F_DEFAULT_VALUE_VALUE;
- } else if (annotationName.equals(Consumes.class.getName())) {
+ } else if (annotationName.equals(CONSUMES.qualifiedName)) {
flag = F_CONSUMED_MEDIATYPES_VALUE;
- } else if (annotationName.equals(Produces.class.getName())) {
+ } else if (annotationName.equals(PRODUCES.qualifiedName)) {
flag = F_PRODUCED_MEDIATYPES_VALUE;
} else {
for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) {
- if (httpMethod.getJavaElement().getFullyQualifiedName().equals(annotationName)) {
+ if (httpMethod.getFullyQualifiedName().equals(annotationName)) {
flag = F_HTTP_METHOD_VALUE;
break;
}
@@ -207,25 +206,25 @@
final EnumKind previousKind = getKind();
final String annotationName = entry.getKey();
iterator.remove();
- if (annotationName.equals(Path.class.getName())) {
+ if (annotationName.equals(PATH.qualifiedName)) {
flag = F_PATH_VALUE;
- }else if (annotationName.equals(ApplicationPath.class.getName())) {
+ }else if (annotationName.equals(APPLICATION_PATH.qualifiedName)) {
flag = F_APPLICATION_PATH_VALUE;
- } else if (annotationName.equals(HttpMethod.class.getName())) {
+ } else if (annotationName.equals(HTTP_METHOD.qualifiedName)) {
flag = F_HTTP_METHOD_VALUE;
- } else if (annotationName.equals(PathParam.class.getName())) {
+ } else if (annotationName.equals(PATH_PARAM.qualifiedName)) {
flag = F_PATH_PARAM_VALUE;
- } else if (annotationName.equals(QueryParam.class.getName())) {
+ } else if (annotationName.equals(QUERY_PARAM.qualifiedName)) {
flag = F_QUERY_PARAM_VALUE;
- } else if (annotationName.equals(MatrixParam.class.getName())) {
+ } else if (annotationName.equals(MATRIX_PARAM.qualifiedName)) {
flag = F_MATRIX_PARAM_VALUE;
- } else if (annotationName.equals(Consumes.class.getName())) {
+ } else if (annotationName.equals(CONSUMES.qualifiedName)) {
flag = F_CONSUMED_MEDIATYPES_VALUE;
- } else if (annotationName.equals(Produces.class.getName())) {
+ } else if (annotationName.equals(PRODUCES.qualifiedName)) {
flag = F_PRODUCED_MEDIATYPES_VALUE;
} else {
for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) {
- if (httpMethod.getJavaElement().getFullyQualifiedName().equals(annotationName)) {
+ if (httpMethod.getFullyQualifiedName().equals(annotationName)) {
flag = F_HTTP_METHOD_VALUE;
break;
}
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -22,7 +22,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBuiltinHttpMethod.*;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -96,8 +96,30 @@
*/
private JaxrsMetamodel(final IJavaProject javaProject) throws CoreException {
this.javaProject = javaProject;
+ preloadHttpMethods();
}
+ /**
+ * Preload the HttpMethods collection with 6 items from the specification:
+ * <ul>
+ * <li>@GET</li>
+ * <li>@POST</li>
+ * <li>@PUT</li>
+ * <li>@DELETE</li>
+ * <li>@OPTIONS</li>
+ * <li>@HEAD</li>
+ * </ul>
+ */
+ private void preloadHttpMethods() {
+ httpMethods.addAll(Arrays.asList(GET, POST, PUT, DELETE, HEAD, OPTIONS));
+ elementsIndex.put(GET.getFullyQualifiedName(), new HashSet<JaxrsBaseElement>(Arrays.asList(GET)));
+ elementsIndex.put(POST.getFullyQualifiedName(), new HashSet<JaxrsBaseElement>(Arrays.asList(POST)));
+ elementsIndex.put(PUT.getFullyQualifiedName(), new HashSet<JaxrsBaseElement>(Arrays.asList(PUT)));
+ elementsIndex.put(DELETE.getFullyQualifiedName(), new HashSet<JaxrsBaseElement>(Arrays.asList(DELETE)));
+ elementsIndex.put(OPTIONS.getFullyQualifiedName(), new HashSet<JaxrsBaseElement>(Arrays.asList(OPTIONS)));
+ elementsIndex.put(HEAD.getFullyQualifiedName(), new HashSet<JaxrsBaseElement>(Arrays.asList(HEAD)));
+ }
+
/*
* (non-Javadoc)
* @see org.jboss.tools.ws.jaxrs.core.internal.metamodel.IMetamodel#getJavaProject ()
@@ -149,6 +171,12 @@
final JaxrsResource resource = (JaxrsResource) element;
this.resources.add(resource);
break;
+ case RESOURCE_FIELD:
+ break;
+ case RESOURCE_METHOD:
+ break;
+ default:
+ break;
}
indexElement(element);
}
@@ -324,14 +352,23 @@
public IJaxrsHttpMethod getHttpMethod(final String annotationName) throws CoreException {
IType annotationType = JdtUtils.resolveType(annotationName, javaProject, new NullProgressMonitor());
if (annotationType != null) {
- final JaxrsBaseElement element = getElement(annotationType);
+ // look for custom HTTP Methods
+ JaxrsBaseElement element = getElement(annotationType);
if (element != null && element.getElementKind() == EnumElementKind.HTTP_METHOD) {
return (IJaxrsHttpMethod) element;
}
+ // if not found, look for built-in HTTP Methods
+ else if(element == null) {
+ element = getElement(annotationType.getFullyQualifiedName());
+ if (element != null && element.getElementKind() == EnumElementKind.HTTP_METHOD) {
+ return (IJaxrsHttpMethod) element;
+ }
+ }
}
return null;
}
+
/**
* returns true if this metamodel already contains the given element.
*
@@ -346,8 +383,14 @@
if (element == null) {
return null;
}
- final String handleIdentifier = element.getHandleIdentifier();
- final Set<JaxrsBaseElement> elements = elementsIndex.get(handleIdentifier);
+ return getElement(element.getHandleIdentifier());
+ }
+
+ protected JaxrsBaseElement getElement(final String elementName) {
+ if (elementName == null) {
+ return null;
+ }
+ final Set<JaxrsBaseElement> elements = elementsIndex.get(elementName);
if (elements == null || elements.isEmpty()) {
return null;
}
@@ -444,7 +487,7 @@
public JaxrsHttpMethod getHttpMethod(Annotation httpMethodAnnotation) {
if (httpMethodAnnotation != null) {
for (IJaxrsHttpMethod httpMethod : httpMethods) {
- final String handleIdentifier1 = httpMethod.getJavaElement().getFullyQualifiedName();
+ final String handleIdentifier1 = httpMethod.getFullyQualifiedName();
final String handleIdentifier2 = httpMethodAnnotation.getName();
if (handleIdentifier1.equals(handleIdentifier2)) {
return (JaxrsHttpMethod) httpMethod;
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -11,6 +11,10 @@
package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.CONSUMES;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PRODUCES;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -18,10 +22,6 @@
import java.util.Map;
import java.util.Map.Entry;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.wst.validation.ValidatorMessage;
@@ -109,7 +109,7 @@
@Override
public final EnumKind getKind() {
- final Annotation pathAnnotation = getAnnotation(Path.class.getName());
+ final Annotation pathAnnotation = getAnnotation(PATH.qualifiedName);
if (pathAnnotation != null) {
return EnumKind.ROOT_RESOURCE;
} else if (resourceMethods.size() > 0 || resourceFields.size() > 0 || paramBeanProperties.size() > 0) {
@@ -124,7 +124,7 @@
@Override
public String getPathTemplate() {
- final Annotation pathAnnotation = getAnnotation(Path.class.getName());
+ final Annotation pathAnnotation = getAnnotation(PATH.qualifiedName);
if (pathAnnotation == null) {
return null;
}
@@ -138,13 +138,13 @@
}
public Annotation getPathAnnotation() {
- final Annotation pathAnnotation = getAnnotation(Path.class.getName());
+ final Annotation pathAnnotation = getAnnotation(PATH.qualifiedName);
return pathAnnotation;
}
@Override
public List<String> getConsumedMediaTypes() {
- final Annotation consumesAnnotation = getAnnotation(Consumes.class.getName());
+ final Annotation consumesAnnotation = getAnnotation(CONSUMES.qualifiedName);
if (consumesAnnotation != null) {
return consumesAnnotation.getValues("value");
}
@@ -153,7 +153,7 @@
@Override
public List<String> getProducedMediaTypes() {
- final Annotation producesAnnotation = getAnnotation(Produces.class.getName());
+ final Annotation producesAnnotation = getAnnotation(PRODUCES.qualifiedName);
if (producesAnnotation != null) {
return producesAnnotation.getValues("value");
}
@@ -161,7 +161,7 @@
}
public Annotation getProducesAnnotation() {
- final Annotation producesAnnotation = getAnnotation(Produces.class.getName());
+ final Annotation producesAnnotation = getAnnotation(PRODUCES.qualifiedName);
return producesAnnotation;
}
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceField.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceField.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceField.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -10,14 +10,14 @@
******************************************************************************/
package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.DEFAULT_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.MATRIX_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.QUERY_PARAM;
+
import java.util.ArrayList;
import java.util.List;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.MatrixParam;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
-
import org.eclipse.jdt.core.IField;
import org.eclipse.wst.validation.ValidatorMessage;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
@@ -44,19 +44,19 @@
}
public Annotation getPathParamAnnotation() {
- return getAnnotation(PathParam.class.getName());
+ return getAnnotation(PATH_PARAM.qualifiedName);
}
public Annotation getQueryParamAnnotation() {
- return getAnnotation(QueryParam.class.getName());
+ return getAnnotation(QUERY_PARAM.qualifiedName);
}
public Annotation getMatrixParamAnnotation() {
- return getAnnotation(MatrixParam.class.getName());
+ return getAnnotation(MATRIX_PARAM.qualifiedName);
}
public Annotation getDefaultValueAnnotation() {
- return getAnnotation(DefaultValue.class.getName());
+ return getAnnotation(DEFAULT_VALUE.qualifiedName);
}
@Override
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -19,16 +19,10 @@
import java.util.Arrays;
import java.util.List;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Request;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.*;
+
+
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
@@ -243,8 +237,7 @@
private List<ValidatorMessage> validateParamsWithContextAnnotation() throws JavaModelException {
final List<ValidatorMessage> messages = new ArrayList<ValidatorMessage>();
for (JavaMethodParameter parameter : this.javaMethodParameters) {
- final Annotation annotation = parameter.getAnnotation(Context.class
- .getName());
+ final Annotation annotation = parameter.getAnnotation(CONTEXT.qualifiedName);
final String typeName = parameter.getTypeName();
if (annotation != null && typeName != null
&& !CONTEXT_TYPE_NAMES.contains(typeName)) {
@@ -275,7 +268,7 @@
boolean matching = false;
for (JavaMethodParameter parameter : this.javaMethodParameters) {
final Annotation annotation = parameter
- .getAnnotation(PathParam.class.getName());
+ .getAnnotation(PATH_PARAM.qualifiedName);
if (annotation != null && annotation.getValue("value") != null
&& annotation.getValue("value").equals(proposal)) {
matching = true;
@@ -306,7 +299,7 @@
final List<String> pathParamValueProposals = getPathParamValueProposals();
for (JavaMethodParameter parameter : this.javaMethodParameters) {
final Annotation annotation = parameter
- .getAnnotation(PathParam.class.getName());
+ .getAnnotation(PATH_PARAM.qualifiedName);
if (annotation != null) {
final String value = annotation.getValue("value");
if(value != null) {
@@ -400,7 +393,7 @@
}
public Annotation getPathAnnotation() {
- return getAnnotation(Path.class.getName());
+ return getAnnotation(PATH.qualifiedName);
}
@Override
@@ -421,7 +414,7 @@
public Annotation getHttpMethodAnnotation() {
for (IJaxrsHttpMethod httpMethod : getMetamodel().getAllHttpMethods()) {
final Annotation annotation = getAnnotation(httpMethod
- .getJavaElement().getFullyQualifiedName());
+ .getFullyQualifiedName());
if (annotation != null) {
return annotation;
}
@@ -439,7 +432,7 @@
}
public Annotation getConsumesAnnotation() {
- return getAnnotation(Consumes.class.getName());
+ return getAnnotation(CONSUMES.qualifiedName);
}
@Override
@@ -452,7 +445,7 @@
}
public Annotation getProducesAnnotation() {
- return getAnnotation(Produces.class.getName());
+ return getAnnotation(PRODUCES.qualifiedName);
}
@Override
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -25,12 +25,10 @@
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsMetamodelBuilder;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBaseElement;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResource;
import org.jboss.tools.ws.jaxrs.core.internal.utils.ConstantUtils;
import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
-import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsResource;
import org.jboss.tools.ws.jaxrs.core.metamodel.JaxrsMetamodelLocator;
public class JaxrsMetamodelValidator extends AbstractValidator {
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.ws.jaxrs.core.jdt;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -43,6 +44,23 @@
this.region = region;
}
+ /**
+ * Full constructor with a single unnamed 'value'
+ *
+ * @param annotation
+ * @param annotationName
+ * @param annotationValue
+ * @param sourceRange
+ */
+ public Annotation(final IAnnotation annotation, final String annotationName, final String annotationValue,
+ final TypedRegion sourceRange) {
+ this.javaAnnotation = annotation;
+ this.javaAnnotationName = annotationName;
+ this.javaAnnotationElements = new HashMap<String, List<String>>();
+ this.javaAnnotationElements.put("value", Arrays.asList(annotationValue));
+ this.region = region;
+ }
+
public boolean update(Annotation annotation) {
assert annotation != null;
Added: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/EnumJaxrsElements.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/EnumJaxrsElements.java (rev 0)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/EnumJaxrsElements.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.ws.jaxrs.core.jdt;
+
+/**
+ * @author Xavier Coulon
+ *
+ */
+public enum EnumJaxrsElements {
+
+ DELETE("javax.ws.rs.DELETE"),
+
+ GET("javax.ws.rs.GET"),
+
+ POST("javax.ws.rs.POST"),
+
+ PUT("javax.ws.rs.PUT"),
+
+ HEAD("javax.ws.rs.HEAD"),
+
+ OPTIONS("javax.ws.rs.OPTIONS"),
+
+ HTTP_METHOD("javax.ws.rs.HttpMethod"),
+
+ APPLICATION("javax.ws.rs.core.Application"),
+
+ APPLICATION_PATH("javax.ws.rs.ApplicationPath"),
+
+ PATH("javax.ws.rs.Path"),
+
+ PATH_PARAM("javax.ws.rs.PathParam"),
+
+ CONSUMES("javax.ws.rs.Consumes"),
+
+ PRODUCES("javax.ws.rs.Produces"),
+
+ DEFAULT_VALUE("javax.ws.rs.DefaultValue"),
+
+ COOKIE_PARAM("javax.ws.rs.CookieParam"),
+
+ HEADER_PARAM("javax.ws.rs.HeaderParam"),
+
+ MATRIX_PARAM("javax.ws.rs.MatrixParam"),
+
+ QUERY_PARAM("javax.ws.rs.QueryParam"),
+
+ CONTEXT("javax.ws.rs.core.Context"),
+
+ HTTP_HEADERS("javax.ws.rs.core.HttpHeaders"),
+
+ REQUEST("javax.ws.rs.core.Request"),
+
+ RESPONSE("javax.ws.rs.core.Response"),
+
+ URI_INFO("javax.ws.rs.core.UriInfo"),
+
+ ENCODED("javax.ws.rs.Encoded"),
+
+ PROVIDER("javax.ws.rs.ext.Provider");
+
+ public final String qualifiedName;
+
+ private EnumJaxrsElements(final String qualifiedName) {
+ this.qualifiedName = qualifiedName;
+ }
+
+}
Property changes on: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/EnumJaxrsElements.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -11,14 +11,14 @@
package org.jboss.tools.ws.jaxrs.core.jdt;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.APPLICATION_PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PROVIDER;
+
import java.util.ArrayList;
import java.util.List;
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.Path;
-import javax.ws.rs.ext.Provider;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
@@ -64,7 +64,7 @@
IJavaSearchScope searchScope = null;
searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { scope }, IJavaSearchScope.SOURCES
| IJavaSearchScope.REFERENCED_PROJECTS);
- return searchForAnnotatedTypes(ApplicationPath.class, searchScope, progressMonitor);
+ return searchForAnnotatedTypes(APPLICATION_PATH.qualifiedName, searchScope, progressMonitor);
}
/**
@@ -92,7 +92,7 @@
searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { scope }, IJavaSearchScope.SOURCES
| IJavaSearchScope.REFERENCED_PROJECTS);
}
- return searchForAnnotatedTypes(Provider.class, searchScope, progressMonitor);
+ return searchForAnnotatedTypes(PROVIDER.qualifiedName, searchScope, progressMonitor);
}
/**
@@ -121,7 +121,7 @@
// }
// look for type with @Path annotations, as looking for types with
// annotated resourceMethods may return incomplete results
- return searchForAnnotatedTypes(Path.class, searchScope, progressMonitor);
+ return searchForAnnotatedTypes(PATH.qualifiedName, searchScope, progressMonitor);
}
/**
@@ -140,12 +140,12 @@
throws CoreException {
IJavaSearchScope searchScope = null;
if (scope instanceof IJavaProject) {
- IJavaProject javaProject = (IJavaProject) scope;
- searchScope = SearchEngine.createJavaSearchScope(javaProject.getPackageFragmentRoots());
+ searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { scope },
+ IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS);
} else {
searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { scope });
}
- return searchForAnnotatedTypes(HttpMethod.class, searchScope, progressMonitor);
+ return searchForAnnotatedTypes(HTTP_METHOD.qualifiedName, searchScope, progressMonitor);
}
/**
@@ -161,10 +161,10 @@
* @throws CoreException
* in case of underlying exception
*/
- private static List<IType> searchForAnnotatedTypes(final Class<?> annotation, final IJavaSearchScope searchScope,
+ private static List<IType> searchForAnnotatedTypes(final String annotationName, final IJavaSearchScope searchScope,
final IProgressMonitor progressMonitor) throws CoreException {
JavaMemberSearchResultCollector collector = new JavaMemberSearchResultCollector(IJavaElement.TYPE, searchScope);
- SearchPattern pattern = SearchPattern.createPattern(annotation.getName(), IJavaSearchConstants.ANNOTATION_TYPE,
+ SearchPattern pattern = SearchPattern.createPattern(annotationName, IJavaSearchConstants.ANNOTATION_TYPE,
IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE | IJavaSearchConstants.TYPE, SearchPattern.R_EXACT_MATCH
| SearchPattern.R_CASE_SENSITIVE);
// perform search, results are added/filtered by the custom
@@ -193,9 +193,9 @@
IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { scope },
IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS);
List<String> annotations = new ArrayList<String>(httpMethods.size() + 1);
- annotations.add(Path.class.getName());
+ annotations.add(PATH.qualifiedName);
for (IJaxrsHttpMethod httpMethod : httpMethods) {
- annotations.add(httpMethod.getJavaElement().getFullyQualifiedName());
+ annotations.add(httpMethod.getFullyQualifiedName());
}
return searchForAnnotatedMethods(annotations, searchScope, progressMonitor);
}
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -249,41 +249,6 @@
}
/**
- * Parse the DOM of the given member, and resolve bindings. If the given
- * member is not a type, then its declaring type is used by the parser.
- *
- * @param member
- * the type to parse
- * @param progressMonitor
- * the progress monitor
- * @return compilationUnit the DOM CompilationUnit returned by the parse()
- * method. This operation is expensive and should be performed only
- * once for each type. Returns null if the given member was null.
- * @throws JavaModelException
- * in case of exception underneath... public static
- * CompilationUnit parse(final IMember member, final
- * IProgressMonitor progressMonitor) throws JavaModelException {
- * if (member == null) { return null; } IType type = null; if
- * (member.getElementType() == IMember.TYPE) { type = (IType)
- * member; } else { type = member.getDeclaringType(); }
- * ASTParser parser = ASTParser.newParser(AST.JLS3); if (type
- * instanceof BinaryType) { IClassFile classFile = (IClassFile)
- * type.getParent(); if (classFile.getSource() == null) {
- * Logger.warn("No source attachment is available for type '" +
- * type + "'. Unable to resolve type arguments."); return null;
- * } parser.setKind(ASTParser.K_COMPILATION_UNIT);
- * parser.setSource(classFile); } else if (type instanceof
- * SourceType) { parser.setSource(type.getCompilationUnit()); }
- *
- * parser.setResolveBindings(true);
- * parser.setBindingsRecovery(true); // FIXME : parser.createAST
- * throws an IllegalStateException on binary //
- * parameterizedType if source code is not available.
- * CompilationUnit node = (CompilationUnit)
- * parser.createAST(progressMonitor); return node; }
- */
-
- /**
* Resolves the annotation given its type.
*
* @param type
@@ -569,7 +534,7 @@
}
// FIXME : path for a sample result with the help of
// bindings
- // superClassBinding.getSuperclass().getInterfaces()[0].getInterfaces()[0].getTypeArguments()[0].getQualifiedName();
+ // superClassBinding.getSuperclass().getInterfaces()[0].getInterfaces()[0].getTypeArguments()[0].qualifiedName;
}
}
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -19,7 +19,7 @@
String getHttpVerb();
/** @return the name */
- String getSimpleName();
+ String getFullyQualifiedName();
Annotation getHttpMethodAnnotation();
Modified: branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/contentassist/PathParamAnnotationValueCompletionProposalComputer.java
===================================================================
--- branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/contentassist/PathParamAnnotationValueCompletionProposalComputer.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/contentassist/PathParamAnnotationValueCompletionProposalComputer.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -15,7 +15,7 @@
import java.util.Collections;
import java.util.List;
-import javax.ws.rs.PathParam;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH_PARAM;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -87,7 +87,7 @@
for (JavaMethodParameter methodParameter : resourceMethod.getJavaMethodParameters()) {
for (Annotation annotation : methodParameter.getAnnotations()) {
final TypedRegion region = annotation.getRegion();
- if (annotation.getName().equals(PathParam.class.getName()) && region != null
+ if (annotation.getName().equals(PATH_PARAM.qualifiedName) && region != null
&& context.getInvocationOffset() >= region.getOffset()
&& context.getInvocationOffset() < (region.getOffset() + region.getLength())) {
// completion proposal on @PathParam method
Modified: branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/.classpath
===================================================================
--- branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/.classpath 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/.classpath 2012-09-14 15:23:28 UTC (rev 43697)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="lib" path="lib/mockito-core-1.9.0-rc1.jar"/>
+ <classpathentry kind="lib" path="lib/mockito-core-1.9.0-rc1.jar" sourcepath="/Users/xcoulon/.m2/repository/org/mockito/mockito-core/1.9.0-rc1/mockito-core-1.9.0-rc1-sources.jar"/>
<classpathentry kind="lib" path="lib/objenesis-1.2.jar"/>
<classpathentry kind="lib" path="lib/hamcrest-all-1.3.0RC2.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
Modified: branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java
===================================================================
--- branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -840,17 +840,17 @@
return found;
}
- public static Annotation getAnnotation(final IMember member, final Class<?> annotationClass)
+ public static Annotation getAnnotation(final IMember member, final String annotationName)
throws JavaModelException {
- if (annotationClass == null) {
+ if (annotationName == null) {
return null;
}
- return JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, null), annotationClass);
+ return JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, null), annotationName);
}
- public static Annotation getAnnotation(final IMember member, final Class<?> annotationClass, String... values)
+ public static Annotation getAnnotation(final IMember member, final String annotationName, String... values)
throws JavaModelException {
- Annotation annotation = JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, null), annotationClass);
+ Annotation annotation = JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, null), annotationName);
Map<String, List<String>> elements = new HashMap<String, List<String>>();
elements.put("value", Arrays.asList(values));
Modified: branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java
===================================================================
--- branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -29,6 +29,23 @@
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_METHOD_RETURN_TYPE;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PATH_VALUE;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PRODUCED_MEDIATYPES_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.APPLICATION_PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.CONSUMES;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.CONTEXT;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.DEFAULT_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.DELETE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.ENCODED;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.GET;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.MATRIX_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.POST;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PRODUCES;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PUT;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.QUERY_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.RESPONSE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.URI_INFO;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
@@ -44,25 +61,6 @@
import java.util.List;
import java.util.Map;
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.Encoded;
-import javax.ws.rs.GET;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.MatrixParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -85,6 +83,7 @@
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceField;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceMethod;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
+import org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements;
import org.jboss.tools.ws.jaxrs.core.jdt.JavaMethodParameter;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
@@ -108,10 +107,10 @@
@Before
public void setup() throws CoreException {
JBossJaxrsCorePlugin.getDefault().unregisterListeners();
- // metamodel = Mockito.mock(JaxrsMetamodel.class);
+ // metamodel = Mockito.mock(JaxrsMetamodel);
// in case an element was attempted to be removed, some impact would be
// retrieved
- // when(metamodel.remove(any(JaxrsElement.class))).thenReturn(true);
+ // when(metamodel.remove(any(JaxrsElement))).thenReturn(true);
metamodel = spy(JaxrsMetamodel.create(javaProject));
// replace the normal metamodel instance with the one spied by Mockito
javaProject.getProject().setSessionProperty(JaxrsMetamodel.METAMODEL_QUALIFIED_NAME, metamodel);
@@ -122,15 +121,15 @@
* @throws CoreException
* @throws JavaModelException
*/
- private JaxrsHttpMethod createHttpMethod(Class<?> httpClass) throws CoreException, JavaModelException {
- final IType httpMethodType = JdtUtils.resolveType(httpClass.getName(), javaProject, progressMonitor);
- final Annotation httpMethodAnnotation = getAnnotation(httpMethodType, HttpMethod.class);
+ private JaxrsHttpMethod createHttpMethod(EnumJaxrsElements httpMethodElement) throws CoreException, JavaModelException {
+ final IType httpMethodType = JdtUtils.resolveType(httpMethodElement.qualifiedName, javaProject, progressMonitor);
+ final Annotation httpMethodAnnotation = getAnnotation(httpMethodType, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(httpMethodType, httpMethodAnnotation, metamodel);
return httpMethod;
}
- private Annotation createAnnotation(Class<?> clazz, String value) {
- return createAnnotation(null, clazz.getName(), value);
+ private Annotation createAnnotation(String className, String value) {
+ return createAnnotation(null, className, value);
}
private Annotation createAnnotation(IAnnotation annotation, String name, String value) {
@@ -184,10 +183,10 @@
@Test
public void shouldAdd1HttpMethodAnd3ResourcesWhenAddingSourceFolder() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
// operation
@@ -254,7 +253,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, ApplicationPath.class);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
// operation
final JavaElementDelta event = createEvent(annotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -272,9 +271,9 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final JaxrsJavaApplication application = new JaxrsJavaApplication(type, getAnnotation(type, ApplicationPath.class), metamodel);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, getAnnotation(type, APPLICATION_PATH.qualifiedName), metamodel);
metamodel.add(application);
- final Annotation annotation = getAnnotation(type, SuppressWarnings.class);
+ final Annotation annotation = getAnnotation(type, SuppressWarnings.class.getName());
// operation
final JavaElementDelta event = createEvent(annotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -289,7 +288,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, ApplicationPath.class, "/bar");
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName, "/bar");
final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
@@ -308,7 +307,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, ApplicationPath.class);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
@@ -324,10 +323,10 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, ApplicationPath.class);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
- final Annotation suppressWarningsAnnotation = getAnnotation(type, SuppressWarnings.class);
+ final Annotation suppressWarningsAnnotation = getAnnotation(type, SuppressWarnings.class.getName());
// operation
final JavaElementDelta event = createEvent(suppressWarningsAnnotation, CHANGED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -341,7 +340,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, ApplicationPath.class);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
@@ -360,7 +359,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, ApplicationPath.class);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
@@ -379,7 +378,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, ApplicationPath.class);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
@@ -398,11 +397,11 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, ApplicationPath.class);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
- final JavaElementDelta event = createEvent(getAnnotation(type, SuppressWarnings.class), REMOVED);
+ final JavaElementDelta event = createEvent(getAnnotation(type, SuppressWarnings.class.getName()), REMOVED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
// verifications
assertThat(impacts.size(), equalTo(0));
@@ -414,7 +413,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, ApplicationPath.class);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
@@ -460,7 +459,7 @@
assertThat(impacts.get(0).getElement().getElementKind(), equalTo(EnumElementKind.HTTP_METHOD));
assertThat(impacts.get(0).getDeltaKind(), equalTo(ADDED));
assertThat(((JaxrsHttpMethod) impacts.get(0).getElement()).getHttpVerb(), equalTo("FOO"));
- verify(metamodel, times(1)).add(any(JaxrsHttpMethod.class));
+ //verify(metamodel, times(1)).add(any(HTTP_METHOD.qualifiedName));
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
@@ -469,7 +468,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
// operation
final JavaElementDelta event = createEvent(annotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -487,9 +486,9 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, getAnnotation(type, HttpMethod.class), metamodel);
+ final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, getAnnotation(type, HTTP_METHOD.qualifiedName), metamodel);
metamodel.add(httpMethod);
- final Annotation annotation = getAnnotation(type, Target.class);
+ final Annotation annotation = getAnnotation(type, Target.class.getName());
// operation
final JavaElementDelta event = createEvent(annotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -504,7 +503,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class, "BAR");
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName, "BAR");
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
// operation
@@ -523,7 +522,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
// operation
@@ -539,10 +538,10 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation httpMethodAnnotation = getAnnotation(type, HttpMethod.class);
+ final Annotation httpMethodAnnotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, httpMethodAnnotation, metamodel);
metamodel.add(httpMethod);
- final Annotation targetAnnotation = getAnnotation(type, Target.class);
+ final Annotation targetAnnotation = getAnnotation(type, Target.class.getName());
// operation
final JavaElementDelta event = createEvent(targetAnnotation, CHANGED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -557,7 +556,7 @@
// JaxrsMetamodel metamodel = new JaxrsMetamodel(javaProject);
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
// operation
@@ -576,7 +575,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
// operation
@@ -595,7 +594,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
// operation
@@ -614,10 +613,10 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, getAnnotation(type, HttpMethod.class), metamodel);
+ final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, getAnnotation(type, HTTP_METHOD.qualifiedName), metamodel);
metamodel.add(httpMethod);
// operation
- final JavaElementDelta event = createEvent(getAnnotation(type, Target.class), REMOVED);
+ final JavaElementDelta event = createEvent(getAnnotation(type, Target.class.getName()), REMOVED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
// verifications
assertThat(impacts.size(), equalTo(0));
@@ -629,7 +628,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
@@ -652,7 +651,7 @@
"lib/jaxrs-api-2.0.1.GA.jar", progressMonitor);
// let's suppose that this jar only contains 1 HTTP Methods ;-)
final IType type = JdtUtils.resolveType("javax.ws.rs.GET", javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
// operation
@@ -668,10 +667,10 @@
@Test
public void shouldAddResourceWhenAddingSourceCompilationUnit() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
// operation
IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JavaElementDelta event = createEvent(type.getCompilationUnit(), ADDED);
@@ -687,7 +686,7 @@
@Test
public void shouldAddSubresourceWhenAddingSourceCompilationUnit() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
+ metamodel.add(createHttpMethod(GET));
// operation
IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource", javaProject);
final JavaElementDelta event = createEvent(type.getCompilationUnit(), ADDED);
@@ -704,7 +703,7 @@
@Test
public void shouldAddSubresourceLocatorWhenAddingSourceCompilationUnit() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
+ metamodel.add(createHttpMethod(GET));
// operation
IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final JavaElementDelta event = createEvent(type.getCompilationUnit(), ADDED);
@@ -721,10 +720,10 @@
@Test
public void shouldAddResourceWhenAddingSourceType() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
// operation
IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JavaElementDelta event = createEvent(type, ADDED);
@@ -740,13 +739,13 @@
@Test
public void shouldAddResourceWhenAddingPathAnnotation() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
// operation
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation annotation = getAnnotation(type, Path.class);
+ final Annotation annotation = getAnnotation(type, PATH.qualifiedName);
final JavaElementDelta event = createEvent(annotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
// verifications
@@ -754,9 +753,9 @@
assertThat(impacts.get(0).getDeltaKind(), equalTo(ADDED));
final JaxrsResource resource = (JaxrsResource) impacts.get(0).getElement();
assertThat(resource.getPathTemplate(), equalTo("/customers"));
- assertThat(resource.getConsumedMediaTypes(), equalTo(Arrays.asList(MediaType.APPLICATION_XML)));
+ assertThat(resource.getConsumedMediaTypes(), equalTo(Arrays.asList("application/xml")));
assertThat(resource.getProducedMediaTypes(),
- equalTo(Arrays.asList(MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON)));
+ equalTo(Arrays.asList("application/xml", "application/json")));
// includes HttpMethods, Resource, ResourceMethods and ResourceFields
assertThat(metamodel.getElements(javaProject).size(), equalTo(11));
}
@@ -765,12 +764,12 @@
public void shouldBecomeRootResourceWhenAddingPathAnnotation() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation consumesAnnotation = getAnnotation(type, Consumes.class);
- final Annotation producesAnnotation = getAnnotation(type, Produces.class);
+ final Annotation consumesAnnotation = getAnnotation(type, CONSUMES.qualifiedName);
+ final Annotation producesAnnotation = getAnnotation(type, PRODUCES.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).consumes(consumesAnnotation)
.produces(producesAnnotation).build();
metamodel.add(resource);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
// operation
final JavaElementDelta event = createEvent(pathAnnotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -786,7 +785,7 @@
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.FooResource", javaProject);
// operation
- final Annotation annotation = getAnnotation(type, Consumes.class);
+ final Annotation annotation = getAnnotation(type, CONSUMES.qualifiedName);
final JavaElementDelta event = createEvent(annotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
// verifications
@@ -799,7 +798,7 @@
public void shouldUpdateResourceWhenChangingPathAnnotationValue() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation annotation = getAnnotation(type, Path.class, "/bar");
+ final Annotation annotation = getAnnotation(type, PATH.qualifiedName, "/bar");
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(annotation).build();
metamodel.add(resource);
// operation
@@ -817,8 +816,8 @@
public void shouldUpdateResourceWhenAddingConsumesAnnotation() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation annotation = getAnnotation(type, Consumes.class);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation annotation = getAnnotation(type, CONSUMES.qualifiedName);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// operation
@@ -835,8 +834,8 @@
public void shouldUpdateResourceWhenChangingConsumesAnnotationValue() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
- final Annotation consumesAnnotation = getAnnotation(type, Consumes.class, "application/foo");
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
+ final Annotation consumesAnnotation = getAnnotation(type, CONSUMES.qualifiedName, "application/foo");
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation)
.consumes(consumesAnnotation).build();
metamodel.add(resource);
@@ -854,8 +853,8 @@
public void shouldUpdateResourceWhenRemovingConsumesAnnotation() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
- final Annotation consumesAnnotation = getAnnotation(type, Consumes.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
+ final Annotation consumesAnnotation = getAnnotation(type, CONSUMES.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation)
.consumes(consumesAnnotation).build();
metamodel.add(resource);
@@ -873,10 +872,10 @@
public void shouldUpdateResourceWhenAddingProducesAnnotation() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
- final Annotation producesAnnotation = getAnnotation(type, Produces.class);
+ final Annotation producesAnnotation = getAnnotation(type, PRODUCES.qualifiedName);
// operation
final JavaElementDelta event = createEvent(producesAnnotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -891,8 +890,8 @@
public void shouldUpdateResourceWhenChangingProducesAnnotationValue() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation annotation = getAnnotation(type, Produces.class, "application/foo");
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation annotation = getAnnotation(type, PRODUCES.qualifiedName, "application/foo");
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation)
.produces(annotation).build();
metamodel.add(resource);
@@ -910,8 +909,8 @@
public void shouldUpdateResourceWhenRemovingProducesAnnotation() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation annotation = getAnnotation(type, Produces.class);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation annotation = getAnnotation(type, PRODUCES.qualifiedName);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation)
.produces(annotation).build();
metamodel.add(resource);
@@ -929,10 +928,10 @@
public void shouldAddResourceFieldWhenAddingPathParamAnnotationOnField() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
- final Annotation annotation = getAnnotation(type.getField("productType"), PathParam.class);
+ final Annotation annotation = getAnnotation(type.getField("productType"), PATH_PARAM.qualifiedName);
// operation
final JavaElementDelta event = createEvent(annotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -949,7 +948,7 @@
* // pre-conditions final IType type =
* getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator" ); final JaxrsResource resource =
* new JaxrsResource.Builder(type, metamodel).build(); //metamodel.add(resource); final IImportDeclaration
- * importDeclaration = getImportDeclaration(type, PathParam.class.getName()); // operation final
+ * importDeclaration = getImportDeclaration(type, PathParam.getName()); // operation final
* JavaElementChangedEvent event = createEvent(importDeclaration, ADDED); final List<JaxrsElementChangedEvent>
* impacts = processEvent(event, progressMonitor); // verifications assertThat(impacts.size(), equalTo(1));
* assertThat(impacts.get(0).getDeltaKind(), equalTo(ADDED));
@@ -960,10 +959,10 @@
public void shouldAddResourceFieldWhenAddingQueryParamAnnotationOnField() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
- final Annotation annotation = getAnnotation(type.getField("foo"), QueryParam.class);
+ final Annotation annotation = getAnnotation(type.getField("foo"), QUERY_PARAM.qualifiedName);
// operation
final JavaElementDelta event = createEvent(annotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -977,10 +976,10 @@
public void shouldAddResourceFieldWhenAddingMatrixParamAnnotationOnField() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
- final Annotation annotation = getAnnotation(type.getField("bar"), MatrixParam.class);
+ final Annotation annotation = getAnnotation(type.getField("bar"), MATRIX_PARAM.qualifiedName);
// operation
final JavaElementDelta event = createEvent(annotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -994,7 +993,7 @@
public void shouldAddResourceFieldWhenAddingFieldAnnotatedWithPathParam() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("productType");
@@ -1011,7 +1010,7 @@
public void shouldAddResourceFieldWhenAddingFieldAnnotatedWithQueryParam() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("foo");
@@ -1028,7 +1027,7 @@
public void shouldAddResourceFieldWhenAddingFieldAnnotatedWithMatrixParam() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("bar");
@@ -1045,7 +1044,7 @@
public void shouldDoNothingWhenAddingFieldWithAnyAnnotation() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("entityManager");
@@ -1061,7 +1060,7 @@
public void shouldDoNothingWhenAddingUnrelatedAnnotationOnField() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("entityManager");
@@ -1077,11 +1076,11 @@
public void shouldUpdateResourceFieldWhenChangingPathParamAnnotationValueOnField() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("productType");
- final Annotation annotation = getAnnotation(field, PathParam.class, "foo");
+ final Annotation annotation = getAnnotation(field, PATH_PARAM.qualifiedName, "foo");
final JaxrsResourceField resourceField = new JaxrsResourceField(field, annotation, resource, metamodel);
metamodel.add(resourceField);
// operation
@@ -1097,11 +1096,11 @@
public void shouldUpdateResourceFieldWhenChangingQueryParamAnnotationValueOnField() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("foo");
- final Annotation annotation = getAnnotation(field, QueryParam.class, "foo!");
+ final Annotation annotation = getAnnotation(field, QUERY_PARAM.qualifiedName, "foo!");
final JaxrsResourceField resourceField = new JaxrsResourceField(field, annotation, resource, metamodel);
metamodel.add(resourceField);
// operation
@@ -1117,11 +1116,11 @@
public void shouldUpdateResourceFieldWhenChangingMatrixParamAnnotationValueOnField() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("bar");
- final Annotation annotation = getAnnotation(field, MatrixParam.class, "bar!");
+ final Annotation annotation = getAnnotation(field, MATRIX_PARAM.qualifiedName, "bar!");
final JaxrsResourceField resourceField = new JaxrsResourceField(field, annotation, resource, metamodel);
metamodel.add(resourceField);
// operation
@@ -1137,11 +1136,11 @@
public void shouldDoNothingWhenChangingUnrelatedResourceFieldAnnotationValue() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("bar");
- final Annotation annotation = getAnnotation(field, SuppressWarnings.class, "bar");
+ final Annotation annotation = getAnnotation(field, SuppressWarnings.class.getName(), "bar");
final JaxrsResourceField resourceField = new JaxrsResourceField(field, annotation, resource, metamodel);
metamodel.add(resourceField);
// operation
@@ -1156,11 +1155,11 @@
public void shouldRemoveResourceFieldWhenRemovingPathParamAnnotatedOnField() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("productType");
- final Annotation annotation = getAnnotation(field, PathParam.class);
+ final Annotation annotation = getAnnotation(field, PATH_PARAM.qualifiedName);
final JaxrsResourceField resourceField = new JaxrsResourceField(field, annotation, resource, metamodel);
metamodel.add(resourceField);
// operation
@@ -1176,11 +1175,11 @@
public void shouldRemoveResourceFieldWhenRemovingQueryParamAnnotationOnField() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("foo");
- final Annotation annotation = getAnnotation(field, QueryParam.class);
+ final Annotation annotation = getAnnotation(field, QUERY_PARAM.qualifiedName);
final JaxrsResourceField resourceField = new JaxrsResourceField(field, annotation, resource, metamodel);
metamodel.add(resourceField);
// operation
@@ -1196,11 +1195,11 @@
public void shouldRemoveResourceFieldWhenRemovingMatrixParamAnnotationOnField() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("bar");
- final Annotation annotation = getAnnotation(field, MatrixParam.class);
+ final Annotation annotation = getAnnotation(field, MATRIX_PARAM.qualifiedName);
final JaxrsResourceField resourceField = new JaxrsResourceField(field, annotation, resource, metamodel);
metamodel.add(resourceField);
// operation
@@ -1216,11 +1215,11 @@
public void shouldRemoveResourceFieldWhenRemovingFieldAnnotatedWithQueryParam() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
IField field = type.getField("foo");
- final Annotation annotation = getAnnotation(field, QueryParam.class);
+ final Annotation annotation = getAnnotation(field, QUERY_PARAM.qualifiedName);
final JaxrsResourceField resourceField = new JaxrsResourceField(field, annotation, resource, metamodel);
metamodel.add(resourceField);
// operation
@@ -1236,11 +1235,11 @@
public void shouldRemoveResourceFieldWhenRemovingFieldAnnotatedWithPathParam() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("productType");
- final Annotation annotation = getAnnotation(field, PathParam.class);
+ final Annotation annotation = getAnnotation(field, PATH_PARAM.qualifiedName);
final JaxrsResourceField resourceField = new JaxrsResourceField(field, annotation, resource, metamodel);
metamodel.add(resourceField);
// operation
@@ -1256,11 +1255,11 @@
public void shouldRemoveResourceFieldWhenRemovingFieldAnnotatedWithMatrixParam() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("bar");
- final Annotation annotation = getAnnotation(field, MatrixParam.class);
+ final Annotation annotation = getAnnotation(field, MATRIX_PARAM.qualifiedName);
final JaxrsResourceField resourceField = new JaxrsResourceField(field, annotation, resource, metamodel);
metamodel.add(resourceField);
// operation
@@ -1276,7 +1275,7 @@
public void shouldDoNothingWhenRemovingUnrelatedAnnotationOnField() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IField field = type.getField("entityManager");
@@ -1293,7 +1292,7 @@
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final Annotation annotation = JdtUtils.resolveAnnotation(type, JdtUtils.parse(type, progressMonitor),
- Path.class);
+ PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(annotation).build();
metamodel.add(resource);
// operation
@@ -1308,10 +1307,10 @@
public void shouldDoNothingWhenChangingUnrelatedResourceAnnotationValue() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
- final Annotation annotation = getAnnotation(type, Consumes.class);
+ final Annotation annotation = getAnnotation(type, CONSUMES.qualifiedName);
// operation
final JavaElementDelta event = createEvent(annotation, CHANGED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -1358,7 +1357,7 @@
public void shouldRemoveResourceWhenRemovingAnnotation() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation annotation = getAnnotation(type, Path.class);
+ final Annotation annotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(annotation).build();
metamodel.add(resource);
for (JaxrsResourceMethod resourceMethod : resource.getMethods().values()) {
@@ -1378,15 +1377,15 @@
@Test
public void shouldRemoveResourceMethodWhenRemovingJavaMethod() throws CoreException {
// JAX-RS HttpMethod
- metamodel.add(createHttpMethod(POST.class));
+ metamodel.add(createHttpMethod(POST));
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "createCustomer");
- final Annotation annotation = getAnnotation(method, POST.class);
+ final Annotation annotation = getAnnotation(method, POST.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(annotation).build();
metamodel.add(resourceMethod);
@@ -1403,16 +1402,16 @@
public void shouldBecomeSubresourceWhenRemovingPathAnnotation() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
metamodel.add(httpMethod);
// JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "createCustomer");
- final Annotation httpMethodAnnotation = getAnnotation(method, POST.class);
+ final Annotation httpMethodAnnotation = getAnnotation(method, POST.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(httpMethodAnnotation).build();
metamodel.add(resourceMethod);
@@ -1433,8 +1432,8 @@
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).build();
metamodel.add(resource);
// in case it would be removed
- final Annotation annotation = JdtUtils.resolveAnnotation(type, JdtUtils.parse(type, progressMonitor),
- Encoded.class);
+ final Annotation annotation = getAnnotation(type,
+ ENCODED.qualifiedName);
// operation
final JavaElementDelta event = createEvent(annotation, REMOVED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -1449,7 +1448,7 @@
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation annotation = getAnnotation(type, Consumes.class);
+ final Annotation annotation = getAnnotation(type, CONSUMES.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(annotation).build();
metamodel.add(resource);
// operation
@@ -1471,14 +1470,14 @@
public void shouldAddResourceMethodWhenAddingHttpMethodAnnotation() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- metamodel.add(createHttpMethod(POST.class));
+ metamodel.add(createHttpMethod(POST));
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IMethod method = getMethod(type, "createCustomer");
- final Annotation annotation = getAnnotation(method, POST.class);
+ final Annotation annotation = getAnnotation(method, POST.qualifiedName);
// operation
final JavaElementDelta event = createEvent(annotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -1492,10 +1491,10 @@
public void shouldAddResourceMethodWhenAddingAnnotatedMethod() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- metamodel.add(createHttpMethod(POST.class));
+ metamodel.add(createHttpMethod(POST));
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IMethod method = getMethod(type, "createCustomer");
@@ -1513,11 +1512,11 @@
// pre-conditions
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
final IMethod method = getMethod(type, "getProductResourceLocator");
- final Annotation annotation = getAnnotation(method, Path.class);
+ final Annotation annotation = getAnnotation(method, PATH.qualifiedName);
// operation
final JavaElementDelta event = createEvent(annotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -1531,16 +1530,16 @@
public void shouldRemoveResourceMethodWhenRemovingHttpMethodAnnotation() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "createCustomer");
- final Annotation annotation = getAnnotation(method, POST.class);
+ final Annotation annotation = getAnnotation(method, POST.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(annotation).build();
metamodel.add(resourceMethod);
@@ -1556,20 +1555,20 @@
@Test
public void shouldConvertIntoSubresourceMethodWhenAddingPathAnnotation() throws CoreException {
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(
- getAnnotation(type, Path.class)).build();
+ getAnnotation(type, PATH.qualifiedName)).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "getCustomer");
- final Annotation httpAnnotation = getAnnotation(method, GET.class);
+ final Annotation httpAnnotation = getAnnotation(method, GET.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(httpAnnotation).build();
metamodel.add(resourceMethod);
- final Annotation pathAnnotation = getAnnotation(method, Path.class);
+ final Annotation pathAnnotation = getAnnotation(method, PATH.qualifiedName);
// operation
final JavaElementDelta event = createEvent(pathAnnotation, ADDED);
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
@@ -1584,17 +1583,17 @@
public void shouldConvertIntoResourceMethodWhenRemovingPathAnnotation() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(
- getAnnotation(type, Path.class)).build();
+ getAnnotation(type, PATH.qualifiedName)).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "getCustomer");
- final Annotation httpAnnotation = getAnnotation(method, GET.class);
- final Annotation pathAnnotation = getAnnotation(method, Path.class);
+ final Annotation httpAnnotation = getAnnotation(method, GET.qualifiedName);
+ final Annotation pathAnnotation = getAnnotation(method, PATH.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(httpAnnotation).pathTemplate(pathAnnotation).build();
metamodel.add(resourceMethod);
@@ -1612,17 +1611,17 @@
public void shouldConvertIntoSubresourceLocatorWhenRemovingHttpMethodAnnotation() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(
- getAnnotation(type, Path.class)).build();
+ getAnnotation(type, PATH.qualifiedName)).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "getCustomer");
- final Annotation pathAnnotation = getAnnotation(method, Path.class);
- final Annotation httpAnnotation = getAnnotation(method, GET.class);
+ final Annotation pathAnnotation = getAnnotation(method, PATH.qualifiedName);
+ final Annotation httpAnnotation = getAnnotation(method, GET.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(httpAnnotation).pathTemplate(pathAnnotation).build();
metamodel.add(resourceMethod);
@@ -1642,11 +1641,11 @@
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(
- getAnnotation(type, Path.class)).build();
+ getAnnotation(type, PATH.qualifiedName)).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "getProductResourceLocator");
- final Annotation annotation = getAnnotation(method, Path.class);
+ final Annotation annotation = getAnnotation(method, PATH.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.pathTemplate(annotation).build();
metamodel.add(resourceMethod);
@@ -1663,17 +1662,17 @@
public void shouldUpdateSubresourceMethodWhenChangingPathAnnotationValue() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(
- getAnnotation(type, Path.class)).build();
+ getAnnotation(type, PATH.qualifiedName)).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "getCustomer");
- final Annotation pathAnnotation = getAnnotation(method, Path.class, "/foo");
- final Annotation httpAnnotation = getAnnotation(method, GET.class);
+ final Annotation pathAnnotation = getAnnotation(method, PATH.qualifiedName, "/foo");
+ final Annotation httpAnnotation = getAnnotation(method, GET.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(httpAnnotation).pathTemplate(pathAnnotation).build();
metamodel.add(resourceMethod);
@@ -1691,17 +1690,17 @@
public void shouldUpdateResourceMethodWhenAddingConsumesAnnotation() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "createCustomer");
- final Annotation consumesAnnotation = getAnnotation(method, Consumes.class);
- final Annotation httpAnnotation = getAnnotation(method, POST.class);
+ final Annotation consumesAnnotation = getAnnotation(method, CONSUMES.qualifiedName);
+ final Annotation httpAnnotation = getAnnotation(method, POST.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(httpAnnotation).build();
metamodel.add(resourceMethod);
@@ -1719,17 +1718,17 @@
public void shouldUpdateResourceMethodWhenChangingConsumesAnnotationValue() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "createCustomer");
- final Annotation consumesAnnotation = getAnnotation(method, Consumes.class, "application/foo");
- final Annotation httpAnnotation = getAnnotation(method, POST.class);
+ final Annotation consumesAnnotation = getAnnotation(method, CONSUMES.qualifiedName, "application/foo");
+ final Annotation httpAnnotation = getAnnotation(method, POST.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(httpAnnotation).consumes(consumesAnnotation).build();
metamodel.add(resourceMethod);
@@ -1747,17 +1746,17 @@
public void shouldUpdateResourceMethodMethodWhenRemovingConsumesAnnotation() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "createCustomer");
- final Annotation httpAnnotation = getAnnotation(method, POST.class);
- final Annotation consumesAnnotation = getAnnotation(method, Consumes.class);
+ final Annotation httpAnnotation = getAnnotation(method, POST.qualifiedName);
+ final Annotation consumesAnnotation = getAnnotation(method, CONSUMES.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(httpAnnotation).consumes(consumesAnnotation).build();
metamodel.add(resourceMethod);
@@ -1775,17 +1774,17 @@
public void shouldUpdateResourceMethodWhenAddingProducesAnnotation() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "getCustomerAsVCard");
- final Annotation producesAnnotation = getAnnotation(method, Produces.class);
- final Annotation httpAnnotation = getAnnotation(method, GET.class);
+ final Annotation producesAnnotation = getAnnotation(method, PRODUCES.qualifiedName);
+ final Annotation httpAnnotation = getAnnotation(method, GET.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(httpAnnotation).build();
metamodel.add(resourceMethod);
@@ -1803,17 +1802,17 @@
public void shouldUpdateResourceMethodWhenChangingProducesAnnotationValue() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "getCustomerAsVCard");
- final Annotation httpAnnotation = getAnnotation(method, GET.class);
- final Annotation producesAnnotation = getAnnotation(method, Produces.class, "application/foo");
+ final Annotation httpAnnotation = getAnnotation(method, GET.qualifiedName);
+ final Annotation producesAnnotation = getAnnotation(method, PRODUCES.qualifiedName, "application/foo");
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(httpAnnotation).produces(producesAnnotation).build();
metamodel.add(resourceMethod);
@@ -1831,17 +1830,17 @@
public void shouldUpdateResourceMethodWhenRemovingProducesAnnotation() throws CoreException {
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "getCustomerAsVCard");
- final Annotation httpAnnotation = getAnnotation(method, GET.class);
- final Annotation producesAnnotation = getAnnotation(method, Produces.class);
+ final Annotation httpAnnotation = getAnnotation(method, GET.qualifiedName);
+ final Annotation producesAnnotation = getAnnotation(method, PRODUCES.qualifiedName);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.httpMethod(httpAnnotation).produces(producesAnnotation).build();
metamodel.add(resourceMethod);
@@ -1865,21 +1864,21 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "getCustomer");
final JavaMethodParameter pathParameter = new JavaMethodParameter("id", Integer.class.getName(), null, null);
- final JavaMethodParameter contextParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(createAnnotation(Context.class, null)), null);
+ final JavaMethodParameter contextParameter = new JavaMethodParameter("uriInfo", URI_INFO.qualifiedName,
+ Arrays.asList(createAnnotation(CONTEXT.qualifiedName, null)), null);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class))
- .returnType(getType(Response.class.getName(), javaProject)).methodParameter(pathParameter)
+ .httpMethod(getAnnotation(method, GET.qualifiedName))
+ .returnType(getType(RESPONSE.qualifiedName, javaProject)).methodParameter(pathParameter)
.methodParameter(contextParameter).build();
metamodel.add(resourceMethod);
// operation
@@ -1897,22 +1896,22 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "getCustomer");
final JavaMethodParameter pathParameter = new JavaMethodParameter("id", Integer.class.getName(),
- Arrays.asList(createAnnotation(PathParam.class, "foo!")), null);
- final JavaMethodParameter contextParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(createAnnotation(Context.class, null)), null);
+ Arrays.asList(createAnnotation(PATH_PARAM.qualifiedName, "foo!")), null);
+ final JavaMethodParameter contextParameter = new JavaMethodParameter("uriInfo", URI_INFO.qualifiedName,
+ Arrays.asList(createAnnotation(CONTEXT.qualifiedName, null)), null);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class))
- .returnType(getType(Response.class.getName(), javaProject)).methodParameter(pathParameter)
+ .httpMethod(getAnnotation(method, GET.qualifiedName))
+ .returnType(getType(RESPONSE.qualifiedName, javaProject)).methodParameter(pathParameter)
.methodParameter(contextParameter).build();
metamodel.add(resourceMethod);
// operation
@@ -1930,22 +1929,22 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(PUT.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(PUT);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method
final IMethod method = getMethod(type, "updateCustomer");
final JavaMethodParameter pathParameter = new JavaMethodParameter("id", Integer.class.getName(),
- Arrays.asList(createAnnotation(PathParam.class, "id")), null);
+ Arrays.asList(createAnnotation(PATH_PARAM.qualifiedName, "id")), null);
final JavaMethodParameter customerParameter = new JavaMethodParameter("update",
"org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", Arrays.asList(createAnnotation(
- PathParam.class, "foo")), null);
+ PATH_PARAM.qualifiedName, "foo")), null);
final JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, PUT.class)).returnType(getType("void", javaProject))
+ .httpMethod(getAnnotation(method, PUT.qualifiedName)).returnType(getType("void", javaProject))
.methodParameter(pathParameter).methodParameter(customerParameter).build();
metamodel.add(resourceMethod);
// operation
@@ -1963,21 +1962,21 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (size param is not declared)
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int",
- Arrays.asList(createAnnotation(QueryParam.class, "start")), null);
- final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(createAnnotation(Context.class, null)), null);
+ Arrays.asList(createAnnotation(QUERY_PARAM.qualifiedName, "start")), null);
+ final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", URI_INFO.qualifiedName,
+ Arrays.asList(createAnnotation(CONTEXT.qualifiedName, null)), null);
final JaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List", javaProject))
+ .httpMethod(getAnnotation(method, GET.qualifiedName)).returnType(getType("java.util.List", javaProject))
.methodParameter(startParameter).methodParameter(uriInfoParameter).build();
metamodel.add(jaxrsMethod);
// operation
@@ -1996,19 +1995,19 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (color param is not declared)
final IMethod method = getMethod(type, "getPicture");
final JavaMethodParameter pathParameter = new JavaMethodParameter("id", String.class.getName(),
- Arrays.asList(createAnnotation(PathParam.class, null)), null);
+ Arrays.asList(createAnnotation(PATH_PARAM.qualifiedName, null)), null);
final JaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .pathTemplate(getAnnotation(method, Path.class)).methodParameter(pathParameter)
+ .pathTemplate(getAnnotation(method, PATH.qualifiedName)).methodParameter(pathParameter)
.returnType(getType("java.lang.Object", javaProject)).build();
metamodel.add(jaxrsMethod);
// operation
@@ -2027,23 +2026,23 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (@QueryParam on 'size' param is not declared)
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int",
- Arrays.asList(createAnnotation(QueryParam.class, "start")), null);
+ Arrays.asList(createAnnotation(QUERY_PARAM.qualifiedName, "start")), null);
final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int",
- Arrays.asList(createAnnotation(DefaultValue.class, "2")), null);
- final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(createAnnotation(Context.class, null)), null);
+ Arrays.asList(createAnnotation(DEFAULT_VALUE.qualifiedName, "2")), null);
+ final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", URI_INFO.qualifiedName,
+ Arrays.asList(createAnnotation(CONTEXT.qualifiedName, null)), null);
final JaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List", javaProject))
+ .httpMethod(getAnnotation(method, GET.qualifiedName)).returnType(getType("java.util.List", javaProject))
.methodParameter(startParameter).methodParameter(sizeParameter).methodParameter(uriInfoParameter)
.build();
metamodel.add(jaxrsMethod);
@@ -2062,24 +2061,24 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (QueryParam value is different: "length" vs
// "size" on second param)
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int",
- Arrays.asList(createAnnotation(QueryParam.class, "start")), null);
+ Arrays.asList(createAnnotation(QUERY_PARAM.qualifiedName, "start")), null);
final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(
- createAnnotation(QueryParam.class, "length"), createAnnotation(DefaultValue.class, "2")), null);
- final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(createAnnotation(Context.class, null)), null);
+ createAnnotation(QUERY_PARAM.qualifiedName, "length"), createAnnotation(DEFAULT_VALUE.qualifiedName, "2")), null);
+ final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", URI_INFO.qualifiedName,
+ Arrays.asList(createAnnotation(CONTEXT.qualifiedName, null)), null);
final JaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List", javaProject))
+ .httpMethod(getAnnotation(method, GET.qualifiedName)).returnType(getType("java.util.List", javaProject))
.methodParameter(startParameter).methodParameter(sizeParameter).methodParameter(uriInfoParameter)
.build();
metamodel.add(jaxrsMethod);
@@ -2098,23 +2097,23 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (with an extra @Queryparam annotation on 'uriInfo' param)
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int",
- Arrays.asList(createAnnotation(QueryParam.class, "start")), null);
+ Arrays.asList(createAnnotation(QUERY_PARAM.qualifiedName, "start")), null);
final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(
- createAnnotation(QueryParam.class, "size"), createAnnotation(DefaultValue.class, "2")), null);
- final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(createAnnotation(QueryParam.class, "foo"), createAnnotation(Context.class, null)), null);
+ createAnnotation(QUERY_PARAM.qualifiedName, "size"), createAnnotation(DEFAULT_VALUE.qualifiedName, "2")), null);
+ final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", URI_INFO.qualifiedName,
+ Arrays.asList(createAnnotation(QUERY_PARAM.qualifiedName, "foo"), createAnnotation(CONTEXT.qualifiedName, null)), null);
final JaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.util.List", javaProject))
+ .httpMethod(getAnnotation(method, GET.qualifiedName)).returnType(getType("java.util.List", javaProject))
.methodParameter(startParameter).methodParameter(sizeParameter).methodParameter(uriInfoParameter)
.build();
metamodel.add(jaxrsMethod);
@@ -2133,21 +2132,21 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
- // JAX-RS Resource Method (MatrixParam annotation on second parameter is not declared)
+ // JAX-RS Resource Method (MATRIX_PARAM.qualifiedName annotation on second parameter is not declared)
final IMethod method = getMethod(type, "getPicture");
final JavaMethodParameter startParameter = new JavaMethodParameter("id", Integer.class.getName(),
- Arrays.asList(createAnnotation(PathParam.class, "id")), null);
+ Arrays.asList(createAnnotation(PATH_PARAM.qualifiedName, "id")), null);
final JavaMethodParameter sizeParameter = new JavaMethodParameter("color", String.class.getName(),
new ArrayList<Annotation>(), null);
final JaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.lang.Object", javaProject))
+ .httpMethod(getAnnotation(method, GET.qualifiedName)).returnType(getType("java.lang.Object", javaProject))
.methodParameter(startParameter).methodParameter(sizeParameter).build();
metamodel.add(jaxrsMethod);
// operation
@@ -2165,21 +2164,21 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
- // JAX-RS Resource Method (MatrixParam value is different: "foo" vs "color" on second param)
+ // JAX-RS Resource Method (MATRIX_PARAM.qualifiedName value is different: "foo" vs "color" on second param)
final IMethod method = getMethod(type, "getPicture");
final JavaMethodParameter startParameter = new JavaMethodParameter("id", Integer.class.getName(),
- Arrays.asList(createAnnotation(PathParam.class, "id")), null);
+ Arrays.asList(createAnnotation(PATH_PARAM.qualifiedName, "id")), null);
final JavaMethodParameter sizeParameter = new JavaMethodParameter("color", String.class.getName(),
- Arrays.asList(createAnnotation(MatrixParam.class, "foo")), null);
+ Arrays.asList(createAnnotation(MATRIX_PARAM.qualifiedName, "foo")), null);
final JaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class)).returnType(getType("java.lang.Object", javaProject))
+ .httpMethod(getAnnotation(method, GET.qualifiedName)).returnType(getType("java.lang.Object", javaProject))
.methodParameter(startParameter).methodParameter(sizeParameter).build();
metamodel.add(jaxrsMethod);
// operation
@@ -2197,19 +2196,19 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
- // JAX-RS Resource Method (an extra MatrixParam annotation on 'id' param)
+ // JAX-RS Resource Method (an extra MATRIX_PARAM.qualifiedName annotation on 'id' param)
final IMethod method = getMethod(type, "getProduct");
final JavaMethodParameter pathParameter = new JavaMethodParameter("id", Integer.class.getName(), Arrays.asList(
- createAnnotation(MatrixParam.class, "foo"), createAnnotation(PathParam.class, "id")), null);
+ createAnnotation(MATRIX_PARAM.qualifiedName, "foo"), createAnnotation(PATH_PARAM.qualifiedName, "id")), null);
final JaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class))
+ .httpMethod(getAnnotation(method, GET.qualifiedName))
.returnType(getType("org.jboss.tools.ws.jaxrs.sample.domain.Book", javaProject))
.methodParameter(pathParameter).build();
metamodel.add(jaxrsMethod);
@@ -2228,25 +2227,25 @@
// the method signature is changed
// pre-conditions
// JAX-RS HttpMethod
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
metamodel.add(httpMethod);
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (declared return type is
// 'javax.ws.rs.Response')
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int",
- Arrays.asList(createAnnotation(QueryParam.class, "start")), null);
+ Arrays.asList(createAnnotation(QUERY_PARAM.qualifiedName, "start")), null);
final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(
- createAnnotation(QueryParam.class, "size"), createAnnotation(DefaultValue.class, "2")), null);
- final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(),
- Arrays.asList(createAnnotation(Context.class, null)), null);
+ createAnnotation(QUERY_PARAM.qualifiedName, "size"), createAnnotation(DEFAULT_VALUE.qualifiedName, "2")), null);
+ final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", URI_INFO.qualifiedName,
+ Arrays.asList(createAnnotation(CONTEXT.qualifiedName, null)), null);
final JaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
- .httpMethod(getAnnotation(method, GET.class))
- .returnType(getType(Response.class.getName(), javaProject)).methodParameter(startParameter)
+ .httpMethod(getAnnotation(method, GET.qualifiedName))
+ .returnType(getType(RESPONSE.qualifiedName, javaProject)).methodParameter(startParameter)
.methodParameter(sizeParameter).methodParameter(uriInfoParameter).build();
metamodel.add(jaxrsMethod);
// operation
@@ -2272,16 +2271,16 @@
// pre-conditions
// Parent JAX-RS Resource
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (@Context is not declared on 'uriInfo' param)
final IMethod method = getMethod(type, "getCustomers");
final JavaMethodParameter startParameter = new JavaMethodParameter("start", "int",
- Arrays.asList(createAnnotation(QueryParam.class, "start")), null);
+ Arrays.asList(createAnnotation(QUERY_PARAM.qualifiedName, "start")), null);
final JavaMethodParameter sizeParameter = new JavaMethodParameter("size", "int", Arrays.asList(
- createAnnotation(QueryParam.class, "length"), createAnnotation(DefaultValue.class, "2")), null);
- final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", UriInfo.class.getName(), null, null);
+ createAnnotation(QUERY_PARAM.qualifiedName, "length"), createAnnotation(DEFAULT_VALUE.qualifiedName, "2")), null);
+ final JavaMethodParameter uriInfoParameter = new JavaMethodParameter("uriInfo", URI_INFO.qualifiedName, null, null);
final JaxrsResourceMethod jaxrsMethod = new JaxrsResourceMethod.Builder(method, resource, metamodel)
.methodParameter(startParameter).methodParameter(sizeParameter).methodParameter(uriInfoParameter)
.build();
@@ -2310,7 +2309,7 @@
public void shouldDoNothingWhenAddingBasicJavaMethod() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (an extra annotation on 'start' param)
@@ -2326,7 +2325,7 @@
public void shouldDoNothingWhenChangingBasicJavaMethod() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (an extra annotation on 'start' param)
@@ -2342,7 +2341,7 @@
public void shouldDoNothingWhenRemovingBasicJavaMethod() throws CoreException {
// pre-conditions
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation pathAnnotation = getAnnotation(type, Path.class);
+ final Annotation pathAnnotation = getAnnotation(type, PATH.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(pathAnnotation).build();
metamodel.add(resource);
// JAX-RS Resource Method (an extra annotation on 'start' param)
Modified: branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java
===================================================================
--- branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -21,6 +21,13 @@
import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getType;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_ELEMENT_KIND;
import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PATH_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.APPLICATION_PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.CONSUMES;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.GET;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.POST;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PRODUCES;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.spy;
@@ -28,14 +35,6 @@
import java.util.LinkedList;
import java.util.List;
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -44,6 +43,7 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.ws.jaxrs.core.AbstractCommonTestCase;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBuiltinHttpMethod;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsEndpoint;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsHttpMethod;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsJavaApplication;
@@ -52,6 +52,7 @@
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceMethod;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceMethod.Builder;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
+import org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements;
import org.jboss.tools.ws.jaxrs.core.jdt.JavaMethodParameter;
import org.jboss.tools.ws.jaxrs.core.jdt.JavaMethodSignature;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
@@ -80,7 +81,7 @@
private JaxrsJavaApplication createApplication(String typeName) throws CoreException, JavaModelException {
final IType applicationType = getType(typeName, javaProject);
final JaxrsJavaApplication application = new JaxrsJavaApplication(applicationType,
- getAnnotation(applicationType, ApplicationPath.class), metamodel);
+ getAnnotation(applicationType, APPLICATION_PATH.qualifiedName), metamodel);
metamodel.add(application);
return application;
}
@@ -88,13 +89,13 @@
private JaxrsResource createResource(String typeName) throws CoreException, JavaModelException {
final IType resourceType = getType(typeName, javaProject);
final JaxrsResource resource = new JaxrsResource.Builder(resourceType, metamodel).pathTemplate(
- getAnnotation(resourceType, Path.class)).build();
+ getAnnotation(resourceType, PATH.qualifiedName)).build();
metamodel.add(resource);
return resource;
}
private JaxrsResourceMethod createResourceMethod(String methodName, JaxrsResource parentResource,
- Class<?> httpMethod) throws CoreException, JavaModelException {
+ EnumJaxrsElements httpMethodElement) throws CoreException, JavaModelException {
final IType javaType = parentResource.getJavaElement();
final ICompilationUnit compilationUnit = javaType.getCompilationUnit();
final IMethod javaMethod = getMethod(javaType, methodName);
@@ -102,8 +103,11 @@
JdtUtils.parse(compilationUnit, progressMonitor));
final Builder builder = new JaxrsResourceMethod.Builder(javaMethod, (JaxrsResource) parentResource, metamodel)
- .httpMethod(getAnnotation(javaMethod, httpMethod)).pathTemplate(getAnnotation(javaMethod, Path.class))
- .returnType(methodSignature.getReturnedType());
+ .pathTemplate(getAnnotation(javaMethod, PATH.qualifiedName)).returnType(methodSignature.getReturnedType());
+ if (httpMethodElement != null) {
+ builder.httpMethod(getAnnotation(javaMethod, httpMethodElement.qualifiedName));
+ }
+
for (JavaMethodParameter methodParam : methodSignature.getMethodParameters()) {
builder.methodParameter(methodParam);
}
@@ -112,14 +116,14 @@
return resourceMethod;
}
- private JaxrsHttpMethod createHttpMethod(Class<?> annotationClass) throws JavaModelException, CoreException {
- final IType type = getType(annotationClass.getName(), javaProject);
- final Annotation httpAnnotation = getAnnotation(type, HttpMethod.class);
+ private JaxrsHttpMethod createHttpMethod(String qualifiedName) throws JavaModelException, CoreException {
+ final IType type = getType(qualifiedName, javaProject);
+ final Annotation httpAnnotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, httpAnnotation, metamodel);
metamodel.add(httpMethod);
return httpMethod;
}
-
+
private JaxrsEndpoint createEndpoint(JaxrsMetamodel metamodel, JaxrsHttpMethod httpMethod, JaxrsResourceMethod... resourceMethods) {
JaxrsEndpoint endpoint = new JaxrsEndpoint(metamodel, httpMethod, new LinkedList<JaxrsResourceMethod>(
Arrays.asList(resourceMethods)));
@@ -145,14 +149,14 @@
@Test
public void shouldConstructSimpleEndpoint() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
- customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), Consumes.class));
- customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), Produces.class));
+ customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), CONSUMES.qualifiedName));
+ customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), PRODUCES.qualifiedName));
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource,
- GET.class);
+ GET);
customerResourceMethod.addOrUpdateAnnotation(getAnnotation(customerResourceMethod.getJavaElement(),
- Produces.class));
+ PRODUCES.qualifiedName));
// operation
JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
// verifications
@@ -166,12 +170,12 @@
@Test
public void shouldConstructEndpointFromSubresource() throws CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource producLocatorResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productLocatorMethod = createResourceMethod("getProductResourceLocator",
- producLocatorResource, GET.class);
+ producLocatorResource, GET);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- final JaxrsResourceMethod subresourceMethod = createResourceMethod("getProduct", bookResource, GET.class);
+ final JaxrsResourceMethod subresourceMethod = createResourceMethod("getProduct", bookResource, GET);
// operation
JaxrsEndpoint endpoint = createEndpoint(httpMethod, productLocatorMethod, subresourceMethod);
// verifications
@@ -186,10 +190,10 @@
@Test
public void shouldConstructEndpointWithQueryParams() throws CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource,
- GET.class);
+ GET);
// operation
JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
// verifications
@@ -200,10 +204,9 @@
@Test
public void shoudCreateEndpointWhenAddingResourceMethodInRootResource() throws CoreException {
// pre-conditions
- createHttpMethod(GET.class);
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource,
- GET.class);
+ GET);
// operation
JaxrsElementDelta event = new JaxrsElementDelta(customerResourceMethod, ADDED);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -215,10 +218,9 @@
@Test
public void shoudCreateEndpointWhenAddingSubresourceMethodInRootResource() throws JavaModelException, CoreException {
// pre-conditions
- createHttpMethod(GET.class);
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerSubresourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
// operation
JaxrsElementDelta event = new JaxrsElementDelta(customerSubresourceMethod, ADDED);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -231,12 +233,11 @@
public void shoudCreateEndpointWhenAddingSubresourceLocatorMethodInRootResource() throws JavaModelException,
CoreException {
// pre-conditions
- createHttpMethod(GET.class);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- createResourceMethod("getProduct", bookResource, GET.class);
+ createResourceMethod("getProduct", bookResource, GET);
// createEndpoint(httpMethod, bookResourceMethod);
final JaxrsResource gameResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.GameResource");
- createResourceMethod("getProduct", gameResource, GET.class);
+ createResourceMethod("getProduct", gameResource, GET);
// createEndpoint(httpMethod, gameResourceMethod);
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
@@ -254,11 +255,10 @@
@Test
public void shoudCreateEndpointWhenAddingResourceMethodInSubresource() throws JavaModelException, CoreException {
// pre-conditions
- createHttpMethod(GET.class);
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
createResourceMethod("getProductResourceLocator", productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getAllProducts", bookResource, GET.class);
+ final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getAllProducts", bookResource, GET);
// operation
final JaxrsElementDelta event = new JaxrsElementDelta(bookResourceMethod, ADDED);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -271,13 +271,12 @@
public void shoudCreateEndpointWhenChangingSubresourceLocatorMethodIntoSubresourceMethod()
throws JavaModelException, CoreException {
// pre-conditions
- createHttpMethod(GET.class);
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerSubresourceMethod = createResourceMethod("getCustomer", customerResource,
null);
assertThat(customerSubresourceMethod.getKind(), equalTo(EnumKind.SUBRESOURCE_LOCATOR));
// operation
- Annotation httpAnnotation = getAnnotation(customerSubresourceMethod.getJavaElement(), GET.class);
+ Annotation httpAnnotation = getAnnotation(customerSubresourceMethod.getJavaElement(), GET.qualifiedName);
final int flags = customerSubresourceMethod.addOrUpdateAnnotation(httpAnnotation);
JaxrsElementDelta event = new JaxrsElementDelta(customerSubresourceMethod, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -290,11 +289,10 @@
@Test
public void shoudCreateEndpointWhenAddingSubresourceMethodInSubresource() throws JavaModelException, CoreException {
// pre-conditions
- createHttpMethod(GET.class);
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
createResourceMethod("getProductResourceLocator", productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET.class);
+ final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET);
// operation
final JaxrsElementDelta event = new JaxrsElementDelta(bookResourceMethod, ADDED);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -312,10 +310,10 @@
public void shoudChangeUriPathTemplateWhenAddingApplication() throws JavaModelException, CoreException {
// the subresource becomes a root resource !
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/customers/{id}"));
// operation
@@ -333,10 +331,10 @@
public void shoudChangeUriPathTemplateWhenAddingResourcePathAnnotation() throws JavaModelException, CoreException {
// the subresource becomes a root resource !
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint fakeEndpoint = createEndpoint(httpMethod, customerResourceMethod);
// operation
final JaxrsElementDelta event = new JaxrsElementDelta(customerResource, CHANGED, F_ELEMENT_KIND
@@ -352,11 +350,11 @@
@Test
public void shoudChangeUriPathTemplateWhenAddingMethodPathAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
- final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), Path.class);
+ GET);
+ final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), PATH.qualifiedName);
customerResourceMethod.removeAnnotation(annotation.getJavaAnnotation().getHandleIdentifier());
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/customers"));
@@ -378,14 +376,14 @@
public void shoudChangeUriPathTemplateWhenChangingApplicationPathAnnotation() throws JavaModelException, CoreException {
// pre-conditions
final JaxrsJavaApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication");
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(metamodel, httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/app/customers/{id}"));
// operation
- final Annotation annotation = getAnnotation(application.getJavaElement(), ApplicationPath.class, "/foo");
+ final Annotation annotation = getAnnotation(application.getJavaElement(), APPLICATION_PATH.qualifiedName, "/foo");
int flags = application.addOrUpdateAnnotation(annotation);
final JaxrsElementDelta event = new JaxrsElementDelta(application, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -401,14 +399,14 @@
@Test
public void shoudChangeUriPathTemplateWhenChangingResourcePathAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/customers/{id}"));
// operation
- final Annotation annotation = getAnnotation(customerResource.getJavaElement(), Path.class, "/foo");
+ final Annotation annotation = getAnnotation(customerResource.getJavaElement(), PATH.qualifiedName, "/foo");
customerResource.addOrUpdateAnnotation(annotation);
final JaxrsElementDelta event = new JaxrsElementDelta(customerResource, CHANGED, F_PATH_VALUE);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -424,14 +422,14 @@
@Test
public void shoudChangeUriPathTemplateWhenChangingMethodPathAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/customers/{id}"));
// operation
- final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), Path.class, "{foo}");
+ final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), PATH.qualifiedName, "{foo}");
final int flags = customerResourceMethod.addOrUpdateAnnotation(annotation);
final JaxrsElementDelta event = new JaxrsElementDelta(customerResourceMethod, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -448,7 +446,7 @@
public void shoudChangeUriPathTemplateWhenRemovingResourcePathAnnotationAndMatchingSubresourceLocatorFound()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
// the subresource locator that will match the resourcemethod when the
// rootresource becomes a subresource
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
@@ -456,11 +454,11 @@
// the root resource that will become a subresource
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/customers/{id}"));
// operation
- final Annotation annotation = getAnnotation(customerResource.getJavaElement(), Path.class);
+ final Annotation annotation = getAnnotation(customerResource.getJavaElement(), PATH.qualifiedName);
final int flags = customerResource.removeAnnotation(annotation.getJavaAnnotation().getHandleIdentifier());
final JaxrsElementDelta event = new JaxrsElementDelta(customerResource, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -477,15 +475,15 @@
@Test
public void shoudChangeHttpVerbWhenChangingHttpMethodAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod("org.jboss.tools.ws.jaxrs.sample.services.FOO");
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/customers/{id}"));
// operation
int flags = httpMethod
- .addOrUpdateAnnotation(getAnnotation(httpMethod.getJavaElement(), HttpMethod.class, "BAR"));
+ .addOrUpdateAnnotation(getAnnotation(httpMethod.getJavaElement(), HTTP_METHOD.qualifiedName, "BAR"));
final JaxrsElementDelta event = new JaxrsElementDelta(httpMethod, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
// verifications
@@ -499,10 +497,10 @@
public void shoudChangeUriPathTemplateWhenRemovingMetamodelApplication() throws JavaModelException, CoreException {
// pre-conditions
final JaxrsJavaApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication");
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(metamodel, httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/app/customers/{id}"));
// operation : no 'application' left in the metamodel
@@ -521,14 +519,14 @@
@Test
public void shoudChangeUriPathTemplateWhenRemovingMethodPathAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/customers/{id}"));
// operation
- final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), Path.class);
+ final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), PATH.qualifiedName);
final int flags = customerResourceMethod.removeAnnotation(annotation.getJavaAnnotation().getHandleIdentifier());
final JaxrsElementDelta event = new JaxrsElementDelta(customerResourceMethod, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -544,15 +542,15 @@
@Test
public void shoudChangeConsumedMediatypesWhenAddingResourceAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
- POST.class);
+ POST);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getConsumedMediaTypes(), equalTo(Arrays.asList("*/*")));
// operation
final int flags = customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(),
- Consumes.class));
+ CONSUMES.qualifiedName));
final JaxrsElementDelta event = new JaxrsElementDelta(customerResource, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
// verifications
@@ -567,15 +565,15 @@
public void shoudChangeConsumedMediatypesWhenAddingResourceMethodAnnotation() throws JavaModelException,
CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
- POST.class);
+ POST);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getConsumedMediaTypes(), equalTo(Arrays.asList("*/*")));
// operation
final int flags = customerResourceMethod.addOrUpdateAnnotation(getAnnotation(
- customerResourceMethod.getJavaElement(), Consumes.class));
+ customerResourceMethod.getJavaElement(), CONSUMES.qualifiedName));
final JaxrsElementDelta event = new JaxrsElementDelta(customerResourceMethod, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
// verifications
@@ -590,18 +588,18 @@
public void shoudChangeConsumedMediatypesWhenChangingResourceMethodAnnotation() throws JavaModelException,
CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
- POST.class);
- final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), Consumes.class,
+ POST);
+ final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), CONSUMES.qualifiedName,
"application/foo");
customerResourceMethod.addOrUpdateAnnotation(annotation);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getConsumedMediaTypes(), equalTo(Arrays.asList("application/foo")));
// operation
int flags = customerResourceMethod.addOrUpdateAnnotation(getAnnotation(customerResourceMethod.getJavaElement(),
- Consumes.class));
+ CONSUMES.qualifiedName));
final JaxrsElementDelta event = new JaxrsElementDelta(customerResourceMethod, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
// verifications
@@ -615,18 +613,18 @@
@Test
public void shoudChangeConsumedMediatypesWhenChangingResourceAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
- final Annotation annotation = getAnnotation(customerResource.getJavaElement(), Consumes.class,
+ final Annotation annotation = getAnnotation(customerResource.getJavaElement(), CONSUMES.qualifiedName,
"application/foo");
customerResource.addOrUpdateAnnotation(annotation);
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
- POST.class);
+ POST);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getConsumedMediaTypes(), equalTo(Arrays.asList("application/foo")));
// operation
int flags = customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(),
- Consumes.class));
+ CONSUMES.qualifiedName));
final JaxrsElementDelta event = new JaxrsElementDelta(customerResourceMethod, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
// verifications
@@ -641,13 +639,13 @@
public void shoudChangeConsumedMediatypesWhenRemovingMethodAnnotationWithResourceDefault()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
- customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), Consumes.class,
+ customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), CONSUMES.qualifiedName,
"application/xml"));
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
- POST.class);
- final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), Consumes.class,
+ POST);
+ final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), CONSUMES.qualifiedName,
"application/foo");
customerResourceMethod.addOrUpdateAnnotation(annotation);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
@@ -668,11 +666,11 @@
public void shoudChangeConsumedMediatypesWhenRemovingMethodAnnotationWithoutResourceDefault()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
- POST.class);
- final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), Consumes.class,
+ POST);
+ final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), CONSUMES.qualifiedName,
"application/foo");
customerResourceMethod.addOrUpdateAnnotation(annotation);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
@@ -692,15 +690,15 @@
@Test
public void shoudChangeProducedMediatypesWhenAddingResourceAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getProducedMediaTypes(), equalTo(Arrays.asList("*/*")));
// operation
final int flags = customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(),
- Produces.class, "application/xml"));
+ PRODUCES.qualifiedName, "application/xml"));
final JaxrsElementDelta event = new JaxrsElementDelta(customerResource, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
// verifications
@@ -715,15 +713,15 @@
public void shoudChangeProducedMediatypesWhenAddingResourceMethodAnnotation() throws JavaModelException,
CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getProducedMediaTypes(), equalTo(Arrays.asList("*/*")));
// operation
final int flags = customerResourceMethod.addOrUpdateAnnotation(getAnnotation(
- customerResourceMethod.getJavaElement(), Produces.class));
+ customerResourceMethod.getJavaElement(), PRODUCES.qualifiedName));
final JaxrsElementDelta event = new JaxrsElementDelta(customerResourceMethod, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
// verifications
@@ -737,18 +735,18 @@
@Test
public void shoudChangeProducedMediatypesWhenChangingResourceAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
- final Annotation annotation = getAnnotation(customerResource.getJavaElement(), Produces.class,
+ final Annotation annotation = getAnnotation(customerResource.getJavaElement(), PRODUCES.qualifiedName,
"application/foo");
customerResource.addOrUpdateAnnotation(annotation);
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getProducedMediaTypes(), equalTo(Arrays.asList("application/foo")));
// operation
int flags = customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(),
- Produces.class, "application/xml"));
+ PRODUCES.qualifiedName, "application/xml"));
final JaxrsElementDelta event = new JaxrsElementDelta(customerResource, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
// verifications
@@ -763,18 +761,18 @@
public void shoudChangeProducedMediatypesWhenChangingResourceMethodAnnotation() throws JavaModelException,
CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource,
- POST.class);
- final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), Produces.class,
+ POST);
+ final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), PRODUCES.qualifiedName,
"application/foo");
customerResourceMethod.addOrUpdateAnnotation(annotation);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getProducedMediaTypes(), equalTo(Arrays.asList("application/foo")));
// operation
int flags = customerResourceMethod.addOrUpdateAnnotation(getAnnotation(customerResourceMethod.getJavaElement(),
- Produces.class));
+ PRODUCES.qualifiedName));
final JaxrsElementDelta event = new JaxrsElementDelta(customerResourceMethod, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
// verifications
@@ -789,13 +787,13 @@
public void shoudChangeProducedMediatypesWhenRemovingMethodAnnotationWithResourceDefault()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
- customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), Produces.class,
+ customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), PRODUCES.qualifiedName,
"application/xml"));
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource,
- POST.class);
- final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), Produces.class,
+ POST);
+ final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), PRODUCES.qualifiedName,
"application/foo");
customerResourceMethod.addOrUpdateAnnotation(annotation);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
@@ -816,11 +814,11 @@
public void shoudChangeProducedMediatypesWhenRemovingMethodAnnotationWithoutResourceDefault()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
- POST.class);
- final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), Consumes.class,
+ POST);
+ final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), CONSUMES.qualifiedName,
"application/foo");
customerResourceMethod.addOrUpdateAnnotation(annotation);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
@@ -840,10 +838,10 @@
@Test
public void shoudRemoveEndpointWhenRemovingHttpMethodAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = createHttpMethod("org.jboss.tools.ws.jaxrs.sample.services.FOO");
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/customers/{id}"));
// operation
@@ -860,15 +858,15 @@
public void shoudRemoveEndpointWhenRemovingResourcePathAnnotationAndMatchingSubresourceLocatorNotFound()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/customers/{id}"));
// operation
- final Annotation annotation = getAnnotation(customerResource.getJavaElement(), Path.class);
+ final Annotation annotation = getAnnotation(customerResource.getJavaElement(), PATH.qualifiedName);
final int flags = customerResource.removeAnnotation(annotation.getJavaAnnotation().getHandleIdentifier());
final JaxrsElementDelta event = new JaxrsElementDelta(customerResource, CHANGED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -882,13 +880,13 @@
@Test
public void shoudRemoveEndpointsWhenRemovingRootResource() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod1 = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint1 = createEndpoint(httpMethod, customerResourceMethod1);
final JaxrsResourceMethod customerResourceMethod2 = createResourceMethod("getCustomers", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint2 = createEndpoint(httpMethod, customerResourceMethod2);
// operation
final JaxrsElementDelta event = new JaxrsElementDelta(customerResource, REMOVED);
@@ -904,16 +902,16 @@
@Test
public void shoudRemoveEndpointsWhenRemovingSubresource() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET.class);
+ final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET);
final JaxrsEndpoint bookEndpoint = createEndpoint(httpMethod, productResourceLocatorMethod, bookResourceMethod);
// adding an extra endpoint that shouldn't be affected
final JaxrsResource gameResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.GameResource");
- final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET.class);
+ final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET);
createEndpoint(httpMethod, gameResourceMethod);
// operation
final JaxrsElementDelta event = new JaxrsElementDelta(bookResource, REMOVED);
@@ -927,15 +925,15 @@
@Test
public void shoudRemoveEndpointsWhenRemovingHttpMethod() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
createResourceMethod("getProductResourceLocator", productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET.class);
+ final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET);
final JaxrsEndpoint bookEndpoint = createEndpoint(httpMethod, bookResourceMethod);
// adding an extra endpoint that shouldn't be affected
final JaxrsResource gameResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.GameResource");
- final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET.class);
+ final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET);
createEndpoint(httpMethod, gameResourceMethod);
final Annotation httpAnnotation = bookResourceMethod.getHttpMethodAnnotation();
final int flags = bookResourceMethod.removeAnnotation(httpAnnotation.getJavaAnnotation().getHandleIdentifier());
@@ -951,18 +949,18 @@
@Test
public void shoudAddEndpointsWhenChangingSubresourceLocatorReturnType() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET.class);
+ final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET);
productResourceLocatorMethod.update(new JavaMethodSignature(productResourceLocatorMethod.getJavaElement(),
bookResource.getJavaElement(), productResourceLocatorMethod.getJavaMethodParameters()));
createEndpoint(httpMethod, productResourceLocatorMethod, bookResourceMethod);
// adding an extra subresource that should be affected later
final JaxrsResource gameResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.GameResource");
- final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET.class);
+ final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET);
assertThat(metamodel.getAllEndpoints().size(), equalTo(1));
// operation
final IType objectType = JdtUtils.resolveType(Object.class.getName(), javaProject, progressMonitor);
@@ -981,16 +979,16 @@
@Test
public void shoudRemoveEndpointsWhenChangingSubresourceLocatorReturnType() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET.class);
+ final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET);
createEndpoint(httpMethod, productResourceLocatorMethod, bookResourceMethod);
// adding an extra subresource that should be affected later
final JaxrsResource gameResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.GameResource");
- final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET.class);
+ final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET);
createEndpoint(httpMethod, productResourceLocatorMethod, gameResourceMethod);
assertThat(metamodel.getAllEndpoints().size(), equalTo(2));
// operation
@@ -1011,15 +1009,15 @@
@Test
public void shoudRemoveEndpointsWhenRemovingSubresourceLocatorResource() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET.class);
+ final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET);
final JaxrsEndpoint bookEndpoint = createEndpoint(httpMethod, productResourceLocatorMethod, bookResourceMethod);
final JaxrsResource gameResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.GameResource");
- final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET.class);
+ final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET);
final JaxrsEndpoint gameEndpoint = createEndpoint(httpMethod, productResourceLocatorMethod, gameResourceMethod);
// operation
final JaxrsElementDelta event = new JaxrsElementDelta(productResourceLocator, REMOVED);
@@ -1035,10 +1033,10 @@
@Test
public void shoudRemoveEndpointWhenRemovingResourceMethodInRootResource() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
// operation
final JaxrsElementDelta event = new JaxrsElementDelta(customerResourceMethod, REMOVED);
@@ -1054,13 +1052,13 @@
public void shoudRemoveEndpointWhenRemovingSubresourceMethodInRootResource() throws JavaModelException,
CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
- GET.class);
+ GET);
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
// operation
- final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), Path.class);
+ final Annotation annotation = getAnnotation(customerResourceMethod.getJavaElement(), PATH.qualifiedName);
final int flags = customerResourceMethod.removeAnnotation(annotation.getJavaAnnotation().getHandleIdentifier());
final JaxrsElementDelta event = new JaxrsElementDelta(customerResourceMethod, REMOVED, flags);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
@@ -1074,15 +1072,15 @@
@Test
public void shoudRemoveEndpointWhenRemovingSubresourceLocatorMethod() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET.class);
+ final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET);
final JaxrsEndpoint bookEndpoint = createEndpoint(httpMethod, productResourceLocatorMethod, bookResourceMethod);
final JaxrsResource gameResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.GameResource");
- final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET.class);
+ final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET);
final JaxrsEndpoint gameEndpoint = createEndpoint(httpMethod, productResourceLocatorMethod, gameResourceMethod);
// operation
final JaxrsElementDelta event = new JaxrsElementDelta(productResourceLocatorMethod, REMOVED);
@@ -1099,18 +1097,18 @@
public void shoudRemoveEndpointWhenSubresourceLocatorRootResourceBecomesSubresource() throws JavaModelException,
CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET.class);
+ final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getProduct", bookResource, GET);
final JaxrsEndpoint bookEndpoint = createEndpoint(httpMethod, productResourceLocatorMethod, bookResourceMethod);
final JaxrsResource gameResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.GameResource");
- final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET.class);
+ final JaxrsResourceMethod gameResourceMethod = createResourceMethod("getProduct", gameResource, GET);
final JaxrsEndpoint gameEndpoint = createEndpoint(httpMethod, productResourceLocatorMethod, gameResourceMethod);
final Annotation productResourceLocatorPathAnnotation = getAnnotation(productResourceLocator.getJavaElement(),
- Path.class);
+ PATH.qualifiedName);
final int flags = productResourceLocator.removeAnnotation(productResourceLocatorPathAnnotation
.getJavaAnnotation().getHandleIdentifier());
// operation
Modified: branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
===================================================================
--- branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -19,6 +19,13 @@
import static org.hamcrest.Matchers.notNullValue;
import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getAnnotation;
import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getType;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.APPLICATION_PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.CONSUMES;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.DELETE;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.GET;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.POST;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PUT;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
@@ -30,14 +37,6 @@
import java.util.Iterator;
import java.util.List;
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -61,6 +60,7 @@
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsWebxmlApplication;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
import org.jboss.tools.ws.jaxrs.core.jdt.CompilationUnitsRepository;
+import org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
@@ -102,7 +102,7 @@
* @throws JavaModelException
*/
private JaxrsJavaApplication createApplication(IType type) throws JavaModelException {
- final Annotation annotation = getAnnotation(type, ApplicationPath.class);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
return new JaxrsJavaApplication(type, annotation, metamodel);
}
@@ -114,7 +114,7 @@
* @throws JavaModelException
*/
private JaxrsJavaApplication createApplication(IType type, String applicationPath) throws JavaModelException {
- final Annotation annotation = getAnnotation(type, ApplicationPath.class, applicationPath);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName, applicationPath);
return new JaxrsJavaApplication(type, annotation, metamodel);
}
@@ -134,21 +134,21 @@
* @throws CoreException
* @throws JavaModelException
*/
- private JaxrsHttpMethod createHttpMethod(Class<?> httpClass) throws CoreException, JavaModelException {
- final IType httpMethodType = JdtUtils.resolveType(httpClass.getName(), javaProject, progressMonitor);
- final Annotation httpMethodAnnotation = getAnnotation(httpMethodType, HttpMethod.class);
+ private JaxrsHttpMethod createHttpMethod(EnumJaxrsElements httpMethodElement) throws CoreException, JavaModelException {
+ final IType httpMethodType = JdtUtils.resolveType(httpMethodElement.qualifiedName, javaProject, progressMonitor);
+ final Annotation httpMethodAnnotation = getAnnotation(httpMethodType, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(httpMethodType, httpMethodAnnotation, metamodel);
return httpMethod;
}
private JaxrsHttpMethod createHttpMethod(IType type) throws JavaModelException {
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
return httpMethod;
}
private JaxrsHttpMethod createHttpMethod(IType type, String httpVerb) throws JavaModelException {
- final Annotation annotation = getAnnotation(type, HttpMethod.class, httpVerb);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName, httpVerb);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
return httpMethod;
}
@@ -171,21 +171,9 @@
return affectedMetamodel.getAffectedElements();
}
- /**
- * Because sometimes, generics are painful...
- *
- * @param elements
- * @return private List<IJaxrsElement<?>> asList(IJaxrsElement<?>... elements) { final List<IJaxrsElement<?>> result
- * = new ArrayList<IJaxrsElement<?>>(); result.addAll(Arrays.asList(elements)); return result; }
- */
-
@Test
public void shouldAddHttpMethodsAndResourcesWhenAddingSourceFolderWithExistingMetamodel() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
// operation
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
@@ -196,21 +184,17 @@
assertThat(affectedMetamodel.getDeltaKind(), equalTo(CHANGED));
assertThat(affectedMetamodel.getMetamodel(), equalTo((IJaxrsMetamodel) metamodel));
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
- // 1 application + 1 HttpMethod + 4 RootResources + 2 Subresources
+ // 1 application + 1 HttpMethod + 7 Resources
assertThat(affectedElements.size(), equalTo(9));
assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
- // all HttpMethods, Resources, ResourceMethods and ResourceFields
- assertThat(metamodel.getElements(javaProject).size(), equalTo(34));
+ // all HttpMethods, Resources, ResourceMethods and ResourceFields. only application is available: the java-based one found in src/main/java
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(30));
}
@Test
public void shouldAddHttpMethodsAndResourcesWhenAddingSourceFolderWithExistingMetamodelWithReset()
throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
// operation
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
@@ -222,11 +206,12 @@
metamodel = (JaxrsMetamodel) affectedMetamodel.getMetamodel();
assertThat(metamodel, equalTo((IJaxrsMetamodel) metamodel));
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
- // 1 application + 1 HttpMethod + 4 RootResources + 2 Subresources
- assertThat(affectedElements.size(), equalTo(15));
+ // 1 application + 1 HttpMethod + 7 Resources
+ assertThat(affectedElements.size(), equalTo(9));
assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
- // all Applications, HttpMethods (including @OPTIONS and @HEAD), Resources, ResourceMethods and ResourceFields
- assertThat(metamodel.getElements(javaProject).size(), equalTo(37));
+ // all project-specific Applications, HttpMethods, Resources, ResourceMethods and ResourceFields (built-in HttpMethods are not bound to a project)
+ // 2 applications are available: the java-based and the web.xml since a full build was performed
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(31));
}
/**
@@ -255,25 +240,22 @@
metamodel = (JaxrsMetamodel) affectedMetamodel.getMetamodel();
assertThat(metamodel, notNullValue());
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
- assertThat(affectedElements.size(), equalTo(15));
- // all Applications, HttpMethods (including @OPTIONS and @HEAD), project Resources, ResourceMethods and ResourceFields
- assertThat(metamodel.getElements(javaProject).size(), equalTo(37));
+ assertThat(affectedElements.size(), equalTo(9));
+ // all Applications, HttpMethods, Resources, ResourceMethods and ResourceFields specific to the project
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(31));
}
@Test
- public void shouldAdd6HttpMethodsAnd0ResourceWhenAddingBinaryLib() throws CoreException {
+ public void shouldNotAddAnythingAddingBinaryLib() throws CoreException {
// pre-conditions
final IPackageFragmentRoot lib = WorkbenchUtils.getPackageFragmentRoot(javaProject,
"lib/jaxrs-api-2.0.1.GA.jar", progressMonitor);
// operation
final ResourceDelta event = createEvent(lib.getResource(), ADDED);
final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
- // verifications. Damned : none in the jar...
- assertThat(affectedElements.size(), equalTo(6));
- assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
- verify(metamodel, times(6)).add(any(JaxrsHttpMethod.class));
- assertThat(metamodel.getElements(javaProject).size(), equalTo(6));
+ // verifications: jar should not be taken into account, even if if it contains matching elements...
+ assertThat(affectedElements.size(), equalTo(0));
}
@Test
@@ -296,7 +278,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, ApplicationPath.class);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
// operation
final ResourceDelta event = createEvent(annotation.getJavaParent().getResource(), CHANGED);
final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
@@ -333,7 +315,7 @@
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
metamodel.add(createApplication(type));
- final Annotation annotation = getAnnotation(type, ApplicationPath.class);
+ final Annotation annotation = getAnnotation(type, APPLICATION_PATH.qualifiedName);
// operation
WorkbenchUtils.delete(annotation.getJavaAnnotation(), false);
final ResourceDelta event = createEvent(annotation.getJavaParent().getResource(), CHANGED);
@@ -371,7 +353,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
// operation
@@ -574,23 +556,20 @@
}
@Test
- public void shouldRemoveHttpMethodWhenRemovingBinaryLib() throws CoreException {
+ public void shouldNotRemoveHttpMethodWhenRemovingBinaryLib() throws CoreException {
// pre-conditions
final IPackageFragmentRoot lib = WorkbenchUtils.getPackageFragmentRoot(javaProject,
"lib/jaxrs-api-2.0.1.GA.jar", progressMonitor);
// let's suppose that this jar only contains 1 HTTP Methods ;-)
final IType type = JdtUtils.resolveType("javax.ws.rs.GET", javaProject, progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
// operation
final ResourceDelta event = createEvent(lib.getResource(), REMOVED);
final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
// verifications
- assertThat(affectedElements.size(), equalTo(1));
- assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.HTTP_METHOD));
- assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(REMOVED))));
- assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
+ assertThat(affectedElements.size(), equalTo(0));
}
@Test
@@ -598,7 +577,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
// operation
final ResourceDelta event = createEvent(annotation.getJavaParent().getResource(), CHANGED);
final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
@@ -635,7 +614,7 @@
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
metamodel.add(createHttpMethod(type));
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
// operation
WorkbenchUtils.delete(annotation.getJavaAnnotation(), false);
final ResourceDelta event = createEvent(annotation.getJavaParent().getResource(), CHANGED);
@@ -655,7 +634,7 @@
// JaxrsMetamodel metamodel = new JaxrsMetamodel(javaProject);
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
// operation
@@ -674,7 +653,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
// operation
@@ -694,7 +673,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, annotation, metamodel);
metamodel.add(httpMethod);
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
@@ -713,10 +692,10 @@
@Test
public void shouldAddResourceWhenAddingSourceCompilationUnit() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
// operation
IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final ResourceDelta event = createEvent(type.getResource(), ADDED);
@@ -732,10 +711,10 @@
@Test
public void shouldAddResourceWhenChangingResource() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
metamodel.add(createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource"));
final IType customerType = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
// operation
@@ -751,10 +730,10 @@
@Test
public void shouldChangeExistingResourceWhenChangingResource() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
metamodel.add(createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource"));
final JaxrsResource resource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
metamodel.add(resource);
@@ -773,10 +752,10 @@
@Test
public void shouldAddResourceMethodWhenChangingResource() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
bookResource.removeMethod(bookResource.getAllMethods().get(0));
metamodel.add(bookResource);
@@ -794,10 +773,10 @@
@Test
public void shouldChangeResourceMethodWhenChangingResource() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
metamodel.add(bookResource);
// operation
@@ -825,10 +804,10 @@
@Test
public void shouldRemoveResourceMethodWhenChangingResource() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
metamodel.add(bookResource);
// operation
@@ -851,10 +830,10 @@
@Test
public void shouldAddResourceFieldWhenChangingResource() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
productResourceLocator.removeField(productResourceLocator.getAllFields().get(0));
metamodel.add(productResourceLocator);
@@ -872,10 +851,10 @@
@Test
public void shouldChangeResourceFieldWhenChangingResource() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
metamodel.add(productResourceLocator);
// operation
@@ -901,10 +880,10 @@
@Test
public void shouldRemoveResourceFieldWhenChangingResource() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
metamodel.add(productResourceLocator);
// operation
@@ -928,10 +907,10 @@
@Test
public void shouldRemoveExistingResourceWhenChangingResource() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
final JaxrsResource resource = createResource("org.jboss.tools.ws.jaxrs.sample.services.GameResource");
metamodel.add(resource);
// operation
@@ -951,10 +930,10 @@
@Test
public void shouldRemoveResourceWhenRemovingCompilationUnit() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
final JaxrsResource resource = createResource("org.jboss.tools.ws.jaxrs.sample.services.GameResource");
metamodel.add(resource);
// operation
@@ -972,10 +951,10 @@
@Test
public void shouldRemoveResourceWhenRemovingSourceType() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
final JaxrsResource resource = createResource("org.jboss.tools.ws.jaxrs.sample.services.GameResource");
metamodel.add(resource);
// operation
@@ -997,7 +976,7 @@
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final Annotation annotation = getAnnotation(type, Consumes.class);
+ final Annotation annotation = getAnnotation(type, CONSUMES.qualifiedName);
final JaxrsResource resource = new JaxrsResource.Builder(type, metamodel).pathTemplate(annotation).build();
metamodel.add(resource);
// operation
@@ -1020,10 +999,10 @@
@Test
public void shouldRemoveResourceWhenRemovingMethodsFieldsAndAnnotations() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET.class));
- metamodel.add(createHttpMethod(POST.class));
- metamodel.add(createHttpMethod(PUT.class));
- metamodel.add(createHttpMethod(DELETE.class));
+ metamodel.add(createHttpMethod(GET));
+ metamodel.add(createHttpMethod(POST));
+ metamodel.add(createHttpMethod(PUT));
+ metamodel.add(createHttpMethod(DELETE));
final JaxrsResource resourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
metamodel.add(resourceLocator);
// operation
Modified: branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java
===================================================================
--- branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -13,25 +13,24 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.nullValue;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getAnnotation;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getMethod;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getType;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.GET;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.QUERY_PARAM;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.spy;
-import javax.ws.rs.GET;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.Path;
-import javax.ws.rs.QueryParam;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.ws.jaxrs.core.AbstractCommonTestCase;
-import org.jboss.tools.ws.jaxrs.core.WorkbenchUtils;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsHttpMethod;
@@ -52,38 +51,25 @@
metamodel = spy(JaxrsMetamodel.create(javaProject));
}
- private IType getType(String typeName) throws CoreException {
- return JdtUtils.resolveType(typeName, javaProject, progressMonitor);
- }
-
- private IMethod getMethod(IType parentType, String methodName) throws JavaModelException {
- return WorkbenchUtils.getMethod(parentType, methodName);
- }
-
- private Annotation getAnnotation(final IMember member, final Class<?> annotationClass) throws JavaModelException {
- return JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, progressMonitor), annotationClass);
- }
-
@Test
public void shouldCreateRootResourceFromPathAnnotation() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
- final Annotation annotation = getAnnotation(type, Path.class);
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
+ final Annotation annotation = getAnnotation(type, PATH.qualifiedName);
// operation
final JaxrsJavaElement<?> element = factory.createElement(annotation.getJavaAnnotation(),
JdtUtils.parse(type, progressMonitor), metamodel);
// verifications
assertNotNull(element);
final IJaxrsResource resource = (IJaxrsResource) element;
- // only @Path annotation is known by the metamodel, so pure resource
- // methods with @GET, etc. are not created here.
- assertThat(resource.getAllMethods().size(), equalTo(4));
+ // result contains a mix of resource methods and subresource methods since http methods are built-in the metamodel
+ assertThat(resource.getAllMethods().size(), equalTo(6));
}
@Test
public void shouldCreateRootResourceFromType() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
// operation
final JaxrsResource element = factory.createResource(type, JdtUtils.parse(type, progressMonitor), metamodel);
// verifications
@@ -93,7 +79,7 @@
@Test
public void shouldCreateSubesourceFromType() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource", javaProject);
// operation
final JaxrsResource element = factory.createResource(type, JdtUtils.parse(type, progressMonitor), metamodel);
// verifications
@@ -103,8 +89,8 @@
@Test
public void shouldCreateHttpMethodFromAnnotation() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.FOO");
- final Annotation annotation = getAnnotation(type, HttpMethod.class);
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject);
+ final Annotation annotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
// operation
final JaxrsJavaElement<?> element = factory.createElement(annotation.getJavaAnnotation(),
JdtUtils.parse(type, progressMonitor), metamodel);
@@ -117,7 +103,7 @@
@Test
public void shouldNotCreateElementFromOtherType() throws CoreException {
// pre-conditions
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.domain.Customer");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.domain.Customer", javaProject);
// operation
final JaxrsResource resource = factory.createResource(type, JdtUtils.parse(type, progressMonitor), metamodel);
// verifications
@@ -127,13 +113,13 @@
@Test
public void shouldCreateMethodInRootResourceFromAnnotation() throws CoreException {
// pre-conditions
- final IType httpType = getType(GET.class.getName());
- final Annotation httpAnnotation = getAnnotation(httpType, HttpMethod.class);
+ final IType httpType = getType(GET.qualifiedName, javaProject);
+ final Annotation httpAnnotation = getAnnotation(httpType, HTTP_METHOD.qualifiedName);
JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(httpType, httpAnnotation, metamodel);
metamodel.add(httpMethod);
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final IMethod method = getMethod(type, "getCustomerAsVCard");
- final Annotation annotation = getAnnotation(method, Path.class);
+ final Annotation annotation = getAnnotation(method, PATH.qualifiedName);
// operation
JaxrsResourceMethod element = factory.createResourceMethod(annotation,
JdtUtils.parse(method, progressMonitor), metamodel);
@@ -145,13 +131,13 @@
@Test
public void shouldCreateMethodInSubresourceFromAnnotation() throws CoreException {
// pre-conditions
- final IType httpType = getType(GET.class.getName());
- final Annotation httpAnnotation = getAnnotation(httpType, HttpMethod.class);
+ final IType httpType = getType(GET.qualifiedName, javaProject);
+ final Annotation httpAnnotation = getAnnotation(httpType, HTTP_METHOD.qualifiedName);
JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(httpType, httpAnnotation, metamodel);
metamodel.add(httpMethod);
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource", javaProject);
final IMethod method = getMethod(type, "getProduct");
- final Annotation annotation = getAnnotation(method, Path.class);
+ final Annotation annotation = getAnnotation(method, PATH.qualifiedName);
// operation
JaxrsResourceMethod element = factory.createResourceMethod(annotation,
JdtUtils.parse(method, progressMonitor), metamodel);
@@ -163,14 +149,14 @@
@Test
public void shouldCreateFieldFromAnnotation() throws CoreException {
// pre-conditions
- final IType httpType = getType(GET.class.getName());
- final Annotation httpAnnotation = getAnnotation(httpType, HttpMethod.class);
+ final IType httpType = getType(GET.qualifiedName, javaProject);
+ final Annotation httpAnnotation = getAnnotation(httpType, HTTP_METHOD.qualifiedName);
JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(httpType, httpAnnotation, metamodel);
metamodel.add(httpMethod);
- final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
+ final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator", javaProject);
IField field = type.getField("foo");
- final Annotation annotation = getAnnotation(field, QueryParam.class);
+ final Annotation annotation = getAnnotation(field, QUERY_PARAM.qualifiedName);
// operation
JaxrsResourceField element = factory.createField(annotation, JdtUtils.parse(field, progressMonitor), metamodel);
// verifications
Modified: branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java
===================================================================
--- branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -16,8 +16,10 @@
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getAnnotation;
import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getMethod;
import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getType;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
import static org.junit.Assert.assertThat;
import java.lang.annotation.Target;
@@ -67,8 +69,7 @@
public void shouldGetHttpMethodByAnnotation() throws CoreException {
IType javaType = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject,
progressMonitor);
- final Annotation annotation = JdtUtils.resolveAnnotation(javaType, JdtUtils.parse(javaType, progressMonitor),
- javax.ws.rs.HttpMethod.class);
+ final Annotation annotation = getAnnotation(javaType, HTTP_METHOD.qualifiedName);
assertThat((JaxrsHttpMethod) metamodel.getElement(annotation), notNullValue());
}
@@ -117,7 +118,7 @@
@Test
public void shouldAssertHTTPMethods() throws CoreException {
- // 6 HttpMethods in the jax-rs API (@GET, etc.) + 1 in the project
+ // 6 fixed HttpMethods as part of the jax-rs API (@GET, etc.) + 1 in the project
// (@FOO)
Assert.assertEquals(1 * 7, metamodel.getAllHttpMethods().size());
Set<IJaxrsHttpMethod> jaxrsHttpMethods = new HashSet<IJaxrsHttpMethod>();
@@ -223,6 +224,7 @@
Collections.sort(httpMethods);
assertThat(httpMethods.get(0).getHttpVerb(), equalTo("GET"));
assertThat(httpMethods.get(5).getHttpVerb(), equalTo("OPTIONS"));
+ assertThat(httpMethods.get(6).getHttpVerb(), equalTo("FOO"));
}
Modified: branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java
===================================================================
--- branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -11,13 +11,13 @@
package org.jboss.tools.ws.jaxrs.core.internal.metamodel.validation;
import static org.hamcrest.Matchers.equalTo;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getAnnotation;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH;
import static org.junit.Assert.assertThat;
import java.util.List;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.Path;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
@@ -52,7 +52,7 @@
// preconditions
IType fooType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject);
final JaxrsHttpMethod httpMethod = metamodel.getElement(fooType, JaxrsHttpMethod.class);
- Annotation httpAnnotation = WorkbenchUtils.getAnnotation(fooType, HttpMethod.class, new String[0]);
+ Annotation httpAnnotation = getAnnotation(fooType, HTTP_METHOD.qualifiedName, new String[0]);
httpMethod.addOrUpdateAnnotation(httpAnnotation);
// operation
final List<ValidatorMessage> validationMessages = httpMethod.validate();
@@ -101,7 +101,7 @@
final JaxrsBaseElement customerResource = metamodel.getElement(customerJavaType);
IMethod customerJavaMethod = WorkbenchUtils.getMethod(customerJavaType, "getCustomer");
final JaxrsResourceMethod customerResourceMethod = metamodel.getElement(customerJavaMethod, JaxrsResourceMethod.class);
- Annotation pathAnnotation = WorkbenchUtils.getAnnotation(customerJavaMethod, Path.class, "/{foo}");
+ Annotation pathAnnotation = getAnnotation(customerJavaMethod, PATH.qualifiedName, "/{foo}");
customerResourceMethod.addOrUpdateAnnotation(pathAnnotation);
// operation
final List<ValidatorMessage> validationMessages = customerResource.validate();
Modified: branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java
===================================================================
--- branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -3,10 +3,9 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.APPLICATION;
import static org.junit.Assert.assertThat;
-import javax.ws.rs.core.Application;
-
import org.eclipse.core.resources.IResource;
import org.jboss.tools.ws.jaxrs.core.AbstractCommonTestCase;
import org.jboss.tools.ws.jaxrs.core.WorkbenchUtils;
@@ -38,7 +37,7 @@
// pre-conditions
WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_3-with-servlet-mapping.xml", bundle);
// operation
- final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ final String applicationPath = WtpUtils.getApplicationPath(project, APPLICATION.qualifiedName);
// verifications
assertThat(applicationPath, equalTo("/hello/*"));
}
@@ -48,7 +47,7 @@
// pre-conditions
WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_3-without-servlet-mapping.xml", bundle);
// operation
- final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ final String applicationPath = WtpUtils.getApplicationPath(project, APPLICATION.qualifiedName);
// verifications
assertThat(applicationPath, nullValue());
}
@@ -58,7 +57,7 @@
// pre-conditions
WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_4-with-servlet-mapping.xml", bundle);
// operation
- final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ final String applicationPath = WtpUtils.getApplicationPath(project, APPLICATION.qualifiedName);
// verifications
assertThat(applicationPath, equalTo("/hello/*"));
}
@@ -68,7 +67,7 @@
// pre-conditions
WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_4-without-servlet-mapping.xml", bundle);
// operation
- final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ final String applicationPath = WtpUtils.getApplicationPath(project, APPLICATION.qualifiedName);
// verifications
assertThat(applicationPath, nullValue());
}
@@ -78,7 +77,7 @@
// pre-conditions
WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_5-with-servlet-mapping.xml", bundle);
// operation
- final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ final String applicationPath = WtpUtils.getApplicationPath(project, APPLICATION.qualifiedName);
// verifications
assertThat(applicationPath, equalTo("/hello/*"));
}
@@ -88,7 +87,7 @@
// pre-conditions
WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_5-without-servlet-mapping.xml", bundle);
// operation
- final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ final String applicationPath = WtpUtils.getApplicationPath(project, APPLICATION.qualifiedName);
// verifications
assertThat(applicationPath, nullValue());
}
@@ -98,7 +97,7 @@
// pre-conditions
WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-3_0-with-servlet-mapping.xml", bundle);
// operation
- final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ final String applicationPath = WtpUtils.getApplicationPath(project, APPLICATION.qualifiedName);
// verifications
assertThat(applicationPath, equalTo("/hello/*"));
@@ -109,7 +108,7 @@
// pre-conditions
WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-3_0-without-servlet-mapping.xml", bundle);
// operation
- final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ final String applicationPath = WtpUtils.getApplicationPath(project, APPLICATION.qualifiedName);
// verifications
assertThat(applicationPath, nullValue());
}
@@ -119,7 +118,7 @@
// pre-conditions
WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, null, bundle);
// operation
- final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ final String applicationPath = WtpUtils.getApplicationPath(project, APPLICATION.qualifiedName);
// verifications
assertThat(applicationPath, nullValue());
}
Modified: branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java
===================================================================
--- branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -80,10 +80,10 @@
public void shouldRetrieveAllHttpMethodsInProject() throws CoreException {
// pre-conditions
// operation
- final List<IType> resourceMethods = JaxrsAnnotationsScanner.findHttpMethodTypes(javaProject,
+ final List<IType> httpMethods = JaxrsAnnotationsScanner.findHttpMethodTypes(javaProject,
new NullProgressMonitor());
// verifications
- assertThat(resourceMethods.size(), equalTo(7));
+ assertThat(httpMethods.size(), equalTo(1));
}
@Test
Modified: branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java
===================================================================
--- branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java 2012-09-14 13:36:15 UTC (rev 43696)
+++ branches/jbosstools-3.3.x/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java 2012-09-14 15:23:28 UTC (rev 43697)
@@ -19,21 +19,21 @@
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
+import static org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.getAnnotation;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.CONSUMES;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.ENCODED;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.GET;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.HTTP_METHOD;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH_PARAM;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PRODUCES;
+import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.RESPONSE;
import static org.junit.Assert.assertThat;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Encoded;
-import javax.ws.rs.GET;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Response;
-
import junit.framework.Assert;
import org.eclipse.core.resources.IResource;
@@ -327,7 +327,7 @@
Annotation javaAnnotation = JdtUtils.resolveAnnotation(type, JdtUtils.parse(type, progressMonitor), "Path");
// verifications
assertThat(javaAnnotation.getJavaAnnotation(), notNullValue());
- assertThat(javaAnnotation.getName(), equalTo(Path.class.getName()));
+ assertThat(javaAnnotation.getName(), equalTo(PATH.qualifiedName));
assertThat(javaAnnotation.getJavaAnnotationElements().size(), equalTo(1));
assertThat(javaAnnotation.getJavaAnnotationElements().get("value").get(0), equalTo("/customers"));
assertThat(javaAnnotation.getRegion(), notNullValue());
@@ -341,8 +341,8 @@
Assert.assertNotNull("Type not found", type);
// operation
Map<String, Annotation> javaAnnotations = JdtUtils.resolveAnnotations(type,
- JdtUtils.parse(type, progressMonitor), Path.class.getName(), Consumes.class.getName(),
- Produces.class.getName(), Encoded.class.getName());
+ JdtUtils.parse(type, progressMonitor), PATH.qualifiedName, CONSUMES.qualifiedName,
+ PRODUCES.qualifiedName, ENCODED.qualifiedName);
// verifications
assertThat(javaAnnotations.size(), equalTo(4));
for (Entry<String, Annotation> entry : javaAnnotations.entrySet()) {
@@ -364,7 +364,7 @@
Annotation javaAnnotation = JdtUtils.resolveAnnotation(annotation, JdtUtils.parse(type, progressMonitor));
// verifications
assertThat(javaAnnotation.getJavaAnnotation(), equalTo(annotation));
- assertThat(javaAnnotation.getName(), equalTo(Path.class.getName()));
+ assertThat(javaAnnotation.getName(), equalTo(PATH.qualifiedName));
assertThat(javaAnnotation.getJavaAnnotationElements().size(), equalTo(1));
assertThat(javaAnnotation.getJavaAnnotationElements().get("value").get(0), equalTo("/customers"));
}
@@ -376,8 +376,7 @@
progressMonitor);
Assert.assertNotNull("Type not found", type);
// operation
- Annotation javaAnnotation = JdtUtils.resolveAnnotation(type, JdtUtils.parse(type, progressMonitor),
- HttpMethod.class);
+ Annotation javaAnnotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
// verifications
assertThat(javaAnnotation, nullValue());
}
@@ -385,14 +384,14 @@
@Test
public void shoudResolveBinaryTypeAnnotationFromClassName() throws CoreException {
// pre-conditions
- IType type = JdtUtils.resolveType(GET.class.getName(), javaProject, progressMonitor);
+ IType type = JdtUtils.resolveType(GET.qualifiedName, javaProject, progressMonitor);
Assert.assertNotNull("Type not found", type);
// operation
Annotation javaAnnotation = JdtUtils.resolveAnnotation(type, JdtUtils.parse(type, progressMonitor),
- HttpMethod.class.getName());
+ HTTP_METHOD.qualifiedName);
// verifications
assertThat(javaAnnotation.getJavaAnnotation(), notNullValue());
- assertThat(javaAnnotation.getName(), equalTo(HttpMethod.class.getName()));
+ assertThat(javaAnnotation.getName(), equalTo(HTTP_METHOD.qualifiedName));
assertThat(javaAnnotation.getJavaAnnotationElements().size(), equalTo(1));
assertThat(javaAnnotation.getJavaAnnotationElements().get("value").get(0), equalTo("GET"));
}
@@ -400,17 +399,17 @@
@Test
public void shoudResolveBinaryTypeAnnotationsFromClassNames() throws CoreException {
// pre-conditions
- IType type = JdtUtils.resolveType(GET.class.getName(), javaProject, progressMonitor);
+ IType type = JdtUtils.resolveType(GET.qualifiedName, javaProject, progressMonitor);
Assert.assertNotNull("Type not found", type);
// operation
Map<String, Annotation> javaAnnotations = JdtUtils.resolveAnnotations(type,
- JdtUtils.parse(type, progressMonitor), HttpMethod.class.getName());
+ JdtUtils.parse(type, progressMonitor), HTTP_METHOD.qualifiedName);
// verifications
assertThat(javaAnnotations.size(), equalTo(1));
- Annotation javaAnnotation = javaAnnotations.get(HttpMethod.class.getName());
+ Annotation javaAnnotation = javaAnnotations.get(HTTP_METHOD.qualifiedName);
assertThat(javaAnnotation, notNullValue());
assertThat(javaAnnotation.getJavaAnnotation(), notNullValue());
- assertThat(javaAnnotation.getName(), equalTo(HttpMethod.class.getName()));
+ assertThat(javaAnnotation.getName(), equalTo(HTTP_METHOD.qualifiedName));
assertThat(javaAnnotation.getJavaAnnotationElements().size(), equalTo(1));
assertThat(javaAnnotation.getJavaAnnotationElements().get("value").get(0), equalTo("GET"));
}
@@ -418,15 +417,15 @@
@Test
public void shoudResolveBinaryTypeAnnotationFromElement() throws CoreException {
// pre-conditions
- IType type = JdtUtils.resolveType(GET.class.getName(), javaProject, progressMonitor);
+ IType type = JdtUtils.resolveType(GET.qualifiedName, javaProject, progressMonitor);
Assert.assertNotNull("Type not found", type);
- IAnnotation javaAnnotation = type.getAnnotation(HttpMethod.class.getName());
+ IAnnotation javaAnnotation = type.getAnnotation(HTTP_METHOD.qualifiedName);
Assert.assertTrue("Annotation not found", javaAnnotation.exists());
// operation
Annotation annotation = JdtUtils.resolveAnnotation(javaAnnotation, JdtUtils.parse(type, progressMonitor));
// verifications
assertThat(annotation.getJavaAnnotation(), equalTo(javaAnnotation));
- assertThat(annotation.getName(), equalTo(HttpMethod.class.getName()));
+ assertThat(annotation.getName(), equalTo(HTTP_METHOD.qualifiedName));
assertThat(annotation.getJavaAnnotationElements().size(), equalTo(1));
assertThat(annotation.getJavaAnnotationElements().get("value").get(0), equalTo("GET"));
}
@@ -434,12 +433,12 @@
@Test
public void shoudNotResolveBinaryTypeUnknownAnnotationFromElement() throws CoreException {
// pre-conditions
- IType type = JdtUtils.resolveType(GET.class.getName(), javaProject, progressMonitor);
+ IType type = JdtUtils.resolveType(GET.qualifiedName, javaProject, progressMonitor);
Assert.assertNotNull("Type not found", type);
- IAnnotation javaAnnotation = type.getAnnotation(Path.class.getName());
+ IAnnotation javaAnnotation = type.getAnnotation(PATH.qualifiedName);
Assert.assertFalse("Annotation not expected", javaAnnotation.exists());
// operation
- Annotation annotation = JdtUtils.resolveAnnotation(type, JdtUtils.parse(type, progressMonitor), Path.class);
+ Annotation annotation = getAnnotation(type, PATH.qualifiedName);
// verifications
assertThat(annotation, nullValue());
}
@@ -467,7 +466,7 @@
// verification
Assert.assertNotNull(methodSignature);
Assert.assertEquals(2, methodSignature.getMethodParameters().size());
- Assert.assertNull(methodSignature.getMethodParameters().get(0).getAnnotation(PathParam.class.getName()).getValue("value"));
+ Assert.assertNull(methodSignature.getMethodParameters().get(0).getAnnotation(PATH_PARAM.qualifiedName).getValue("value"));
}
@Test
@@ -520,7 +519,7 @@
@Test
public void shouldNotConfirmSuperType() throws CoreException {
final IType bookType = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
- final IType objectType = getType(Response.class.getName());
+ final IType objectType = getType(RESPONSE.qualifiedName);
assertThat(JdtUtils.isTypeOrSuperType(objectType, bookType), is(false));
}
More information about the jbosstools-commits
mailing list