Package io.ebean.test

Class DbJson.PrettyJson

java.lang.Object
io.ebean.test.DbJson.PrettyJson
Enclosing class:
DbJson

public static class DbJson.PrettyJson extends Object
Contains the JSON of beans(s).
  • Method Details

    • withPlaceholder

      public DbJson.PrettyJson withPlaceholder(String placeHolder)
      Set the placeHolder to use when replacing property values.
    • replace

      public DbJson.PrettyJson replace(String... propertyNames)
      Replace the values of the given properties with a placeholder value.

      Typically we do this on generated properties such as id and timestamp properties.

    • asJson

      public String asJson()
      Return the JSON content.
    • assertContentMatches

      public void assertContentMatches(String resourcePath)
      Assert the json exactly matches the content at the given resource path.
      
      
          DbJson.of(timedEntries)
            .replace("id", "eventTime")
            .assertContentMatches("/assertJson/full-1-timed.json");
      
       
    • assertContains

      public void assertContains(String json)
      Assert the DB json contains the given json content.

      With this "contains" check the DB Json can contain more content than what it is checked against. Typically the DB json can contain generated properties like id values, when created, when modified etc and we leave these out of the json content we are checking against.

      Parameters:
      json - The subset json content that should be contained by the DB json.
    • assertContainsResource

      public void assertContainsResource(String resourcePath)
      Assert the DB Json contains the Json at the given resource path.

      With this "contains" check the DB Json can contain more content than what it is checked against. Typically the DB json can contain generated properties like id values, when created, when modified etc and we leave these out of the json content we are checking against.

      Parameters:
      resourcePath - The resource path of the JSON content we are checking against.