- Status
- illustrative
- Industry
- Insurance
- Language
- Java
- Framework
- JUnit 5
- CI
- any
- Fulfilment
- BUILD_DATASET
- Profile
- insurance-claims
About this example
All data is synthetic. DataNivra provisions approved test data into a customer-controlled target; it does not run these tests. Credentials for the target are never returned by DataNivra — your runner holds its own.
Why test data matters
Payout calculations fail at deductible and limit boundaries; those cases are rare in a sample.
What is requested
insurance-claims@1 with INS_EVERYDAY_BOOK × 200, INS_CLAIM_PAYMENT_EDGE_CASES × 100.
Policy gates
Within the profile maximums; synthetic-only.
What is provisioned
A certified synthetic dataset in the profile's approved target.
Expected output
AUTO_APPROVED for a developer; the test polls until READY.
Cleanup
The finally/teardown block calls POST /v1/test-data/requests/{id}/release.
Files
request.yamlClaimPayoutTest.java
Run
- A tenant administrator defines and a second person approves the profile (
datanivra test-data define ../../profiles/insurance-claims.yaml --submit, thendatanivra policies approve). datanivra test-data validate request.yaml && datanivra test-data plan request.yaml- Run the example with
DATANIVRA_BASE_URLand a session or workload token.
Files
Exactly as they are in the examples repository. Every value is a synthetic placeholder; nothing here is a credential.
request.json
{
"profile": {
"name": "insurance-claims",
"version": 1
},
"scenarios": [
{
"scenario_code": "INS_EVERYDAY_BOOK",
"count": 200
},
{
"scenario_code": "INS_CLAIM_PAYMENT_EDGE_CASES",
"count": 100
}
]
}
examples/test-data-api/scenarios/04-insurance-claim-edge-cases/request.json
request.yaml
# yaml-language-server: $schema=../../../../packages/contracts/schemas/v1/manifests/test-data-request.schema.json
# DataNivra test-data-request manifest (apiVersion datanivra.io/v1alpha1). Validate: datanivra test-data validate <file>
apiVersion: datanivra.io/v1alpha1
kind: TestDataRequest
metadata:
name: insurance-claim-edge-cases
spec:
profile: { name: insurance-claims, version: 1 }
scenarios:
- { scenario_code: INS_EVERYDAY_BOOK, count: 200 }
- { scenario_code: INS_CLAIM_PAYMENT_EDGE_CASES, count: 100 }
examples/test-data-api/scenarios/04-insurance-claim-edge-cases/request.yaml
ClaimPayoutTest.java
// Insurance claim payout edge cases — JUnit 5 using the REST API (no Java SDK exists; java.net.http only).
// DataNivra provisions approved data; this test then exercises your service with its own DB access.
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
class ClaimPayoutTest {
static final String API = System.getenv("DATANIVRA_BASE_URL") + "/v1/test-data/requests";
static final HttpClient HTTP = HttpClient.newHttpClient();
static String requestId;
static HttpRequest.Builder call(String url) {
return HttpRequest.newBuilder(URI.create(url))
.header("Authorization", "Bearer " + System.getenv("DATANIVRA_TOKEN"))
.header("Content-Type", "application/json");
}
@BeforeAll
static void acquire() throws Exception {
// request.json holds the same TestDataRequest spec as request.yaml (JSON form).
String body = Files.readString(Path.of("request.json"));
HttpResponse<String> created = HTTP.send(call(API).POST(HttpRequest.BodyPublishers.ofString(body)).build(),
HttpResponse.BodyHandlers.ofString());
requestId = created.body().replaceAll("(?s).*\"id\":\"([^\"]+)\".*", "$1");
for (int i = 0; i < 120; i++) {
String state = HTTP.send(call(API + "/" + requestId).GET().build(), HttpResponse.BodyHandlers.ofString())
.body().replaceAll("(?s).*\"state\":\"([A-Z_]+)\".*", "$1");
if (state.equals("READY")) return;
Thread.sleep(5000);
}
throw new IllegalStateException("test data not READY");
}
@AfterAll
static void release() throws Exception {
if (requestId != null) {
HTTP.send(call(API + "/" + requestId + "/release")
.POST(HttpRequest.BodyPublishers.ofString("{\"reason_code\":\"TEST_RUN_FINISHED\"}")).build(),
HttpResponse.BodyHandlers.discarding());
}
}
@Test
void payoutNeverExceedsTheLimit() {
// Query your claims service against the approved target and assert payouts at the boundaries.
assertEquals(true, requestId != null);
}
}
examples/test-data-api/scenarios/04-insurance-claim-edge-cases/ClaimPayoutTest.java
The profile it uses: insurance-claims
A tenant administrator defines this profile and a second person approves it; requests can only ask for what it allows. All profiles
insurance-claims.yaml
# yaml-language-server: $schema=../../../packages/contracts/schemas/v1/manifests/test-data-profile.schema.json
# DataNivra test-data-profile manifest (apiVersion datanivra.io/v1alpha1). Validate: datanivra test-data validate <file>
# Placeholder ids (00000000-0000-4000-8000-0000000000NN): replace with your ids.
# 01 = approved target environment, 11 = certified dataset, 21 = customer agent,
# 99 = workload identity trust (datanivra workload-identities list).
apiVersion: datanivra.io/v1alpha1
kind: TestDataProfile
metadata:
name: insurance-claims
description: Synthetic policies, claims and payouts
spec:
fulfilment: BUILD_DATASET
build:
business_domain: policies and claims
pack_id: insurance
dataset_kind: SYNTHETIC_ONLY
target_environment_id: 00000000-0000-4000-8000-000000000001
retention_days: 1
max_total_records: 1500
scenarios:
- {
pack_id: insurance,
scenario_code: INS_EVERYDAY_BOOK,
kind: NORMAL,
default_count: 500,
max_count: 1000,
}
- {
pack_id: insurance,
scenario_code: INS_CLAIM_PAYMENT_EDGE_CASES,
kind: BOUNDARY,
default_count: 50,
max_count: 200,
}
- {
pack_id: insurance,
scenario_code: INS_EARLY_CLAIM_REVIEW,
kind: RARE,
default_count: 50,
max_count: 200,
included_by_default: false,
}
- {
pack_id: insurance,
scenario_code: INS_DUPLICATE_CLAIMS,
kind: DUPLICATE,
default_count: 20,
max_count: 100,
included_by_default: false,
}