What is Garland?#
Garland is a Java library for writing integration tests as type-safe pipelines.
Each step transforms and passes data to the next. The compiler enforces the chain —
if a step returns the wrong type, the build fails.
UserDto expected = TestUsers.defaultUser();
Pipeline.given(TestUserRequests.createUser(expected))
.then(httpClient.makeCall(201, UserDto.class))
.then(Verify.matching(expected))
.then(Verify.allOf(
UserMapper.toEntity().andThen(postgresClient.findByFields()),
UserMapper.toEvent().andThen(kafkaClient.consumeMatching(UserCreatedEvent.class)),
UserMapper.toDoc().andThen(mongoClient.findByFields())
))
.execute();
One pipeline. One test. HTTP response, Postgres, Kafka, and MongoDB — all verified.
Add to your project#
<dependency>
<groupId>dev.garlandframework</groupId>
<artifactId>garland-http</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
Available modules: garland-http, garland-postgres, garland-kafka, garland-mongodb, garland-testng
Links#
Type-safe pipeline composition for Java integration testing — HTTP, DB, Kafka, MongoDB.
Requirements Java 21+ Maven 3.8+ Add dependencies Add the modules you need to your test pom.xml:
<dependency> <groupId>dev.garlandframework</groupId> <artifactId>garland-http</artifactId> <version>1.0.0</version> <scope>test</scope> </dependency> <dependency> <groupId>dev.garlandframework</groupId> <artifactId>garland-postgres</artifactId> <version>1.0.0</version> <scope>test</scope> </dependency> <dependency> <groupId>dev.garlandframework</groupId> <artifactId>garland-kafka</artifactId> <version>1.0.0</version> <scope>test</scope> </dependency> <dependency> <groupId>dev.garlandframework</groupId> <artifactId>garland-mongodb</artifactId> <version>1.0.0</version> <scope>test</scope> </dependency> Configure clients HttpTestClient http = new HttpTestClient( HttpConfig.builder() .baseUrl("http://localhost:8080") .build() ); PostgresTestClient postgres = new PostgresTestClient( DbConfig.builder() .url("jdbc:postgresql://localhost:5432/mydb") .username("user").password("pass") .entityPackage("com.example.entities") .build() ); Write a pipeline test @Test public void createUser_verifiedInDbAndKafka() { UserDto expected = new UserDto("Alice", "[email protected]"); Pipeline.given(HttpCallRequest.post("/api/users").withBody(expected)) .then(http.makeCall(201, UserDto.class)) .then(Verify.matching(expected)) .then(UserMapper.toEntity().andThen(postgres.findByFields())) .execute(); } See a full example Clone the demo project — two Spring Boot microservices with a complete test suite covering HTTP, Postgres, Kafka, and MongoDB.
...