use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto in project open-smart-grid-platform by OSGP.
the class FindMatchingChannelHelperTest method testNoAttributesInRequestAllInRetrievedValues.
@Test
public void testNoAttributesInRequestAllInRetrievedValues() {
final MbusChannelElementsDto requestData = new MbusChannelElementsDto(this.primaryAddress, this.deviceIdentification, this.noIdentificationNumber, this.noManufacturerIdentification, null, null);
final ChannelElementValuesDto channelValues = new ChannelElementValuesDto(this.channel, this.primaryAddress, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
assertThat(FindMatchingChannelHelper.matches(requestData, channelValues)).withFailMessage(requestData + " should match " + channelValues).isTrue();
assertThat(FindMatchingChannelHelper.matchesPartially(requestData, channelValues)).withFailMessage(requestData + " should match partially " + channelValues).isTrue();
final List<ChannelElementValuesDto> channelValuesList = Arrays.asList(channelValues);
assertThat(FindMatchingChannelHelper.bestMatch(requestData, channelValuesList)).withFailMessage(requestData + " should have a best match from " + channelValuesList).isNotNull();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto in project open-smart-grid-platform by OSGP.
the class FindMatchingChannelHelperTest method testAllAttributesInRequestOnlySomeInRetrievedValues.
@Test
public void testAllAttributesInRequestOnlySomeInRetrievedValues() {
final MbusChannelElementsDto requestData = new MbusChannelElementsDto(this.primaryAddress, this.deviceIdentification, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
final ChannelElementValuesDto channelValues = new ChannelElementValuesDto(this.channel, this.primaryAddress, this.identificationNumber, this.noManufacturerIdentification, this.noVersion, this.noDeviceTypeIdentification);
assertThat(FindMatchingChannelHelper.matches(requestData, channelValues)).withFailMessage(requestData + " should not match " + channelValues).isFalse();
assertThat(FindMatchingChannelHelper.matchesPartially(requestData, channelValues)).withFailMessage(requestData + " should match partially " + channelValues).isTrue();
final List<ChannelElementValuesDto> channelValuesList = Arrays.asList(channelValues);
assertThat(FindMatchingChannelHelper.bestMatch(requestData, channelValuesList)).withFailMessage(requestData + " should have a best match from " + channelValuesList).isNotNull();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto in project open-smart-grid-platform by OSGP.
the class FindMatchingChannelHelperTest method testAllAttributesInRequestOnlyPrimaryAddressInRetrievedValues.
@Test
public void testAllAttributesInRequestOnlyPrimaryAddressInRetrievedValues() {
final MbusChannelElementsDto requestData = new MbusChannelElementsDto(this.primaryAddress, this.deviceIdentification, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
final ChannelElementValuesDto channelValues = new ChannelElementValuesDto(this.channel, this.primaryAddress, this.noIdentificationNumber, this.noManufacturerIdentification, this.noVersion, this.noDeviceTypeIdentification);
assertThat(FindMatchingChannelHelper.matches(requestData, channelValues)).withFailMessage(requestData + " should not match " + channelValues).isFalse();
assertThat(FindMatchingChannelHelper.matchesPartially(requestData, channelValues)).withFailMessage(requestData + " should match partially " + channelValues).isTrue();
final List<ChannelElementValuesDto> channelValuesList = Arrays.asList(channelValues);
assertThat(FindMatchingChannelHelper.bestMatch(requestData, channelValuesList)).withFailMessage(requestData + " should have a best match from " + channelValuesList).isNotNull();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto in project open-smart-grid-platform by OSGP.
the class FindMatchingChannelHelperTest method testAllAttributesInRequestNoneInRetrievedValues.
@Test
public void testAllAttributesInRequestNoneInRetrievedValues() {
final MbusChannelElementsDto requestData = new MbusChannelElementsDto(this.primaryAddress, this.deviceIdentification, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
final ChannelElementValuesDto channelValues = new ChannelElementValuesDto(this.channel, this.noPrimaryAddress, this.noIdentificationNumber, this.noManufacturerIdentification, this.noVersion, this.noDeviceTypeIdentification);
assertThat(FindMatchingChannelHelper.matches(requestData, channelValues)).withFailMessage(requestData + " should not match " + channelValues).isFalse();
assertThat(FindMatchingChannelHelper.matchesPartially(requestData, channelValues)).withFailMessage(requestData + " should not match partially " + channelValues).isFalse();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsDto in project open-smart-grid-platform by OSGP.
the class FindMatchingChannelHelperTest method testValuesBestMatchingToRequestShouldBePicked.
@Test
public void testValuesBestMatchingToRequestShouldBePicked() {
final MbusChannelElementsDto requestData = new MbusChannelElementsDto(this.primaryAddress, this.deviceIdentification, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
final ChannelElementValuesDto channelValues = new ChannelElementValuesDto(this.channel, this.primaryAddress, this.identificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
final ChannelElementValuesDto otherChannelValues = new ChannelElementValuesDto(this.otherChannel, this.otherPrimaryAddress, this.otherIdentificationNumber, this.otherManufacturerIdentification, this.otherVersion, this.otherDeviceTypeIdentification);
final ChannelElementValuesDto partiallyMatchingChannelValues = new ChannelElementValuesDto((short) 3, (short) 3, this.noIdentificationNumber, this.manufacturerIdentification, this.version, this.deviceTypeIdentification);
assertThat(FindMatchingChannelHelper.matches(requestData, channelValues)).withFailMessage(requestData + " should match " + channelValues).isTrue();
assertThat(FindMatchingChannelHelper.matches(requestData, otherChannelValues)).withFailMessage(requestData + " should not match " + otherChannelValues).isFalse();
assertThat(FindMatchingChannelHelper.matches(requestData, partiallyMatchingChannelValues)).withFailMessage(requestData + " should not match " + partiallyMatchingChannelValues).isFalse();
assertThat(FindMatchingChannelHelper.matchesPartially(requestData, channelValues)).withFailMessage(requestData + " should match partially " + channelValues).isTrue();
assertThat(FindMatchingChannelHelper.matchesPartially(requestData, otherChannelValues)).withFailMessage(requestData + " should not match partially " + otherChannelValues).isFalse();
assertThat(FindMatchingChannelHelper.matchesPartially(requestData, partiallyMatchingChannelValues)).withFailMessage(requestData + " should match partially " + partiallyMatchingChannelValues).isTrue();
final List<ChannelElementValuesDto> channelValuesList = Arrays.asList(partiallyMatchingChannelValues, otherChannelValues, channelValues);
final ChannelElementValuesDto bestMatch = FindMatchingChannelHelper.bestMatch(requestData, channelValuesList);
assertThat(bestMatch).withFailMessage(requestData + " should have a best match from " + channelValuesList).isNotNull();
assertThat(bestMatch.getChannel()).withFailMessage("Channel for best match").isEqualTo(channelValues.getChannel());
}
Aggregations