use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectService method toWord.
private String toWord(final List<ConfigurationFlagDto> flags) throws ProtocolAdapterException {
final StringBuilder sb = this.createEmptyWord();
for (final ConfigurationFlagDto flag : flags) {
if (flag.isEnabled()) {
final ConfigurationFlagTypeDto flagType = flag.getConfigurationFlagType();
final Integer bitPosition = this.getBitPosition(flagType).orElseThrow(() -> new NotSupportedByProtocolException(String.format("ConfigurationFlagTypeDto %s not known for protocol", flagType)));
sb.setCharAt(bitPosition, '1');
}
}
return sb.toString();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectRequestMappingTest method checkSetConfigurationObjectRequestData.
// method to check values of all objects that are mapped when a
// SetConfigurationObjectRequest is mapped.
private void checkSetConfigurationObjectRequestData(final GprsOperationModeType gprsOperationModeType, final ConfigurationFlagType configurationFlagType, final ConfigurationFlags configurationFlags, final SetConfigurationObjectRequestDto setConfigurationObjectRequestDto) {
// check if SetConfigurationObjectRequesDataDto object is present
final SetConfigurationObjectRequestDataDto setConfigurationObjectRequestDataDto = setConfigurationObjectRequestDto.getSetConfigurationObjectRequestData();
assertThat(setConfigurationObjectRequestDto).isNotNull();
// check if ConfigurationObjectDto object is present
final ConfigurationObjectDto configurationObjectDto = setConfigurationObjectRequestDataDto.getConfigurationObject();
assertThat(configurationObjectDto).isNotNull();
// check the GprsOperationModeTypeDto value
final GprsOperationModeTypeDto gprsOperationModeTypeDto = configurationObjectDto.getGprsOperationMode();
assertThat(gprsOperationModeTypeDto.name()).isEqualTo(gprsOperationModeType.name());
// check if ConfigurationFlagsDto object is present, and if its List is
// of an equal size.
final ConfigurationFlagsDto configurationFlagsDto = configurationObjectDto.getConfigurationFlags();
assertThat(configurationFlagsDto).isNotNull();
assertThat(configurationFlagsDto.getFlags().size()).isEqualTo(configurationFlags.getFlags().size());
// check ConfigurationObjectFlagTypeDto value.
final ConfigurationFlagDto configurationFlagDto = configurationFlagsDto.getFlags().get(0);
final ConfigurationFlagTypeDto configurationFlagTypeDto = configurationFlagDto.getConfigurationFlagType();
assertThat(configurationFlagTypeDto.name()).isEqualTo(configurationFlagType.name());
}
Aggregations