use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetPushSetupAlarmCommandExecutorTest method testSetBothSendDestinationAndPushObjectList.
@Test
void testSetBothSendDestinationAndPushObjectList() 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 pushSetupAlarmDto = new PushSetupAlarmDto.Builder().withSendDestinationAndMethod(SEND_DESTINATION_AND_METHOD).withPushObjectList(PUSH_OBJECT_LIST).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(2)).set(this.setParameterArgumentCaptor.capture());
final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
this.verifySendDestinationAndMethodParameter(setParameters.get(0));
this.verifyPushObjectListParameter(setParameters.get(1));
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetPushSetupAlarmCommandExecutorTest method testSetSendDestinationAndMethod.
@Test
void testSetSendDestinationAndMethod() 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);
final PushSetupAlarmDto pushSetupAlarmDto = new PushSetupAlarmDto.Builder().withSendDestinationAndMethod(SEND_DESTINATION_AND_METHOD).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.verifySendDestinationAndMethodParameter(setParameters.get(0));
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class ClearAlarmRegisterCommandExecutorTest method assertForTwoRegisters.
void assertForTwoRegisters(final String protocol, final String protocolVersion) throws ProtocolAdapterException, IOException {
final DlmsDevice dlmsDevice = new DlmsDevice(protocol + " " + protocolVersion + " device");
dlmsDevice.setProtocol(protocol, protocolVersion);
when(this.dlmsObjectConfigService.getAttributeAddress(dlmsDevice, DlmsObjectType.ALARM_REGISTER_1, null)).thenReturn(new AttributeAddress(InterfaceClass.DATA.id(), OBIS_CODE_ALARM_REGISTER_1, DataAttribute.VALUE.attributeId()));
when(this.dlmsObjectConfigService.findAttributeAddress(dlmsDevice, DlmsObjectType.ALARM_REGISTER_2, null)).thenReturn(Optional.of(new AttributeAddress(InterfaceClass.DATA.id(), OBIS_CODE_ALARM_REGISTER_2, DataAttribute.VALUE.attributeId())));
when(this.connectionManager.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.connectionManager.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(this.setParameterArgumentCaptor.capture())).thenReturn(AccessResultCode.SUCCESS);
this.executor.execute(this.connectionManager, dlmsDevice, this.dto, this.messageMetadata);
assertThat(this.setParameterArgumentCaptor.getAllValues()).hasSize(2);
SetParameter setParameter = this.setParameterArgumentCaptor.getAllValues().get(0);
assertThat(((Number) setParameter.getData().getValue()).longValue()).isEqualTo(ALARM_CODE);
final AttributeAddress attributeAddress = setParameter.getAttributeAddress();
assertThat(attributeAddress.getInstanceId().asDecimalString()).isEqualTo(OBIS_CODE_ALARM_REGISTER_1);
assertThat(attributeAddress.getClassId()).isEqualTo(CLASS_ID_CLEAR_ALARM_REGISTER);
setParameter = this.setParameterArgumentCaptor.getAllValues().get(1);
assertThat(((Number) setParameter.getData().getValue()).longValue()).isEqualTo(ALARM_CODE);
final AttributeAddress attributeAddress2 = setParameter.getAttributeAddress();
assertThat(attributeAddress2.getInstanceId().asDecimalString()).isEqualTo(OBIS_CODE_ALARM_REGISTER_2);
assertThat(attributeAddress2.getClassId()).isEqualTo(CLASS_ID_CLEAR_ALARM_REGISTER);
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class ClearAlarmRegisterCommandExecutorTest method assertForOneRegister.
void assertForOneRegister(final String protocol, final String protocolVersion) throws ProtocolAdapterException, IOException {
final DlmsDevice dlmsDevice = new DlmsDevice(protocol + " " + protocolVersion + " device");
dlmsDevice.setProtocol(protocol, protocolVersion);
when(this.dlmsObjectConfigService.getAttributeAddress(dlmsDevice, DlmsObjectType.ALARM_REGISTER_1, null)).thenReturn(new AttributeAddress(InterfaceClass.DATA.id(), OBIS_CODE_ALARM_REGISTER_1, DataAttribute.VALUE.attributeId()));
when(this.connectionManager.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.connectionManager.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(this.setParameterArgumentCaptor.capture())).thenReturn(AccessResultCode.SUCCESS);
this.executor.execute(this.connectionManager, dlmsDevice, this.dto, this.messageMetadata);
assertThat(this.setParameterArgumentCaptor.getAllValues()).hasSize(1);
final SetParameter setParameter = this.setParameterArgumentCaptor.getAllValues().get(0);
assertThat(((Number) setParameter.getData().getValue()).longValue()).isEqualTo(ALARM_CODE);
final AttributeAddress attributeAddress = setParameter.getAttributeAddress();
assertThat(attributeAddress.getInstanceId().asDecimalString()).isEqualTo(OBIS_CODE_ALARM_REGISTER_1);
assertThat(attributeAddress.getClassId()).isEqualTo(CLASS_ID_CLEAR_ALARM_REGISTER);
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectCommandExecutorSmr5IT method captureSetParameterBitStringData.
private BitString captureSetParameterBitStringData() throws IOException {
verify(this.dlmsConnection).set(this.setParameterArgumentCaptor.capture());
final SetParameter setParameter = this.setParameterArgumentCaptor.getValue();
final DataObject setParameterData = setParameter.getData();
return setParameterData.getValue();
}
Aggregations