Test overview
mvn test # everything, except the known security gaps
mvn test -Dtest=ClassName # one class
mvn test -Dtest=ClassName#method # one method
mvn test -Dgroups=security # only the security suite
Integration tests need a running Docker daemon. No other setup is needed: no environment variables or running
infrastructure.
Test types
flowchart TB
security["<b>Security suite</b><br/>complete application, real PostgreSQL,<br/>local OIDC server, requests through the API"]
integration["<b>Integration tests</b><br/>services with a real PostgreSQL or Neo4j<br/>(Testcontainers)"]
unit["<b>Unit tests</b><br/>models, formats and logic,<br/>collaborators mocked"]
security --> integration --> unit
| Type |
How to recognize it |
Uses |
| Unit |
No container or Spring context |
JUnit 5, Mockito |
| Integration |
Extends a *IntegrationTestSupport or declares a container |
Testcontainers: postgres:17, Neo4j |
| Security |
Package security, tag security |
See Security test suite |
How integration tests work
Integration tests run against real databases, so that SQL, triggers and migrations are actually covered. The test
classes share one PostgreSQL container, held in a static field and started once for the whole JVM, rather than using
JUnit's @Container lifecycle: InstanceServiceIntegrationTestSupport explains why. Shared fixtures live in the
support classes.
classDiagram
class InstanceServiceIntegrationTestSupport {
<<abstract>>
POSTGRES container
entity fixtures
}
class InvitationServiceIntegrationTestSupport {
<<abstract>>
}
class SecurityTestSupport {
<<abstract>>
POSTGRES container
IDENTITY_PROVIDER
getAs(persona, path)
}
InstanceServiceIntegrationTestSupport <|-- InstanceServiceListInstancesTest
InstanceServiceIntegrationTestSupport <|-- InstanceServiceReleaseInstanceTest
InstanceServiceIntegrationTestSupport <|-- InstanceServiceValidationTest
InvitationServiceIntegrationTestSupport <|-- InvitationServiceTest
InvitationServiceIntegrationTestSupport <|-- PendingInvitationServiceTest
SecurityTestSupport <|-- ReadVisibilityTest
SecurityTestSupport <|-- EndpointAuthorizationTest
Test map
Paths are relative to src/test/java/org/marmotgraph/core. IT marks tests that need Docker.
| Test |
Verifies |
models/TypeInformationFormatTest |
Plain-key JSON of the v4 type information |
v3/models/InstanceFormatV3Test |
Conversion of instances to the v3 format |
v3/models/PropertySpecificationV3Test |
v3 property specifications |
v3/models/QuerySpecificationV3Test |
Translation between JSON-LD queries and the typed format |
v3/models/ScopeElementV3Test |
The v3 scope format |
v3/models/SpaceFormatV3Test |
v3 space information |
v3/unresolved/InstancesV3ListInstancesBindingTest |
Binding of the v3 listing parameters |
v4/unresolved/InstancesV4ListInstancesBindingTest |
Binding of the v4 listing parameters, including repeated values |
Models (auth/models, common)
| Test |
Verifies |
auth/models/UserWithRolesTest |
Roles to permissions, including the private space |
auth/models/QuerySpecificationTest |
Parsing of the query specification |
common/model/query/QuerySpecificationTest |
Empty traversals in query results |
common/jsonld/NormalizedJsonLdTest |
Normalized documents |
common/model/scope/ScopeSpecificationTest |
Parsing of scope specifications |
Graph (graph)
| Test |
IT |
Verifies |
nograph/NoGraphIntegrationTest |
✓ |
Query semantics on PostgreSQL, embedded objects, type filters, nested access restrictions |
neo4j/internal/Neo4JInternalUpsertTest |
✓ |
The upsert of an instance against a real Neo4j |
neo4j/internal/Neo4JReindexInternalTest |
✓ |
The generated Cypher of the bulk reindex |
neo4j/PayloadSplitterTest |
|
Currently @Disabled |
neo4j/DynamicNeo4jServiceTest |
|
Currently @Disabled |
vocabulary/GraphVocabularyTest |
✓ |
Prefix generation and registration |
Persistence (persistence)
| Test |
IT |
Verifies |
StoredQueryRepositoryIntegrationTest |
✓ |
The listing and search of stored queries |
converters/PayloadCompressorTest |
|
Compression of payloads |
converters/PropertySpecificationCompressorTest |
|
Compression of property specifications |
converters/ValidationSchemaCompressorTest |
|
Compression of validation schemas |
Services: instances (services/instances)
| Test |
IT |
Verifies |
InstanceServiceContributionsTest |
✓ |
Contributions by several users |
internal/InstanceProcessorInternalReconcileTest |
|
Reconciliation of contributions |
InstanceServiceListInstancesTest |
✓ |
Listing, filters and sorting with the real criteria queries |
InstanceRepositoryPaginationTest |
✓ |
Marker pagination |
InstanceServiceGetInstancesByIdentifiersTest |
✓ |
Lookup by identifier |
InstanceServiceOutgoingLinksTest |
✓ |
Summaries of outgoing links |
InstanceServiceGetIncomingLinksTest |
✓ |
Incoming links as a page (v3) |
InstanceServiceGetGroupedIncomingLinksTest |
✓ |
Grouped incoming links (v4) |
InstanceServiceReleaseInstanceTest |
✓ |
Identifiers, relations and occurrences of the released stage |
InstanceServiceMoveInstanceTest |
✓ |
Moving between spaces |
InstanceServiceRemoveInstanceTest |
✓ |
Deleting, forceUnrelease |
InstanceServiceTimestampsAndContributorsTest |
✓ |
Timestamps and contributors |
InstanceServiceFavoritesTest |
✓ |
Favorites |
InstanceServiceValidationTest |
✓ |
Validation on write and dry runs |
InstanceServiceGraphEventsTest |
✓ |
Events are published for each mutation |
InstanceServiceGraphIndexingTest |
✓ |
Mutations reach the graph |
Services: other (services)
| Test |
IT |
Verifies |
authorization/PermissionServiceTest |
|
Permission logic |
authorization/AuthContextTest |
|
Authentication context |
authorization/ClaimPatternsTest |
|
Matching and validation of claim patterns |
comment/CommentServiceTest |
✓ |
Comments and their permissions |
graph/GraphIndexingListenerTest |
|
Forwarding events to the graph |
graph/ReindexLockTest |
|
Locking between reindexing and manipulations |
graph/ManipulationThrottleTest |
|
Throttling of writes |
graph/internal/GraphSourceInternalTest |
✓ |
Reading instances for the graph |
invitation/InvitationServiceTest |
✓ |
Invitations for known users |
invitation/PendingInvitationServiceTest |
✓ |
Invitation links |
queries/QueryServiceTest |
|
Query service logic |
queries/QueryServiceNeo4jIntegrationTest |
✓ |
Query semantics in Cypher against a real Neo4j |
scope/ScopeServiceTest |
✓ |
Scope definitions and evaluation |
structure/SpacesServiceTest |
|
Spaces |
structure/SpacesServiceSpaceNamesCacheTest |
|
Cache of space names |
structure/SpaceSpecificationIntegrationTest |
✓ |
Specifying and removing spaces |
structure/IncomingLinkSummaryIntegrationTest |
✓ |
Trigger-maintained summary tables |
structure/StatisticsServiceIntegrationTest |
✓ |
Key figures |
structure/UnusedTypeRemovalIntegrationTest |
✓ |
Removal of types which are neither specified nor in use |
validation/ValidationSchemaServiceTest |
|
Schema management and validation |
validation/ComplianceScoreTest |
|
Compliance score |
Test resources (src/test/resources)
| Directory |
Purpose |
invalidPayloads |
Payloads that have to be rejected |
normalizablePayloads |
Payloads that are normalized and then accepted |
query |
Query specifications |
validation |
Schema files |
Writing tests
- Put tests into the package of the class under test, in a class named
<Class>Test.
- Test logic that relies on SQL, triggers or migrations against a real database, using a support class.
- Permissions of new endpoints belong to the security suite.