use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException in project open-smart-grid-platform by OSGP.
the class GetActualPowerQualityCommandExecutorTest method testOtherReasonResult.
@Test
void testOtherReasonResult() throws ProtocolAdapterException {
this.actualPowerQualityRequestDto = new ActualPowerQualityRequestDto("PRIVATE");
final List<GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata> metadatas = GetActualPowerQualityCommandExecutor.getMetadatasPrivate();
doReturn(this.generateMockedResult(metadatas, AccessResultCode.OTHER_REASON)).when(this.dlmsHelper).getAndCheck(eq(this.conn), eq(this.dlmsDevice), eq("retrieve actual power quality"), any(AttributeAddress.class));
assertThatExceptionOfType(ProtocolAdapterException.class).isThrownBy(() -> {
new GetActualPowerQualityCommandExecutor(this.dlmsHelper).execute(this.conn, this.dlmsDevice, this.actualPowerQualityRequestDto, this.messageMetadata);
});
}
use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException in project open-smart-grid-platform by OSGP.
the class FirmwareFileTest method testMisfitMbusDeviceIdentificationNumber.
@Test
public void testMisfitMbusDeviceIdentificationNumber() throws IOException, ProtocolAdapterException {
final FirmwareFile firmwareFile = this.createPartialWildcardFirmwareFile("FFFF0000");
final String reversedWildcard = "0000FFFF";
final String identificationNumber = "00010000";
final String misfittingMbusDeviceIdentificationNumber = IdentificationNumber.fromTextualRepresentation(identificationNumber).getTextualRepresentation();
final Exception exception = assertThrows(ProtocolAdapterException.class, () -> {
firmwareFile.setMbusDeviceIdentificationNumber(misfittingMbusDeviceIdentificationNumber);
});
assertThat(exception).hasMessage("M-Bus Device Identification Number (%s) does not fit the range of Identification Numbers supported by this Firmware File (%s)", identificationNumber, reversedWildcard.toLowerCase());
}
use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException in project open-smart-grid-platform by OSGP.
the class DataObjectToOutageListConverter method convert.
public List<OutageDto> convert(final DataObject source) throws ProtocolAdapterException {
final List<OutageDto> eventList = new ArrayList<>();
if (source == null) {
throw new ProtocolAdapterException("DataObject should not be null");
}
final List<DataObject> dataObjects = source.getValue();
for (final DataObject dataObject : dataObjects) {
eventList.add(this.getOutageDto(dataObject));
}
return eventList;
}
use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException in project open-smart-grid-platform by OSGP.
the class GetConfigurationObjectServiceDsmr4Test method getConfigurationObjectFlagsNotBitString.
@Test
public void getConfigurationObjectFlagsNotBitString() throws ProtocolAdapterException {
// SETUP
final DataObject structure = mock(DataObject.class);
when(structure.isComplex()).thenReturn(true);
when(this.getResult.getResultData()).thenReturn(structure);
final List<DataObject> elements = new ArrayList<>();
final DataObject gprsMode = mock(DataObject.class);
when(gprsMode.isNumber()).thenReturn(true);
when(gprsMode.getValue()).thenReturn(42);
elements.add(gprsMode);
final DataObject flags = mock(DataObject.class);
// flags is not a BitString
when(flags.isBitString()).thenReturn(false);
elements.add(flags);
when(structure.getValue()).thenReturn(elements);
assertThatExceptionOfType(ProtocolAdapterException.class).isThrownBy(() -> {
// CALL
this.instance.getConfigurationObject(this.getResult);
});
}
use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException in project open-smart-grid-platform by OSGP.
the class GetConfigurationObjectServiceDsmr4Test method getConfigurationObjectGprsModeNull.
@Test
public void getConfigurationObjectGprsModeNull() throws ProtocolAdapterException {
// SETUP
final DataObject structure = mock(DataObject.class);
when(structure.isComplex()).thenReturn(true);
when(this.getResult.getResultData()).thenReturn(structure);
final List<DataObject> elements = new ArrayList<>();
// gprs mode is null
elements.add(null);
elements.add(null);
when(structure.getValue()).thenReturn(elements);
assertThatExceptionOfType(ProtocolAdapterException.class).isThrownBy(() -> {
// CALL
this.instance.getConfigurationObject(this.getResult);
});
}
Aggregations