title: How to include annotations in a class method for static import
body: <p>I would like to create a class of methods for junit and restassured tests that can be statically imported to other classes when they are needed instead of having duplicate code. But I'm having trouble getting this design to work. I'm fairly new to Java, Rest-assured and junit.
  For example:</p>
  
  <p>In file CommonCode.java:</p>
  
  <pre><code>package com.mypackage;
  //imports excluded for brevity
  String input = "string";
  String path = "number";
  String expected = "1";
  
  public class CommonCode {
  
     @DisplayName("Checking number")
     @ParameterizedTest(name="{index} =&gt; input={0},path={1},expected={2}")
     @CsvSource(value = {input+","+path+","+expected})
     public static void test1(String input, String path, int expected) {
        given().queryParam("?", input)
                .when().get()
                .then().body(path,greaterThan(expected))
                .statusCode(200);
     }
  }
  </code></pre>
  
  <p>My question is: how can I have tests like these, with junit annotations and the like, inside a method in a class to be called and used by other classes? I've tried static import but this doesn't work especially with the annotations. If I put the above code inside a method, the annotations and rest-assured methods go out of scope. I'm open to the idea of another design if this one is fundamentally flawed.</p>
  
  <p>Appreciate any help and/or advice.</p>