Search in sources :

Example 1 with PushSetupAlarmDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.

the class PushSetupAlarmDtoConverterTest method convertTestWithEmptyLists.

@Test
void convertTestWithEmptyLists() {
    when(this.pushSetupAlarm.getCommunicationWindow()).thenReturn(null);
    when(this.pushSetupAlarm.getPushObjectList()).thenReturn(null);
    final PushSetupAlarmDto result = this.pushSetupAlarmDtoConverter.convert(this.pushSetupAlarm, null, this.mappingContext);
    assertThat(result.getCommunicationWindow()).isNull();
    assertThat(result.getPushObjectList()).isNull();
}
Also used : PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) Test(org.junit.jupiter.api.Test)

Example 2 with PushSetupAlarmDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.

the class ConfigurationService method setPushSetupAlarm.

public void setPushSetupAlarm(final MessageMetadata messageMetadata, final PushSetupAlarm pushSetupAlarm) throws FunctionalException {
    log.info("setPushSetupAlarm for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
    final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
    final PushSetupAlarmDto requestDto = this.configurationMapper.map(pushSetupAlarm, PushSetupAlarmDto.class);
    this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
Also used : SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)

Example 3 with PushSetupAlarmDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.

the class PushSetupAlarmMappingTest method testPushSetupAlarmMappingNull.

// To test if a PushSetupAlarm can be mapped if instance variables are null.
@Test
public void testPushSetupAlarmMappingNull() {
    // build test data
    final PushSetupAlarm pushSetupAlarm = new PushSetupAlarmBuilder().withNullValues().build();
    // actual mapping
    final PushSetupAlarmDto pushSetupAlarmDto = this.configurationMapper.map(pushSetupAlarm, PushSetupAlarmDto.class);
    // check values
    assertThat(pushSetupAlarmDto).isNotNull();
    assertThat(pushSetupAlarmDto.getLogicalName()).isNull();
    assertThat(pushSetupAlarmDto.getPushObjectList()).isNull();
    assertThat(pushSetupAlarmDto.getSendDestinationAndMethod()).isNull();
    assertThat(pushSetupAlarmDto.getCommunicationWindow()).isNull();
    assertThat(pushSetupAlarmDto.getRandomisationStartInterval()).isNull();
    assertThat(pushSetupAlarmDto.getNumberOfRetries()).isNull();
    assertThat(pushSetupAlarmDto.getRepetitionDelay()).isNull();
}
Also used : PushSetupAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) Test(org.junit.jupiter.api.Test)

Example 4 with PushSetupAlarmDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.

the class PushSetupAlarmMappingTest method testPushSetupAlarmMappingWithEmptyLists.

// To test if a PushSetupAlarm can be mapped if instance variables are
// initialized and lists are empty.
@Test
public void testPushSetupAlarmMappingWithEmptyLists() {
    // build test data
    final ArrayList<CosemObjectDefinition> pushObjectList = new ArrayList<>();
    final ArrayList<WindowElement> communicationWindow = new ArrayList<>();
    final PushSetupAlarm pushSetupAlarm = new PushSetupAlarmBuilder().withEmptyLists(pushObjectList, communicationWindow).build();
    // actual mapping
    final PushSetupAlarmDto pushSetupAlarmDto = this.configurationMapper.map(pushSetupAlarm, PushSetupAlarmDto.class);
    // check values
    this.checkCosemObisCodeMapping(pushSetupAlarm.getLogicalName(), pushSetupAlarmDto.getLogicalName());
    this.checkSendDestinationAndMethodMapping(pushSetupAlarm, pushSetupAlarmDto);
    this.checkIntegerMapping(pushSetupAlarm, pushSetupAlarmDto);
    assertThat(pushSetupAlarmDto.getPushObjectList()).isNotNull();
    assertThat(pushSetupAlarmDto.getCommunicationWindow()).isNotNull();
}
Also used : WindowElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement) PushSetupAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm) ArrayList(java.util.ArrayList) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) Test(org.junit.jupiter.api.Test)

Example 5 with PushSetupAlarmDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto in project open-smart-grid-platform by OSGP.

the class SetPushSetupAlarmCommandExecutorTest method testSetWithUnsupportedFieldsSet.

@Test
void testSetWithUnsupportedFieldsSet() {
    // SETUP
    final PushSetupAlarmDto pushSetupAlarmDto = new PushSetupAlarmDto.Builder().withCommunicationWindow(new ArrayList<>()).build();
    // CALL
    final Throwable thrown = catchThrowable(() -> {
        this.executor.execute(this.conn, this.DLMS_DEVICE, pushSetupAlarmDto, this.messageMetadata);
    });
    // VERIFY
    assertThat(thrown).isInstanceOf(ProtocolAdapterException.class);
}
Also used : ArrayList(java.util.ArrayList) AssertionsForClassTypes.catchThrowable(org.assertj.core.api.AssertionsForClassTypes.catchThrowable) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) Test(org.junit.jupiter.api.Test)

Aggregations

PushSetupAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)13 Test (org.junit.jupiter.api.Test)10 AccessResultCode (org.openmuc.jdlms.AccessResultCode)3 AttributeAddress (org.openmuc.jdlms.AttributeAddress)3 SetParameter (org.openmuc.jdlms.SetParameter)3 GetResultImpl (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)3 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)3 PushSetupAlarm (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm)3 WindowElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement)3 ArrayList (java.util.ArrayList)2 AssertionsForClassTypes.catchThrowable (org.assertj.core.api.AssertionsForClassTypes.catchThrowable)2 CosemDateTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime)2 CosemObisCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode)2 GetResult (org.openmuc.jdlms.GetResult)1 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)1 ClockStatus (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus)1 CosemDate (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate)1 CosemTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime)1 CosemObisCodeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)1