@Test public void testExceptionWhenBundleIsNotAllowed() throws FunctionalException { final FunctionalException fe = new FunctionalException(FunctionalExceptionType.UNAUTHORIZED, ComponentType.WS_SMART_METERING); doThrow(fe).when(this.domainHelperService).checkAllowed(this.organisation, this.device, DeviceFunction.HANDLE_BUNDLED_ACTIONS); try { this.bundleService.enqueueBundleRequest(ORGANISATION_IDENTIFICATION, DEVICE_IDENTIFICATION, this.actionRequestMockList, MESSAGE_PRIORITY, BYPASS_RETRY); } catch (final FunctionalException e) { assertThat(e).isEqualTo(fe); } }
public String enqueueBundleRequest(final String organisationIdentification, final String deviceIdentification, final List<ActionRequest> actionList, final int messagePriority, final boolean bypassRetry) throws FunctionalException { final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification); final Device device = this.domainHelperService.findActiveDevice(deviceIdentification); LOGGER.info("Bundle request called with organisation {}", organisationIdentification); this.checkIfBundleIsAllowed(actionList, organisation, device); final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification); final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, MessageType.HANDLE_BUNDLED_ACTIONS.name(), messagePriority); deviceMessageMetadata.setBypassRetry(bypassRetry); final SmartMeteringRequestMessage message = new SmartMeteringRequestMessage.Builder().deviceMessageMetadata( deviceMessageMetadata).request(new BundleMessageRequest(actionList)).build(); this.smartMeteringRequestMessageSender.send(message); return correlationUid; }
BundleService { public String enqueueBundleRequest(final String organisationIdentification, final String deviceIdentification, final List<ActionRequest> actionList, final int messagePriority, final boolean bypassRetry) throws FunctionalException { final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification); final Device device = this.domainHelperService.findActiveDevice(deviceIdentification); LOGGER.info("Bundle request called with organisation {}", organisationIdentification); this.checkIfBundleIsAllowed(actionList, organisation, device); final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification); final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, MessageType.HANDLE_BUNDLED_ACTIONS.name(), messagePriority); deviceMessageMetadata.setBypassRetry(bypassRetry); final SmartMeteringRequestMessage message = new SmartMeteringRequestMessage.Builder().deviceMessageMetadata( deviceMessageMetadata).request(new BundleMessageRequest(actionList)).build(); this.smartMeteringRequestMessageSender.send(message); return correlationUid; } }
BundleService { public String enqueueBundleRequest(final String organisationIdentification, final String deviceIdentification, final List<ActionRequest> actionList, final int messagePriority, final boolean bypassRetry) throws FunctionalException { final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification); final Device device = this.domainHelperService.findActiveDevice(deviceIdentification); LOGGER.info("Bundle request called with organisation {}", organisationIdentification); this.checkIfBundleIsAllowed(actionList, organisation, device); final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification); final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, MessageType.HANDLE_BUNDLED_ACTIONS.name(), messagePriority); deviceMessageMetadata.setBypassRetry(bypassRetry); final SmartMeteringRequestMessage message = new SmartMeteringRequestMessage.Builder().deviceMessageMetadata( deviceMessageMetadata).request(new BundleMessageRequest(actionList)).build(); this.smartMeteringRequestMessageSender.send(message); return correlationUid; } BundleService(); }
BundleService { public String enqueueBundleRequest(final String organisationIdentification, final String deviceIdentification, final List<ActionRequest> actionList, final int messagePriority, final boolean bypassRetry) throws FunctionalException { final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification); final Device device = this.domainHelperService.findActiveDevice(deviceIdentification); LOGGER.info("Bundle request called with organisation {}", organisationIdentification); this.checkIfBundleIsAllowed(actionList, organisation, device); final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification); final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, MessageType.HANDLE_BUNDLED_ACTIONS.name(), messagePriority); deviceMessageMetadata.setBypassRetry(bypassRetry); final SmartMeteringRequestMessage message = new SmartMeteringRequestMessage.Builder().deviceMessageMetadata( deviceMessageMetadata).request(new BundleMessageRequest(actionList)).build(); this.smartMeteringRequestMessageSender.send(message); return correlationUid; } BundleService(); String enqueueBundleRequest(final String organisationIdentification, final String deviceIdentification,
            final List<ActionRequest> actionList, final int messagePriority, final boolean bypassRetry); }
BundleService { public String enqueueBundleRequest(final String organisationIdentification, final String deviceIdentification, final List<ActionRequest> actionList, final int messagePriority, final boolean bypassRetry) throws FunctionalException { final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification); final Device device = this.domainHelperService.findActiveDevice(deviceIdentification); LOGGER.info("Bundle request called with organisation {}", organisationIdentification); this.checkIfBundleIsAllowed(actionList, organisation, device); final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification); final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, MessageType.HANDLE_BUNDLED_ACTIONS.name(), messagePriority); deviceMessageMetadata.setBypassRetry(bypassRetry); final SmartMeteringRequestMessage message = new SmartMeteringRequestMessage.Builder().deviceMessageMetadata( deviceMessageMetadata).request(new BundleMessageRequest(actionList)).build(); this.smartMeteringRequestMessageSender.send(message); return correlationUid; } BundleService(); String enqueueBundleRequest(final String organisationIdentification, final String deviceIdentification,
            final List<ActionRequest> actionList, final int messagePriority, final boolean bypassRetry);  }