@Test public void testBeanClassWithMatrixParamField() { final String defaultValue = "1"; /* prepare project */ importWSTestProject(PROJECT3_NAME); /* there is no error */ assertCountOfValidationProblemsExists(ProblemType.ERROR, PROJECT3_NAME, null, null, 0); /* get RESTful services from JAX-RS REST explorer for the project */ List<RESTfulWebService> restServices = restfulServicesForProject(PROJECT3_NAME); /* test JAX-RS REST explorer */ assertCountOfRESTServices(restServices, 1); assertExpectedPathOfService( restServices.get(0), "/rest;" + matrixParam1 + "={" + matrixType1 + "}"); new WaitWhile(new JobIsRunning(), TimePeriod.LONG); /* open BeanClass class */ openBeanClass(PROJECT3_NAME); ExtendedTextEditor editor = new ExtendedTextEditor(); /* remove @MatrixParam from BeanClass and assert that endpoint URI was updated */ editor.removeLine("@MatrixParam"); // Wait a bit till its shown in explorer AbstractWait.sleep(TimePeriod.SHORT); restServices = restfulServicesForProject(PROJECT3_NAME); assertExpectedPathOfService("unstable ", restServices.get(0), "/rest"); /* add @MatrixParam and @DefaultValue into BeanClass and assert that endpoint URI was updated */ editor.insertBeforeLine("@MatrixParam(\"" + matrixParam1 + "\")", matrixType1); editor.insertBeforeLine("import javax.ws.rs.DefaultValue;", "import javax.ws.rs.MatrixParam;"); editor.insertBeforeLine("@DefaultValue(\"" + defaultValue + "\")", matrixType1); AbstractWait.sleep(TimePeriod.SHORT); restServices = restfulServicesForProject(PROJECT3_NAME); assertExpectedPathOfService( restServices.get(0), "/rest;" + matrixParam1 + "={" + matrixType1 + ":\"" + defaultValue + "\"}"); // unstable }
@Test public void testBeanClassWithPathParamField() { final String pathAnnotation = "@Path(\"{" + pathParam1 + "}\")"; final String pathParameterNotBoundToAnyFieldWarning = "The @Path template parameter 'id' is not bound to any field, property or method parameter annotated with @PathParam(\"id\")."; final String pathParamNotBoundToPathParameterError = "@PathParam value 'id' does not match any @Path annotation template parameters in 'org.rest.test.RestService'."; final String pathParameterNotBoundToPathParamError = "@PathParam value 'id' in associated Parameter Aggregator 'org.rest.test.BeanClass' does not match any @Path annotation template parameters of the java method 'post' and its enclosing java type 'org.rest.test.RestService'."; /* prepare project */ importWSTestProject(PROJECT1_NAME); /* there is no error */ assertCountOfProblemsExists(ProblemType.ERROR, PROJECT1_NAME, null, null, 0); assertCountOfValidationProblemsExists( ProblemType.WARNING, PROJECT1_NAME, pathParameterNotBoundToAnyFieldWarning, null, 0); /* get RESTful services from JAX-RS REST explorer for the project */ List<RESTfulWebService> restServices = restfulServicesForProject(PROJECT1_NAME); /* test JAX-RS REST explorer */ assertCountOfRESTServices(restServices, 1); assertExpectedPathOfService( restServices.get(0), "/rest/{" + pathParam1 + ":" + pathType1 + "}"); /* open RestService class */ openJavaFile(PROJECT1_NAME, "org.rest.test", "RestService.java"); ExtendedTextEditor editor = new ExtendedTextEditor(); /* remove @Path annotation from RestService and assert there are two errors (one in RestService and one in BeanClass */ editor.removeLine(pathAnnotation); assertCountOfProblemsExists( ProblemType.ERROR, PROJECT1_NAME, pathParamNotBoundToPathParameterError, null, 1); assertCountOfProblemsExists( ProblemType.ERROR, PROJECT1_NAME, pathParameterNotBoundToPathParamError, null, 1); assertCountOfProblemsExists(ProblemType.ERROR, PROJECT1_NAME, null, null, 2); /* add @Path annotation into RestService and assert that errors disappear */ editor.insertBeforeLine(pathAnnotation, "public void post("); assertCountOfValidationProblemsExists(ProblemType.ERROR, PROJECT1_NAME, null, null, 0); /* open BeanClass class */ openBeanClass(PROJECT1_NAME); editor = new ExtendedTextEditor(); /* remove @PathParam from BeanClass and assert that there is an warning */ editor.removeLine("@PathParam"); assertCountOfValidationProblemsExists( ProblemType.WARNING, PROJECT1_NAME, pathParameterNotBoundToAnyFieldWarning, null, 1); }