+
+ /**
+ * Constructs the ResponseString on the basis of request.
+ *
+ * @param executionServiceInput service input
+ * @param countOfSuccesfulEvents number of successive successful events
+ * @return responseString
+ */
+ public String getResponseString(ExecutionServiceInput executionServiceInput, int countOfSuccesfulEvents) {
+ String resourceName = "DefaultResponseEvent";
+ if (!StringUtils.isBlank(executionServiceInput.getActionIdentifiers().getActionName())) {
+ ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
+ resourceName = actionIdentifiers.getBlueprintName() + "-" + actionIdentifiers.getActionName();
+ }
+ if (countOfSuccesfulEvents > 0 && countOfEvents.getAndIncrement() % countOfSuccesfulEvents == 0) {
+ // generating the failure response
+ resourceName = resourceName + "-error.json";
+ } else {
+ resourceName = resourceName + ".json";
+ }
+ String responseString = ResourceUtils.getResourceAsString(resourceLocation + resourceName);
+ if (responseString == null) {
+ responseString = ResourceUtils.getResourceAsString(resourceLocation
+ + "DefaultResponseEvent.json");
+ }
+ return responseString;
+ }