Testing And Reviewing Integrations
Klok integrations should be reviewed as production software, not just as mapping scripts.
Test Levels
| Level | Purpose |
|---|---|
| Unit test | Prove transformation and validation logic with small fixtures |
| Route/component test | Prove route behavior with mocked endpoints and broker interactions |
| Integration test | Prove actual protocol configuration, serialization, and error paths |
| End-to-end test | Prove the solution works across onramp, broker, processing, and offramp |
| Performance test | Prove throughput, latency, batching, and vendor rate constraints |
| Operations test | Prove logs, correlation, retries, DLQ, and failure events are visible |
Transformation Tests
Every non-trivial transformation should have tests for:
- Happy path.
- Missing optional fields.
- Missing required fields.
- Invalid enum or code values.
- Date, time, and timezone conversion.
- Numeric rounding and precision.
- Unknown fields in forward-compatible payloads.
Failure Tests
Test failures deliberately:
- Source timeout.
- Target timeout.
- Authentication failure.
- Invalid payload.
- Serialization error.
- Rate limit response.
- Poison message.
- DLQ path.
Review Checklist
- [ ] Route belongs to an integration solution.
- [ ] Route class name uses the correct prefix.
- [ ] Source and target systems are registered.
- [ ] Broker payload is Class B or C unless tactical debt is documented.
- [ ] Topic names follow standards.
- [ ] CloudEvent metadata is correct.
- [ ] Secrets are referenced, not stored.
- [ ] Logs include tenant, domain, solution, route, and correlation context.
- [ ] Tests cover transformation and error paths.
- [ ] Generated documentation and Integration Context are updated by CI/CD.
Human Review Of AI Output
AI-generated code should be treated like code from a junior developer with perfect typing speed and no production accountability. Review it for business semantics, platform rules, security, hidden coupling, and operational behavior.