use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.
the class SetPushSetupAlarmCommandExecutorTest method testSetPushObjectList.
@Test
void testSetPushObjectList() throws ProtocolAdapterException, IOException {
// SETUP
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
when(this.dlmsConnection.get(any(AttributeAddress.class))).thenReturn(new GetResultImpl(DataObject.newNullData(), AccessResultCode.SUCCESS));
final PushSetupAlarmDto.Builder pushSetupAlarmBuilder = new PushSetupAlarmDto.Builder();
pushSetupAlarmBuilder.withPushObjectList(PUSH_OBJECT_LIST);
final PushSetupAlarmDto pushSetupAlarmDto = pushSetupAlarmBuilder.build();
// CALL
final AccessResultCode resultCode = this.executor.execute(this.conn, this.DLMS_DEVICE, pushSetupAlarmDto, this.messageMetadata);
// VERIFY
assertThat(resultCode).isEqualTo(AccessResultCode.SUCCESS);
verify(this.dlmsConnection, times(1)).set(this.setParameterArgumentCaptor.capture());
final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
this.verifyPushObjectListParameter(setParameters.get(0));
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.
the class SetPushSetupAlarmRequestMessageProcessor method handleMessage.
@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
this.assertRequestObjectType(PushSetupAlarmDto.class, requestObject);
final PushSetupAlarmDto pushSetupAlarm = (PushSetupAlarmDto) requestObject;
this.configurationService.setPushSetupAlarm(conn, device, pushSetupAlarm, messageMetadata);
return null;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.
the class GetPushSetupAlarmCommandExecutor method execute.
@Override
public PushSetupAlarmDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final Void useless, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
conn.getDlmsMessageListener().setDescription("GetPushSetupAlarm, retrieve attributes: " + JdlmsObjectToStringUtil.describeAttributes(ATTRIBUTE_ADDRESSES));
LOGGER.info("Retrieving Push Setup Alarm");
final List<GetResult> getResultList = this.dlmsHelper.getWithList(conn, device, ATTRIBUTE_ADDRESSES);
GetPushSetupCommandExecutor.checkResultList(getResultList, ATTRIBUTE_ADDRESSES);
final PushSetupAlarmDto.Builder pushSetupAlarmBuilder = new PushSetupAlarmDto.Builder();
pushSetupAlarmBuilder.withLogicalName(new CosemObisCodeDto(OBIS_CODE.bytes()));
pushSetupAlarmBuilder.withPushObjectList(this.dlmsHelper.readListOfObjectDefinition(getResultList.get(INDEX_PUSH_OBJECT_LIST), "Push Object List"));
pushSetupAlarmBuilder.withSendDestinationAndMethod(this.dlmsHelper.readSendDestinationAndMethod(getResultList.get(INDEX_SEND_DESTINATION_AND_METHOD), "Send Destination And Method"));
pushSetupAlarmBuilder.withCommunicationWindow(this.dlmsHelper.readListOfWindowElement(getResultList.get(INDEX_COMMUNICATION_WINDOW), "Communication Window"));
pushSetupAlarmBuilder.withRandomisationStartInterval(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_RANDOMISATION_START_INTERVAL), "Randomisation Start Interval").intValue());
pushSetupAlarmBuilder.withNumberOfRetries(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_NUMBER_OF_RETRIES), "Number of Retries").intValue());
pushSetupAlarmBuilder.withRepetitionDelay(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_REPETITION_DELAY), "Repetition Delay").intValue());
return pushSetupAlarmBuilder.build();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.
the class PushSetupAlarmDtoConverterTest method convertTest.
@Test
void convertTest() {
final List<WindowElement> testList = Collections.singletonList(new WindowElement(new CosemDateTime(), new CosemDateTime()));
when(this.pushSetupAlarm.getCommunicationWindow()).thenReturn(testList);
final CosemObisCode code = new CosemObisCode(1, 2, 3, 4, 5, 6);
when(this.pushSetupAlarm.getPushObjectList()).thenReturn(Collections.singletonList(new CosemObjectDefinition(1, code, 2)));
final PushSetupAlarmDto result = this.pushSetupAlarmDtoConverter.convert(this.pushSetupAlarm, null, this.mappingContext);
assertThat(result.getCommunicationWindow()).isNotNull();
assertThat(result.getPushObjectList()).isNotNull();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.
the class PushSetupAlarmMappingTest method testPushSetupAlarmMappingWithLists.
// To test Mapping if lists contain values
@Test
public void testPushSetupAlarmMappingWithLists() {
// build test data
final CosemObisCode logicalName = new CosemObisCode(new int[] { 1, 2, 3, 4, 5, 6 });
final CosemObjectDefinition cosemObjectDefinition = new CosemObjectDefinition(1, logicalName, 2);
final CosemDateTime startTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
final CosemDateTime endTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
final WindowElement windowElement = new WindowElement(startTime, endTime);
final PushSetupAlarm pushSetupAlarm = new PushSetupAlarmBuilder().withFilledLists(cosemObjectDefinition, windowElement).build();
// actual mapping
final PushSetupAlarmDto pushSetupAlarmDto = this.configurationMapper.map(pushSetupAlarm, PushSetupAlarmDto.class);
// check values
this.checkCosemObisCodeMapping(pushSetupAlarm.getLogicalName(), pushSetupAlarmDto.getLogicalName());
this.checkSendDestinationAndMethodMapping(pushSetupAlarm, pushSetupAlarmDto);
this.checkIntegerMapping(pushSetupAlarm, pushSetupAlarmDto);
this.checkNonEmptyListMapping(pushSetupAlarm, pushSetupAlarmDto);
}
Aggregations