use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium in project open-smart-grid-platform by OSGP.
the class DlmsObjectConfigServiceTest method testProfileWithOneMedium.
@Test
void testProfileWithOneMedium() {
// SETUP
final Integer channel = null;
final Medium filterMedium = Medium.ELECTRICITY;
final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
final DataObject accessParams = this.getAccessParams(selectedValues);
final SelectiveAccessDescription access = new SelectiveAccessDescription(1, accessParams);
final AttributeAddress expectedAddress = new AttributeAddress(this.profileE.getClassId(), this.profileE.getObisCodeAsString(), this.profileE.getDefaultAttributeId(), access);
// CALL
final Optional<AttributeAddressForProfile> attributeAddressForProfile = this.service.findAttributeAddressForProfile(this.device422, DlmsObjectType.INTERVAL_VALUES, channel, this.from, this.to, filterMedium);
// VERIFY
assertThat(attributeAddressForProfile).isPresent();
AttributeAddressAssert.is(attributeAddressForProfile.get().getAttributeAddress(), expectedAddress);
assertThat(attributeAddressForProfile.get().getSelectedObjects()).isEqualTo(this.captureObjectsE);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium in project open-smart-grid-platform by OSGP.
the class DlmsObjectConfigServiceTest method testProfileWithMediumCombinedAndNoFilterMedium.
@Test
void testProfileWithMediumCombinedAndNoFilterMedium() {
// SETUP
final Integer channel = 1;
final Medium filterMedium = null;
final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
final DataObject accessParams = this.getAccessParams(selectedValues);
final SelectiveAccessDescription access = new SelectiveAccessDescription(1, accessParams);
final AttributeAddress expectedAddress = new AttributeAddress(this.profileCombined.getClassId(), this.profileCombined.getObisCodeAsString(), this.profileCombined.getDefaultAttributeId(), access);
// CALL
final Optional<AttributeAddressForProfile> attributeAddressForProfile = this.service.findAttributeAddressForProfile(this.device422, DlmsObjectType.DAILY_LOAD_PROFILE, channel, this.from, this.to, filterMedium);
// VERIFY
assertThat(attributeAddressForProfile).isPresent();
AttributeAddressAssert.is(attributeAddressForProfile.get().getAttributeAddress(), expectedAddress);
assertThat(attributeAddressForProfile.get().getSelectedObjects()).isEqualTo(this.captureObjectsCombined);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium in project open-smart-grid-platform by OSGP.
the class DlmsObjectConfigServiceTest method testProfileWithMediumCombinedAndFilterMedium.
@Test
void testProfileWithMediumCombinedAndFilterMedium() {
// SETUP
final Integer channel = null;
final Medium filterMedium = Medium.ELECTRICITY;
final List<DlmsCaptureObject> expectedSelectedObjects = this.captureObjectsCombined.stream().filter(c -> !(c.getRelatedObject() instanceof DlmsRegister) || ((DlmsRegister) c.getRelatedObject()).getMedium() == filterMedium).collect(Collectors.toList());
final DataObject selectedValues = DataObject.newArrayData(expectedSelectedObjects.stream().map(o -> this.getDataObject(o.getRelatedObject())).collect(Collectors.toList()));
final DataObject accessParams = this.getAccessParams(selectedValues);
final SelectiveAccessDescription access = new SelectiveAccessDescription(1, accessParams);
final AttributeAddress expectedAddress = new AttributeAddress(this.profileCombined.getClassId(), this.profileCombined.getObisCodeAsString(), this.profileCombined.getDefaultAttributeId(), access);
// CALL
final Optional<AttributeAddressForProfile> attributeAddressForProfile = this.service.findAttributeAddressForProfile(this.device422, DlmsObjectType.DAILY_LOAD_PROFILE, channel, this.from, this.to, filterMedium);
// VERIFY
assertThat(attributeAddressForProfile).isPresent();
AttributeAddressAssert.is(attributeAddressForProfile.get().getAttributeAddress(), expectedAddress);
assertThat(attributeAddressForProfile.get().getSelectedObjects()).isEqualTo(expectedSelectedObjects);
}
Aggregations