Resolve Type Definitions in RtService in Unit Tests

I try to create an IDocumentRtService with dynamic configuration as described here: Documentation | GetA12
And bring it to use in Unit Tests with a TestDocumentModelResolver similar to the Examples found in here: Documentation | GetA12

The model of the document I want to compute imports another model with custom type definitions, resulting in the computation throwing an error, because it cannot resolve the type definition:

Typedefinition with id ‘typedef_01cbbaf3-693d-4a05-bd33-d82aefb418cd’ could not be found.

Even though the imported model can be resolved by the TestDocumentModelResolver (which is not attempted by RtService).
Can you maybe offer a clue on how to solve this?

Hi @tobias-gentle-alder,
do you call IDocumentModelService#expand for the DMs which are involved in your test? For that you will have to implement the interface IDocumentModelReferenceResolver which is similar to TestDocumentModelResolver, please be aware of the following difference:

  • IDocumentModelReferenceResolver#getDocumentModel → the returned DMs must not be expanded.
  • IDocumentModelResolver#getDocumentModelById → the returned DMs must be expanded.

I implemented, as you said. Now the Model is expanded, but I am still getting an exception:

Custom field type ‘Steuernummer’ missing.
com.mgmtp.a12.kernel.core.rt.a12internal.ValidatorException: Custom field type ‘Steuernummer’ missing.
at app//com.mgmtp.a12.kernel.core.rt._30_1.internal.formatdef.FormatDefinitionVordefiniert.getCustomFieldType(FormatDefinitionVordefiniert.java:145)

The expanded Model contains an Optional with the respective TypeDefinition

Hi @tobias-gentle-alder,

I assume that the models used in production also contain custom field types and that your project already followed these instructions. For your tests, you will have to do the same. Since you are using Steuernummer, please be also aware of this special case. Note: the latter link goes to an older A12 version since this part of the documentation is not available in newer A12 versions anymore, but the process should still work for 2025.06, if you get an error because of missing dependencies related to custom field types, you will have to add the dependency to kernel-core-customfieldtype-impl.