Description
Reason/Context
Hello,
We use microcks-testcontainers-java to mock SOAP web services, importing SoapUI projects.
It works well, but we lack of methods on MicrocksContainer class that could return the invocations count of a service SOAP.
We saw this data is available in admin console, and is accessible via Metrics resource in REST API.
So we would like to have this data easily available, we think it could be benefit for many.
And why do we need to check this invocation count ?
To be sure the mock as been invoked by the application we are covering with integration tests.
Indeed, sometimes we have SOAP WS that just return empty body. For instance : WS that just does an update.
Without having this invocations count, we are not able to know whether our application had the correct behaviour or not.
In summary : it would be like what we do when we call the "verify" method of "Mockito".
Description
Add methods to MicrocksContainer class that could return the invocations count of a service SOAP.
Implementation ideas
This is a draft, using project microcks-java-client
to have MetricsApi
class :
private static @NotNull BigDecimal getServiceInvocationsCount(String serviceName,
String serviceVersion,
@Nullable Date invocationDate) {
ApiClient apiClient = new ApiClient();
apiClient.updateBaseUri(getHttpEndpoint() + "/api");
MetricsApi metricsApi = new MetricsApi(apiClient);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
final String stringifiedDate = (invocationDate != null) ? simpleDateFormat.format(invocationDate) : null;
BigDecimal count = null;
try {
DailyInvocationStatistic dailyInvocationStatistic =
metricsApi.getInvocationStatsByService(serviceName, serviceVersion, stringifiedDate);
count = dailyInvocationStatistic.getDailyCount();
} catch (ApiException e) {
throw new RuntimeException(e); // TODO Better exception handling
}
return count;
}
We have already done the code and would like to create branch to push commit but it seems I am not allow to do it.
@lbroudoux (or someone else) : could you please, give me the ability to push a commit on a new branch to submit a PR ?
We are opened to any suggestion, and we give thanks to the community for what you've done so far.