@Override
  public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
    final Class<?> type = parameterContext.getParameter().getType();
    if (MongoDatabase.class.isAssignableFrom(type)) {
      return getOrCreate(extensionContext).instance.database();
    } else if (MongoClient.class.isAssignableFrom(type)) {
      return getOrCreate(extensionContext).instance.client();
    } else if (MongoInstance.class.isAssignableFrom(type)) {
      return getOrCreate(extensionContext).instance;
    }

    throw new ExtensionConfigurationException(String.format("%s supports only %s or %s but yours was %s", MongoExtension.class.getSimpleName(),
            MongoDatabase.class.getName(), MongoClient.class.getName(), type.getName()));
  }
JUnit5 extension which allows to test repository access backed by a real database (embedded/fake or remote MongoDB). It
is a good habit to run tests on different versions of the database. By default embedded (in memory) java server
is used.

<p>If you want to connect to external mongo database use system property {@code mongo}.
With maven it will look something like this:
<pre>
{@code $ mvn test -DargLine="-Dmongo=mongodb://localhost"}
</pre>

@see <a href="https://github.com/bwaldvogel/mongo-java-server">Mongo Java Server</a>
criteria/mongo/test/org/immutables/criteria/mongo/MongoExtension.java