Search in sources :

Example 1 with Medium

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);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) Medium(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium) AttributeAddress(org.openmuc.jdlms.AttributeAddress) Test(org.junit.jupiter.api.Test)

Example 2 with Medium

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);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) Medium(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium) AttributeAddress(org.openmuc.jdlms.AttributeAddress) Test(org.junit.jupiter.api.Test)

Example 3 with Medium

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);
}
Also used : Strictness(org.mockito.quality.Strictness) DlmsProfile(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) MockitoSettings(org.mockito.junit.jupiter.MockitoSettings) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject) Fail.fail(org.assertj.core.api.Fail.fail) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsRegister(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsRegister) ObisCode(org.openmuc.jdlms.ObisCode) DlmsClock(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsClock) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Medium(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium) ProfileCaptureTime(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.ProfileCaptureTime) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) AttributeAddressAssert(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.AttributeAddressAssert) Protocol(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) DlmsHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper) DateTime(org.joda.time.DateTime) DataObject(org.openmuc.jdlms.datatypes.DataObject) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) List(java.util.List) CommunicationMethod(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.CommunicationMethod) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) Optional(java.util.Optional) RegisterUnit(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.RegisterUnit) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Collections(java.util.Collections) DlmsGsmDiagnostic(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsGsmDiagnostic) DataObject(org.openmuc.jdlms.datatypes.DataObject) DlmsRegister(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsRegister) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) Medium(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium) AttributeAddress(org.openmuc.jdlms.AttributeAddress) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 AttributeAddress (org.openmuc.jdlms.AttributeAddress)3 SelectiveAccessDescription (org.openmuc.jdlms.SelectiveAccessDescription)3 DataObject (org.openmuc.jdlms.datatypes.DataObject)3 Medium (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium)3 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)1 Fail.fail (org.assertj.core.api.Fail.fail)1 DateTime (org.joda.time.DateTime)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1 Mock (org.mockito.Mock)1 Mockito.when (org.mockito.Mockito.when)1 MockitoExtension (org.mockito.junit.jupiter.MockitoExtension)1 MockitoSettings (org.mockito.junit.jupiter.MockitoSettings)1