Index: .classpath =================================================================== --- .classpath (revision 42677) +++ .classpath (working copy) @@ -1,7 +1,7 @@ - + Index: src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java (working copy) @@ -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> elements = new HashMap>(); elements.put("value", Arrays.asList(values)); Index: src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtilsTestCase.java (working copy) @@ -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.getSourceRange(), notNullValue()); @@ -341,8 +341,8 @@ Assert.assertNotNull("Type not found", type); // operation Map 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 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 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)); } Index: src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java (working copy) @@ -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()); } Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java (working copy) @@ -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 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 validationMessages = customerResource.validate(); Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java (working copy) @@ -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; @@ -52,6 +51,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 +80,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 +88,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 +102,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,9 +115,9 @@ 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(EnumJaxrsElements element) throws JavaModelException, CoreException { + final IType type = getType(element.qualifiedName, javaProject); + final Annotation httpAnnotation = getAnnotation(type, HTTP_METHOD.qualifiedName); final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, httpAnnotation, metamodel); metamodel.add(httpMethod); return httpMethod; @@ -145,14 +148,14 @@ @Test public void shouldConstructSimpleEndpoint() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +169,12 @@ @Test public void shouldConstructEndpointFromSubresource() throws CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +189,10 @@ @Test public void shouldConstructEndpointWithQueryParams() throws CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +203,10 @@ @Test public void shoudCreateEndpointWhenAddingResourceMethodInRootResource() throws CoreException { // pre-conditions - createHttpMethod(GET.class); + createHttpMethod(GET); 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 changes = processEvent(event, progressMonitor); @@ -215,10 +218,10 @@ @Test public void shoudCreateEndpointWhenAddingSubresourceMethodInRootResource() throws JavaModelException, CoreException { // pre-conditions - createHttpMethod(GET.class); + createHttpMethod(GET); 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 changes = processEvent(event, progressMonitor); @@ -231,12 +234,12 @@ public void shoudCreateEndpointWhenAddingSubresourceLocatorMethodInRootResource() throws JavaModelException, CoreException { // pre-conditions - createHttpMethod(GET.class); + createHttpMethod(GET); 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 +257,11 @@ @Test public void shoudCreateEndpointWhenAddingResourceMethodInSubresource() throws JavaModelException, CoreException { // pre-conditions - createHttpMethod(GET.class); + createHttpMethod(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("getAllProducts", bookResource, GET.class); + final JaxrsResourceMethod bookResourceMethod = createResourceMethod("getAllProducts", bookResource, GET); // operation final JaxrsElementDelta event = new JaxrsElementDelta(bookResourceMethod, ADDED); final List changes = processEvent(event, progressMonitor); @@ -271,13 +274,13 @@ public void shoudCreateEndpointWhenChangingSubresourceLocatorMethodIntoSubresourceMethod() throws JavaModelException, CoreException { // pre-conditions - createHttpMethod(GET.class); + createHttpMethod(GET); 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 changes = processEvent(event, progressMonitor); @@ -290,11 +293,11 @@ @Test public void shoudCreateEndpointWhenAddingSubresourceMethodInSubresource() throws JavaModelException, CoreException { // pre-conditions - createHttpMethod(GET.class); + createHttpMethod(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); // operation final JaxrsElementDelta event = new JaxrsElementDelta(bookResourceMethod, ADDED); final List changes = processEvent(event, progressMonitor); @@ -312,10 +315,10 @@ public void shoudChangeUriPathTemplateWhenAddingApplication() throws JavaModelException, CoreException { // the subresource becomes a root resource ! // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +336,10 @@ public void shoudChangeUriPathTemplateWhenAddingResourcePathAnnotation() throws JavaModelException, CoreException { // the subresource becomes a root resource ! // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +355,11 @@ @Test public void shoudChangeUriPathTemplateWhenAddingMethodPathAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +381,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 = createHttpMethod(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 changes = processEvent(event, progressMonitor); @@ -401,14 +404,14 @@ @Test public void shoudChangeUriPathTemplateWhenChangingResourcePathAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); @@ -424,14 +427,14 @@ @Test public void shoudChangeUriPathTemplateWhenChangingMethodPathAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); @@ -448,7 +451,7 @@ public void shoudChangeUriPathTemplateWhenRemovingResourcePathAnnotationAndMatchingSubresourceLocatorFound() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +459,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 changes = processEvent(event, progressMonitor); @@ -477,15 +480,15 @@ @Test public void shoudChangeHttpVerbWhenChangingHttpMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 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 changes = processEvent(event, progressMonitor); // verifications @@ -499,10 +502,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 = createHttpMethod(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 +524,14 @@ @Test public void shoudChangeUriPathTemplateWhenRemovingMethodPathAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); @@ -544,15 +547,15 @@ @Test public void shoudChangeConsumedMediatypesWhenAddingResourceAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); // verifications @@ -567,15 +570,15 @@ public void shoudChangeConsumedMediatypesWhenAddingResourceMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); // verifications @@ -590,18 +593,18 @@ public void shoudChangeConsumedMediatypesWhenChangingResourceMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); // verifications @@ -615,18 +618,18 @@ @Test public void shoudChangeConsumedMediatypesWhenChangingResourceAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); // verifications @@ -641,13 +644,13 @@ public void shoudChangeConsumedMediatypesWhenRemovingMethodAnnotationWithResourceDefault() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +671,11 @@ public void shoudChangeConsumedMediatypesWhenRemovingMethodAnnotationWithoutResourceDefault() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +695,15 @@ @Test public void shoudChangeProducedMediatypesWhenAddingResourceAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); // verifications @@ -715,15 +718,15 @@ public void shoudChangeProducedMediatypesWhenAddingResourceMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); // verifications @@ -737,18 +740,18 @@ @Test public void shoudChangeProducedMediatypesWhenChangingResourceAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); // verifications @@ -763,18 +766,18 @@ public void shoudChangeProducedMediatypesWhenChangingResourceMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); // verifications @@ -789,13 +792,13 @@ public void shoudChangeProducedMediatypesWhenRemovingMethodAnnotationWithResourceDefault() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +819,11 @@ public void shoudChangeProducedMediatypesWhenRemovingMethodAnnotationWithoutResourceDefault() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +843,10 @@ @Test public void shoudRemoveEndpointWhenRemovingHttpMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 @@ -860,15 +863,15 @@ public void shoudRemoveEndpointWhenRemovingResourcePathAnnotationAndMatchingSubresourceLocatorNotFound() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); @@ -882,13 +885,13 @@ @Test public void shoudRemoveEndpointsWhenRemovingRootResource() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +907,16 @@ @Test public void shoudRemoveEndpointsWhenRemovingSubresource() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + JaxrsHttpMethod httpMethod = createHttpMethod(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 +930,15 @@ @Test public void shoudRemoveEndpointsWhenRemovingHttpMethod() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + JaxrsHttpMethod httpMethod = createHttpMethod(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 +954,18 @@ @Test public void shoudAddEndpointsWhenChangingSubresourceLocatorReturnType() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + JaxrsHttpMethod httpMethod = createHttpMethod(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 +984,16 @@ @Test public void shoudRemoveEndpointsWhenChangingSubresourceLocatorReturnType() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + JaxrsHttpMethod httpMethod = createHttpMethod(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 +1014,15 @@ @Test public void shoudRemoveEndpointsWhenRemovingSubresourceLocatorResource() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + JaxrsHttpMethod httpMethod = createHttpMethod(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 +1038,10 @@ @Test public void shoudRemoveEndpointWhenRemovingResourceMethodInRootResource() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 +1057,13 @@ public void shoudRemoveEndpointWhenRemovingSubresourceMethodInRootResource() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + final JaxrsHttpMethod httpMethod = createHttpMethod(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 changes = processEvent(event, progressMonitor); @@ -1074,15 +1077,15 @@ @Test public void shoudRemoveEndpointWhenRemovingSubresourceLocatorMethod() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + JaxrsHttpMethod httpMethod = createHttpMethod(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 +1102,18 @@ public void shoudRemoveEndpointWhenSubresourceLocatorRootResourceBecomesSubresource() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET.class); + JaxrsHttpMethod httpMethod = createHttpMethod(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 Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java (working copy) @@ -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; } @@ -182,10 +182,10 @@ @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)); + metamodel.add(createHttpMethod(GET)); + metamodel.add(createHttpMethod(POST)); + metamodel.add(createHttpMethod(PUT)); + metamodel.add(createHttpMethod(DELETE)); // operation final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java", progressMonitor); @@ -207,10 +207,10 @@ 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)); + metamodel.add(createHttpMethod(GET)); + metamodel.add(createHttpMethod(POST)); + metamodel.add(createHttpMethod(PUT)); + metamodel.add(createHttpMethod(DELETE)); // operation final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java", progressMonitor); @@ -296,7 +296,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 affectedElements = processResourceChanges(event, progressMonitor); @@ -333,7 +333,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 +371,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 @@ -580,7 +580,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 @@ -598,7 +598,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 affectedElements = processResourceChanges(event, progressMonitor); @@ -635,7 +635,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 +655,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 +674,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 +694,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 +713,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 +732,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 +751,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 +773,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 +794,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 +825,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 +851,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 +872,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 +901,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 +928,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 +951,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 +972,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 +997,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 +1020,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 Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java (working copy) @@ -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 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 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 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 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 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 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 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 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 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 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 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 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 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 * 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 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 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 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 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 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 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 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(), 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) Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java (working copy) @@ -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()); } Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java (working copy) @@ -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,23 +51,11 @@ 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); @@ -83,7 +70,7 @@ @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 +80,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 +90,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 +104,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 +114,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 +132,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 +150,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 Index: src/org/jboss/tools/ws/jaxrs/ui/contentassist/PathParamAnnotationValueCompletionProposalComputer.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/ui/contentassist/PathParamAnnotationValueCompletionProposalComputer.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/ui/contentassist/PathParamAnnotationValueCompletionProposalComputer.java (working copy) @@ -11,12 +11,12 @@ package org.jboss.tools.ws.jaxrs.ui.contentassist; +import static org.jboss.tools.ws.jaxrs.core.jdt.EnumJaxrsElements.PATH_PARAM; + import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javax.ws.rs.PathParam; - import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.core.IJavaElement; @@ -87,7 +87,7 @@ for (JavaMethodParameter methodParameter : resourceMethod.getJavaMethodParameters()) { for (Annotation annotation : methodParameter.getAnnotations()) { final ISourceRange range = annotation.getSourceRange(); - if (annotation.getName().equals(PathParam.class.getName()) && range != null + if (annotation.getName().equals(PATH_PARAM.qualifiedName) && range != null && context.getInvocationOffset() >= range.getOffset() && context.getInvocationOffset() < (range.getOffset() + range.getLength())) { // completion proposal on @PathParam method Index: src/org/jboss/tools/ws/jaxrs/ui/cnf/action/OpenInWSTesterActionProvider.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/ui/cnf/action/OpenInWSTesterActionProvider.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/ui/cnf/action/OpenInWSTesterActionProvider.java (working copy) @@ -19,7 +19,6 @@ import org.eclipse.ui.navigator.ICommonMenuConstants; import org.eclipse.ui.navigator.ICommonViewerSite; import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite; -import org.jboss.tools.ws.jaxrs.ui.internal.launcher.WSTesterClientDelegate; import org.jboss.tools.ws.jaxrs.ui.internal.launcher.WSTesterLaunchableAdapterDelegate; /** Index: build.properties =================================================================== --- build.properties (revision 42677) +++ build.properties (working copy) @@ -3,7 +3,6 @@ bin.includes = META-INF/,\ plugin.xml,\ plugin.properties,\ - lib/jaxrs-api.jar,\ . jars.compile.order = .,\ lib/jaxrs-api.jar Index: .classpath =================================================================== --- .classpath (revision 42677) +++ .classpath (working copy) @@ -1,6 +1,5 @@ - Index: src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/jdt/JdtUtils.java (working copy) @@ -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; } } Index: src/org/jboss/tools/ws/jaxrs/core/jdt/EnumJaxrsElements.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/jdt/EnumJaxrsElements.java (revision 0) +++ src/org/jboss/tools/ws/jaxrs/core/jdt/EnumJaxrsElements.java (revision 0) @@ -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; + } + +} Index: src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java (working copy) @@ -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); } /** @@ -145,7 +145,7 @@ } 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 searchForAnnotatedTypes(final Class annotation, final IJavaSearchScope searchScope, + private static List 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,7 +193,7 @@ IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { scope }, IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS); List annotations = new ArrayList(httpMethods.size() + 1); - annotations.add(Path.class.getName()); + annotations.add(PATH.qualifiedName); for (IJaxrsHttpMethod httpMethod : httpMethods) { annotations.add(httpMethod.getJavaElement().getFullyQualifiedName()); } Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java (working copy) @@ -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 { Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java (working copy) @@ -84,6 +84,7 @@ return metamodelDelta; } + @SuppressWarnings("incomplete-switch") private List 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 processAddition(final JaxrsResourceMethod resourceMethod) throws CoreException { final List changes = new ArrayList(); final JaxrsMetamodel metamodel = (JaxrsMetamodel) resourceMethod.getMetamodel(); @@ -236,6 +238,7 @@ } // FIXME: support chain of subresource locators + @SuppressWarnings("incomplete-switch") private List processSubresourceLocatorAddition(final JaxrsResourceMethod subresourceLocator, final JaxrsMetamodel metamodel) throws CoreException { final List changes = new ArrayList(); Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java (working copy) @@ -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,8 +25,6 @@ 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; @@ -200,7 +199,7 @@ private List 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) { Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java (working copy) @@ -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 processAddition(final IAnnotation javaAnnotation, final CompilationUnit ast, final JaxrsMetamodel metamodel, final IProgressMonitor progressMonitor) throws CoreException { final List changes = new ArrayList(); @@ -341,6 +341,7 @@ * @throws CoreException */ // FIXME : same code as method processAddition(annotation, etc..) ?!? + @SuppressWarnings("incomplete-switch") private List processChange(final IAnnotation javaAnnotation, final CompilationUnit ast, final JaxrsMetamodel metamodel, final IProgressMonitor progressMonitor) throws CoreException { final List changes = new ArrayList(); Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java (working copy) @@ -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 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 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 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 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")); } Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java (working copy) @@ -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 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 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; } Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java (working copy) @@ -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; @@ -145,7 +144,7 @@ /** @return the httpVerbAnnotation */ @Override public Annotation getHttpMethodAnnotation() { - return getAnnotation(HttpMethod.class.getName()); + return getAnnotation(HTTP_METHOD.qualifiedName); } /* @@ -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; Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java (working copy) @@ -19,15 +19,9 @@ 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; @@ -242,8 +236,7 @@ private List validateParamsWithContextAnnotation() throws JavaModelException { final List messages = new ArrayList(); 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)) { @@ -274,7 +267,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; @@ -305,7 +298,7 @@ final List 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) { @@ -399,7 +392,7 @@ } public Annotation getPathAnnotation() { - return getAnnotation(Path.class.getName()); + return getAnnotation(PATH.qualifiedName); } @Override @@ -438,7 +431,7 @@ } public Annotation getConsumesAnnotation() { - return getAnnotation(Consumes.class.getName()); + return getAnnotation(CONSUMES.qualifiedName); } @Override @@ -451,7 +444,7 @@ } public Annotation getProducesAnnotation() { - return getAnnotation(Produces.class.getName()); + return getAnnotation(PRODUCES.qualifiedName); } @Override Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceField.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceField.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceField.java (working copy) @@ -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 Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java (working copy) @@ -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 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 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; @@ -216,11 +216,11 @@ httpMethodAnnotationNames.add(httpMethod.getJavaElement().getFullyQualifiedName()); } final List annotationNames = new ArrayList(); - 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 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 supportedFieldAnnotations = Arrays.asList(MatrixParam.class.getName(), - QueryParam.class.getName(), PathParam.class.getName(), CookieParam.class.getName(), - HeaderParam.class.getName(), DefaultValue.class.getName()); + final List supportedFieldAnnotations = Arrays.asList(MATRIX_PARAM.qualifiedName, + QUERY_PARAM.qualifiedName, PATH_PARAM.qualifiedName, COOKIE_PARAM.qualifiedName, + HEADER_PARAM.qualifiedName, DEFAULT_VALUE.qualifiedName); final Map 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( annotations.values()), parentResource, metamodel); return field; Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java (working copy) @@ -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,23 +159,23 @@ 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()) { @@ -207,21 +206,21 @@ 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()) { Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java (working copy) @@ -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; Index: META-INF/MANIFEST.MF =================================================================== --- META-INF/MANIFEST.MF (revision 42677) +++ META-INF/MANIFEST.MF (working copy) @@ -30,10 +30,7 @@ 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", @@ -41,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: . Index: lib/jaxrs-api.jar =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream