API Reference
Unit test improvement
With bitryon logger, developers can directly run uni test from logs against models.
the idea is to check if the values appear in the sample payload with the method calls' return.
For some unit tests, we don't need to exam all of returned values and json-structure exactly matched.
Therefore the sample must be a subset of the returned objects after the invoke. So we can manipulate unit tests by logs.
Methods
| Method | Description |
|---|---|
boolean containSubset(Object subsetObject, Object supersetObject) | The structural match if the value is Collection, Map and Array, equals at the exact same depth like json. it will transform the structure to Collection, Map and Array then match if there is a subset. |
Contain subset
The return of method full equals to the return from the logs
@Test
public void test_case8() throws Exception {
String fileName = "sample/test_case8.log";
LogLineInvoke logLineInvoke = LogLineHelper.readLogLineFile(fileName);
LogLineInvokerHelper.invokeLogLineInvokers(loggingMethodIntercepter, methodToBeans, logLineInvoke);
Object[] retSampleVals = LogLineInvokerHelper.parseReturnObject(logLineInvoke.getMethod(), logLineInvoke.getReturnSample().getPayload());
Assertions.assertTrue(LogLineInvokerHelper.containSubset(retSampleVals[0], logLineInvoke.getReturnAndParameter()[0]));
Assertions.assertFalse(LogLineInvokerHelper.containSubset(logLineInvoke.getReturnAndParameter()[0], retSampleVals[0]));
}
//sample/test_case8.log
2025-08-09 16:51:51.806|main-http-nio-80-exec-2-41-5|6zqPlRGyIXvKlQkYMxRyDopSsZwMlJ91|8-1|JSON|
UserServiceImpl.java#io.bitryon.example.web.service.rpc.UserServiceImpl#getById#24#|
[
{
"userId": 0
}
]
2025-08-09 16:51:51.807|main-http-nio-80-exec-2-41-5|6zqPlRGyIXvKlQkYMxRyDopSsZwMlJ91|8-3|JSON|
UserServiceImpl.java#io.bitryon.example.web.service.rpc.UserServiceImpl#getById#24#R|
[
{
"name": "randome guy probably",
"id": 123,
"driverLisenceId": "a number that you can't know"
}
]
Full match
The return of method full equals to the return from the logs
@Test
public void test_case5() throws Exception {
String fileName = "sample/test_case5.log";
LogLineInvoke logLineInvoke = LogLineHelper.readLogLineFile(fileName);
LogLineInvokerHelper.invokeLogLineInvokers(loggingMethodIntercepter, methodToBeans, logLineInvoke);
Object[] retVals = LogLineInvokerHelper.parseReturnObject(logLineInvoke.getMethod(), logLineInvoke.getReturnSample().getPayload());
Assertions.assertEquals(retVals[0], logLineInvoke.getReturnAndParameter()[0]);
}
// sample/test_case5.log
2025-08-11 16:01:40.594|main-http-nio-80-exec-1-40-5|5o0ku57lL7LVoG3N4Pqm89byaX5tBwHi|4|JSON|
MedicService.java#io.bitryon.example.web.service.MedicService#query#-2222222#|
[
{
"sessionId": "xxx",
"page": {
"size": 123,
"offset": 0
}
}
]
2025-08-11 16:01:41.300|main-http-nio-80-exec-1-40-5|5o0ku57lL7LVoG3N4Pqm89byaX5tBwHi|15|JSON|
MedicService.java#io.bitryon.example.web.service.MedicService#query#-111111#R|
[
[
{
"user": {
"name": "randome guy probably",
"id": 123,
"age": null,
"birthday": "2025-08-10T15:42:17.123+02",
"driverLisenceId": "a number that you can't know"
},
"medicConditionDO": {
"id": 321,
"deceases": "idk, maybe conding fever",
"timeCreated": 111111111111111,
"userId": 123
}
}
]
]
💡 More
See LogLineInvokerHelper and LocalCasesTest on Github