IeQualityConverter extends CustomConverter<IeQuality, BitmaskMeasurementElementDto> { @Override public BitmaskMeasurementElementDto convert(final IeQuality source, final Type<? extends BitmaskMeasurementElementDto> destinationType, final MappingContext mappingContext) { int value = 0; value += source.isOverflow() ? BIT_OVERFLOW : 0; value += source.isBlocked() ? BIT_BLOCKED : 0; value += source.isSubstituted() ? BIT_SUBSTITUTED : 0; value += source.isNotTopical() ? BIT_NOT_TOPICAL : 0; value += source.isInvalid() ? BIT_INVALID : 0; return new BitmaskMeasurementElementDto((byte) value); }  @Override BitmaskMeasurementElementDto convert(final IeQuality source,
            final Type<? extends BitmaskMeasurementElementDto> destinationType, final MappingContext mappingContext);  }
@Test public void shouldConvertIeQualityNoneToByte() { final BitmaskMeasurementElementDto expected = new BitmaskMeasurementElementDto((byte) IE_QUALITY_NONE); final IeQuality source = new IeQuality(false, false, false, false, false); final BitmaskMeasurementElementDto actual = this.converter.convert(source, null, null); assertThat(actual).isEqualTo(expected); }
@Test public void shouldConvertIeQualityOverflowToByte() { final BitmaskMeasurementElementDto expected = new BitmaskMeasurementElementDto((byte) IE_QUALITY_OVERFLOW); final IeQuality source = new IeQuality(true, false, false, false, false); final BitmaskMeasurementElementDto actual = this.converter.convert(source, null, null); assertThat(actual).isEqualTo(expected); }
@Test public void shouldConvertIeQualityBlockedToByte() { final BitmaskMeasurementElementDto expected = new BitmaskMeasurementElementDto((byte) IE_QUALITY_BLOCKED); final IeQuality source = new IeQuality(false, true, false, false, false); final BitmaskMeasurementElementDto actual = this.converter.convert(source, null, null); assertThat(actual).isEqualTo(expected); }
@Test public void shouldConvertIeQualitySubstitutedToByte() { final BitmaskMeasurementElementDto expected = new BitmaskMeasurementElementDto((byte) IE_QUALITY_SUBSTITUTED); final IeQuality source = new IeQuality(false, false, true, false, false); final BitmaskMeasurementElementDto actual = this.converter.convert(source, null, null); assertThat(actual).isEqualTo(expected); }
@Test public void shouldConvertIeQualityNotTopicalToByte() { final BitmaskMeasurementElementDto expected = new BitmaskMeasurementElementDto((byte) IE_QUALITY_NOT_TOPICAL); final IeQuality source = new IeQuality(false, false, false, true, false); final BitmaskMeasurementElementDto actual = this.converter.convert(source, null, null); assertThat(actual).isEqualTo(expected); }
@Test public void shouldConvertIeQualityInvalidToByte() { final BitmaskMeasurementElementDto expected = new BitmaskMeasurementElementDto((byte) IE_QUALITY_INVALID); final IeQuality source = new IeQuality(false, false, false, false, true); final BitmaskMeasurementElementDto actual = this.converter.convert(source, null, null); assertThat(actual).isEqualTo(expected); }
@Test public void shouldConvertIeQualityAllToByte() { final BitmaskMeasurementElementDto expected = new BitmaskMeasurementElementDto((byte) IE_QUALITY_ALL); final IeQuality source = new IeQuality(true, true, true, true, true); final BitmaskMeasurementElementDto actual = this.converter.convert(source, null, null); assertThat(actual).isEqualTo(expected); }