use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionDto in project open-smart-grid-platform by OSGP.
the class BundleServiceTest method makeActions.
private List<ActionDto> makeActions() {
final List<ActionDto> actions = new ArrayList<>();
actions.add(new ActionDto(this.builder.makeActualMeterReadsDataDtoAction()));
actions.add(new ActionDto(this.builder.makeActualPowerQualityRequestDto()));
actions.add(new ActionDto(this.builder.makePeriodicMeterReadsGasRequestDataDto()));
actions.add(new ActionDto(this.builder.makePeriodicMeterReadsRequestDataDto()));
actions.add(new ActionDto(this.builder.makeSpecialDaysRequestDataDto()));
actions.add(new ActionDto(this.builder.makeReadAlarmRegisterDataDto()));
actions.add(new ActionDto(this.builder.makeGetAdministrativeStatusDataDto()));
actions.add(new ActionDto(this.builder.makeAdministrativeStatusTypeDataDto()));
actions.add(new ActionDto(this.builder.makeActivityCalendarDataDto()));
actions.add(new ActionDto(this.builder.makeFindEventsQueryDto()));
actions.add(new ActionDto(this.builder.makeGMeterInfoDto()));
actions.add(new ActionDto(this.builder.makeSetAlarmNotificationsRequestDataDto()));
actions.add(new ActionDto(this.builder.makeSetConfigurationObjectRequestDataDto()));
actions.add(new ActionDto(this.builder.makeSetPushSetupAlarmRequestDataDto()));
actions.add(new ActionDto(this.builder.makeSetPushSetupSmsRequestDataDto()));
actions.add(new ActionDto(this.builder.makeSynchronizeTimeRequestDataDto()));
actions.add(new ActionDto(this.builder.makeGetAllAttributeValuesRequestDto()));
actions.add(new ActionDto(this.builder.makeGetFirmwareVersionRequestDataDto()));
return actions;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionDto in project open-smart-grid-platform by OSGP.
the class BundleServiceTest method testConnectionException.
/**
* Tests the retry mechanism works in the adapter-protocol. In the first run a ConnectionException
* is thrown while executing the {@link FindEventsRequestDto}. In the second attempt (when the
* connection is restored again) the rest of the actions are executed.
*
* @throws ProtocolAdapterException is not thrown in this test
*/
@Test
public void testConnectionException() throws ProtocolAdapterException {
final List<ActionDto> actionDtoList = this.makeActions();
final BundleMessagesRequestDto dto = new BundleMessagesRequestDto(actionDtoList);
// Set the point where to throw the ConnectionException
this.getStub(FindEventsRequestDto.class).failWithRuntimeException(new ConnectionException("Connection Exception thrown!"));
try {
// Execute all the actions
this.callExecutors(dto, this.messageMetadata);
fail("A ConnectionException should be thrown");
} catch (final ConnectionException connectionException) {
// The execution is stopped. The number of responses is equal to the
// actions performed before the point the exception is thrown. See
// also the order of the ArrayList in method 'makeActions'.
assertThat(dto.getAllResponses().size()).isEqualTo(9);
}
// Reset the point where the exception was thrown.
this.getStub(FindEventsRequestDto.class).failWithRuntimeException(null);
try {
// Execute the remaining actions
this.callExecutors(dto, this.messageMetadata);
assertThat(actionDtoList.size()).isEqualTo(dto.getAllResponses().size());
} catch (final ConnectionException connectionException) {
fail("A ConnectionException should not have been thrown.");
}
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionDto in project open-smart-grid-platform by OSGP.
the class BundleMessageProcessorTest method prepareBundleServiceMockWithRequestAndResponse.
private void prepareBundleServiceMockWithRequestAndResponse(final ActionResponseDto response) throws JMSException {
final ActionDto action = new ActionDto(new ClearAlarmRegisterRequestDto());
action.setResponse(response);
final BundleMessagesRequestDto request = new BundleMessagesRequestDto(Arrays.asList(action));
when(this.message.getObject()).thenReturn(request);
when(this.bundleService.callExecutors(same(this.dlmsConnectionManager), same(this.dlmsDevice), same(request), any(MessageMetadata.class))).thenReturn(request);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionDto in project open-smart-grid-platform by OSGP.
the class BundleResponseMessageProcessor method handleError.
@Override
protected void handleError(final Exception e, final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage) throws FunctionalException {
final OsgpException osgpException = this.ensureOsgpException(e);
final BundleMessagesRequestDto bundleMessagesResponseDto = (BundleMessagesRequestDto) responseMessage.getDataObject();
final List<ActionDto> actionList = bundleMessagesResponseDto.getActionList();
for (final ActionDto action : actionList) {
if (action.getResponse() == null) {
final List<FaultResponseParameterDto> parameterList = new ArrayList<>();
final FaultResponseParameterDto deviceIdentificationParameter = new FaultResponseParameterDto("deviceIdentification", deviceMessageMetadata.getDeviceIdentification());
parameterList.add(deviceIdentificationParameter);
action.setResponse(this.faultResponseForException(e, parameterList, "Unable to handle request"));
}
}
this.bundleService.handleBundleResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, bundleMessagesResponseDto);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionDto in project open-smart-grid-platform by OSGP.
the class BundleServiceTest method createAction.
private ActionDto createAction(final ActionRequestDto actionRequestDto, final ActionResponseDto actionResponseDto) {
final ActionDto action = new ActionDto(actionRequestDto);
action.setResponse(actionResponseDto);
return action;
}
Aggregations