@Test public void testHappyFlow() { final List<ActionDto> actionDtoList = this.makeActions(); final BundleMessagesRequestDto dto = new BundleMessagesRequestDto(actionDtoList); final BundleMessagesRequestDto result = this.callExecutors(dto); this.assertResult(result); }
public BundleMessagesRequestDto callExecutors(final DlmsConnectionManager conn, final DlmsDevice device, final BundleMessagesRequestDto bundleMessagesRequest) { final List<ActionDto> actionList = bundleMessagesRequest.getActionList(); for (final ActionDto actionDto : actionList) { if (actionDto.getResponse() == null) { final Class<? extends ActionRequestDto> actionRequestClass = actionDto.getRequest().getClass(); final CommandExecutor<?, ?> executor = this.bundleCommandExecutorMap .getCommandExecutor(actionRequestClass); final String executorName = executor == null ? "null" : executor.getClass().getSimpleName(); try { this.checkIfExecutorExists(actionRequestClass, executor); LOGGER.debug("**************************************************"); LOGGER.info("Calling executor in bundle {}", executorName); LOGGER.debug("**************************************************"); actionDto.setResponse(executor.executeBundleAction(conn, device, actionDto.getRequest())); } catch (final ConnectionException connectionException) { LOGGER.warn("A connection exception occurred while executing {}", executorName, connectionException); final List<ActionDto> remainingActionDtoList = actionList .subList(actionList.indexOf(actionDto), actionList.size()); for (final ActionDto remainingActionDto : remainingActionDtoList) { LOGGER.debug("Skipping: {}", remainingActionDto.getRequest().getClass().getSimpleName()); } actionDto.setResponse(null); throw connectionException; } catch (final Exception exception) { LOGGER.error("Error while executing bundle action for {} with {}", actionRequestClass.getName(), executorName, exception); final String responseMessage = executor == null ? "Unable to handle request" : "Error handling request with " + executorName; this.addFaultResponse(actionDto, exception, responseMessage, device); } } } return bundleMessagesRequest; }
BundleService { public BundleMessagesRequestDto callExecutors(final DlmsConnectionManager conn, final DlmsDevice device, final BundleMessagesRequestDto bundleMessagesRequest) { final List<ActionDto> actionList = bundleMessagesRequest.getActionList(); for (final ActionDto actionDto : actionList) { if (actionDto.getResponse() == null) { final Class<? extends ActionRequestDto> actionRequestClass = actionDto.getRequest().getClass(); final CommandExecutor<?, ?> executor = this.bundleCommandExecutorMap .getCommandExecutor(actionRequestClass); final String executorName = executor == null ? "null" : executor.getClass().getSimpleName(); try { this.checkIfExecutorExists(actionRequestClass, executor); LOGGER.debug("**************************************************"); LOGGER.info("Calling executor in bundle {}", executorName); LOGGER.debug("**************************************************"); actionDto.setResponse(executor.executeBundleAction(conn, device, actionDto.getRequest())); } catch (final ConnectionException connectionException) { LOGGER.warn("A connection exception occurred while executing {}", executorName, connectionException); final List<ActionDto> remainingActionDtoList = actionList .subList(actionList.indexOf(actionDto), actionList.size()); for (final ActionDto remainingActionDto : remainingActionDtoList) { LOGGER.debug("Skipping: {}", remainingActionDto.getRequest().getClass().getSimpleName()); } actionDto.setResponse(null); throw connectionException; } catch (final Exception exception) { LOGGER.error("Error while executing bundle action for {} with {}", actionRequestClass.getName(), executorName, exception); final String responseMessage = executor == null ? "Unable to handle request" : "Error handling request with " + executorName; this.addFaultResponse(actionDto, exception, responseMessage, device); } } } return bundleMessagesRequest; } }
BundleService { public BundleMessagesRequestDto callExecutors(final DlmsConnectionManager conn, final DlmsDevice device, final BundleMessagesRequestDto bundleMessagesRequest) { final List<ActionDto> actionList = bundleMessagesRequest.getActionList(); for (final ActionDto actionDto : actionList) { if (actionDto.getResponse() == null) { final Class<? extends ActionRequestDto> actionRequestClass = actionDto.getRequest().getClass(); final CommandExecutor<?, ?> executor = this.bundleCommandExecutorMap .getCommandExecutor(actionRequestClass); final String executorName = executor == null ? "null" : executor.getClass().getSimpleName(); try { this.checkIfExecutorExists(actionRequestClass, executor); LOGGER.debug("**************************************************"); LOGGER.info("Calling executor in bundle {}", executorName); LOGGER.debug("**************************************************"); actionDto.setResponse(executor.executeBundleAction(conn, device, actionDto.getRequest())); } catch (final ConnectionException connectionException) { LOGGER.warn("A connection exception occurred while executing {}", executorName, connectionException); final List<ActionDto> remainingActionDtoList = actionList .subList(actionList.indexOf(actionDto), actionList.size()); for (final ActionDto remainingActionDto : remainingActionDtoList) { LOGGER.debug("Skipping: {}", remainingActionDto.getRequest().getClass().getSimpleName()); } actionDto.setResponse(null); throw connectionException; } catch (final Exception exception) { LOGGER.error("Error while executing bundle action for {} with {}", actionRequestClass.getName(), executorName, exception); final String responseMessage = executor == null ? "Unable to handle request" : "Error handling request with " + executorName; this.addFaultResponse(actionDto, exception, responseMessage, device); } } } return bundleMessagesRequest; }  }
BundleService { public BundleMessagesRequestDto callExecutors(final DlmsConnectionManager conn, final DlmsDevice device, final BundleMessagesRequestDto bundleMessagesRequest) { final List<ActionDto> actionList = bundleMessagesRequest.getActionList(); for (final ActionDto actionDto : actionList) { if (actionDto.getResponse() == null) { final Class<? extends ActionRequestDto> actionRequestClass = actionDto.getRequest().getClass(); final CommandExecutor<?, ?> executor = this.bundleCommandExecutorMap .getCommandExecutor(actionRequestClass); final String executorName = executor == null ? "null" : executor.getClass().getSimpleName(); try { this.checkIfExecutorExists(actionRequestClass, executor); LOGGER.debug("**************************************************"); LOGGER.info("Calling executor in bundle {}", executorName); LOGGER.debug("**************************************************"); actionDto.setResponse(executor.executeBundleAction(conn, device, actionDto.getRequest())); } catch (final ConnectionException connectionException) { LOGGER.warn("A connection exception occurred while executing {}", executorName, connectionException); final List<ActionDto> remainingActionDtoList = actionList .subList(actionList.indexOf(actionDto), actionList.size()); for (final ActionDto remainingActionDto : remainingActionDtoList) { LOGGER.debug("Skipping: {}", remainingActionDto.getRequest().getClass().getSimpleName()); } actionDto.setResponse(null); throw connectionException; } catch (final Exception exception) { LOGGER.error("Error while executing bundle action for {} with {}", actionRequestClass.getName(), executorName, exception); final String responseMessage = executor == null ? "Unable to handle request" : "Error handling request with " + executorName; this.addFaultResponse(actionDto, exception, responseMessage, device); } } } return bundleMessagesRequest; }  BundleMessagesRequestDto callExecutors(final DlmsConnectionManager conn, final DlmsDevice device,
            final BundleMessagesRequestDto bundleMessagesRequest); }
BundleService { public BundleMessagesRequestDto callExecutors(final DlmsConnectionManager conn, final DlmsDevice device, final BundleMessagesRequestDto bundleMessagesRequest) { final List<ActionDto> actionList = bundleMessagesRequest.getActionList(); for (final ActionDto actionDto : actionList) { if (actionDto.getResponse() == null) { final Class<? extends ActionRequestDto> actionRequestClass = actionDto.getRequest().getClass(); final CommandExecutor<?, ?> executor = this.bundleCommandExecutorMap .getCommandExecutor(actionRequestClass); final String executorName = executor == null ? "null" : executor.getClass().getSimpleName(); try { this.checkIfExecutorExists(actionRequestClass, executor); LOGGER.debug("**************************************************"); LOGGER.info("Calling executor in bundle {}", executorName); LOGGER.debug("**************************************************"); actionDto.setResponse(executor.executeBundleAction(conn, device, actionDto.getRequest())); } catch (final ConnectionException connectionException) { LOGGER.warn("A connection exception occurred while executing {}", executorName, connectionException); final List<ActionDto> remainingActionDtoList = actionList .subList(actionList.indexOf(actionDto), actionList.size()); for (final ActionDto remainingActionDto : remainingActionDtoList) { LOGGER.debug("Skipping: {}", remainingActionDto.getRequest().getClass().getSimpleName()); } actionDto.setResponse(null); throw connectionException; } catch (final Exception exception) { LOGGER.error("Error while executing bundle action for {} with {}", actionRequestClass.getName(), executorName, exception); final String responseMessage = executor == null ? "Unable to handle request" : "Error handling request with " + executorName; this.addFaultResponse(actionDto, exception, responseMessage, device); } } } return bundleMessagesRequest; }  BundleMessagesRequestDto callExecutors(final DlmsConnectionManager conn, final DlmsDevice device,
            final BundleMessagesRequestDto bundleMessagesRequest);  }