@Test public void shouldCreateParameterAggregatorFromTypeWithAnnotatedField() throws CoreException { // pre-conditions metamodelMonitor.createCompilationUnit( "ParameterAggregator.txt", "org.jboss.tools.ws.jaxrs.sample.services", "ParameterAggregator.java"); final IType parameterAggregatorType = metamodelMonitor.resolveType( "org.jboss.tools.ws.jaxrs.sample.services.ParameterAggregator"); assertThat(parameterAggregatorType, notNullValue()); replaceAllOccurrencesOfCode( parameterAggregatorType, "// PLACEHOLDER", "@PathParam(\"id2\") public String id2;", false); // operation final List<IJaxrsElement> elements = JaxrsElementFactory.createElements( parameterAggregatorType, JdtUtils.parse(parameterAggregatorType, new NullProgressMonitor()), metamodel, new NullProgressMonitor()); // verification: parameter aggregator with child method created assertThat(elements.size(), equalTo(2)); assertThat( elements.iterator().next().getElementKind(), equalTo(EnumElementKind.PARAMETER_AGGREGATOR)); assertThat( elements.get(1).getElementKind(), equalTo(EnumElementKind.PARAMETER_AGGREGATOR_FIELD)); }
@Test public void shouldNotCreateParameterAggregatorFromTypeWithUnannotatedMethod() throws CoreException { // pre-conditions metamodelMonitor.createCompilationUnit( "ParameterAggregator.txt", "org.jboss.tools.ws.jaxrs.sample.services", "ParameterAggregator.java"); final IType parameterAggregatorType = metamodelMonitor.resolveType( "org.jboss.tools.ws.jaxrs.sample.services.ParameterAggregator"); assertThat(parameterAggregatorType, notNullValue()); replaceAllOccurrencesOfCode( parameterAggregatorType, "// PLACEHOLDER", "public void setId2(String id2) {}", false); // operation final List<IJaxrsElement> elements = JaxrsElementFactory.createElements( parameterAggregatorType, JdtUtils.parse(parameterAggregatorType, new NullProgressMonitor()), metamodel, new NullProgressMonitor()); // verification: parameter aggregator with child method created assertThat(elements.size(), equalTo(0)); }