title: Reuse Junit asserts in different classes
body: <p>I have some tests that made asserts in JsonObject that are returned for different endpoints, like this:</p>
  
  <pre><code>JsonElement product = asJsonObject.get("product");
  JsonElement type = product.getAsJsonObject().get("type");
  Assert.assertEquals(ProductType.PRODUCT_1.name(), type.getAsString());
  JsonElement name = product.getAsJsonObject().get("name");
  Assert.assertEquals("name", name.getAsString());
  </code></pre>
  
  <p>This a lot of Java code, right? There are more than one endpoint that return the same Json and a I need to do the same assert to guarantee the expected result.</p>
  
  <p>But I'm trying to find a way to reuse this code above. Obviously,I can do something like this:</p>
  
  <pre><code>new AssertProduct(asJsonObject.get("product")).assert(type, name);
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>class AssertProduct {
  
      private JsonElement product;
  
      AssertProduct(JsonElement product) {
          this.product = product;
      {
  
      boolean assert(String name, String type) {
          JsonElement type = product.getAsJsonObject().get("type");
          Assert.assertEquals(type, type.getAsString());
          JsonElement name = product.getAsJsonObject().get("name");
          Assert.assertEquals(name, name.getAsString());
      }
  
  }
  </code></pre>
  
  <p>But... this is a good approach for this kind of problem?</p>