Search in sources :

Example 6 with PushSetupAlarmDto

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

the class SetPushSetupAlarmCommandExecutorTest method testSetPushObjectList.

@Test
void testSetPushObjectList() throws ProtocolAdapterException, IOException {
    // SETUP
    when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
    when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
    when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
    when(this.dlmsConnection.get(any(AttributeAddress.class))).thenReturn(new GetResultImpl(DataObject.newNullData(), AccessResultCode.SUCCESS));
    final PushSetupAlarmDto.Builder pushSetupAlarmBuilder = new PushSetupAlarmDto.Builder();
    pushSetupAlarmBuilder.withPushObjectList(PUSH_OBJECT_LIST);
    final PushSetupAlarmDto pushSetupAlarmDto = pushSetupAlarmBuilder.build();
    // CALL
    final AccessResultCode resultCode = this.executor.execute(this.conn, this.DLMS_DEVICE, pushSetupAlarmDto, this.messageMetadata);
    // VERIFY
    assertThat(resultCode).isEqualTo(AccessResultCode.SUCCESS);
    verify(this.dlmsConnection, times(1)).set(this.setParameterArgumentCaptor.capture());
    final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
    this.verifyPushObjectListParameter(setParameters.get(0));
}
Also used : GetResultImpl(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl) AttributeAddress(org.openmuc.jdlms.AttributeAddress) AccessResultCode(org.openmuc.jdlms.AccessResultCode) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) SetParameter(org.openmuc.jdlms.SetParameter) Test(org.junit.jupiter.api.Test)

Example 7 with PushSetupAlarmDto

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

the class SetPushSetupAlarmRequestMessageProcessor method handleMessage.

@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
    this.assertRequestObjectType(PushSetupAlarmDto.class, requestObject);
    final PushSetupAlarmDto pushSetupAlarm = (PushSetupAlarmDto) requestObject;
    this.configurationService.setPushSetupAlarm(conn, device, pushSetupAlarm, messageMetadata);
    return null;
}
Also used : PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)

Example 8 with PushSetupAlarmDto

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

the class GetPushSetupAlarmCommandExecutor method execute.

@Override
public PushSetupAlarmDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final Void useless, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    conn.getDlmsMessageListener().setDescription("GetPushSetupAlarm, retrieve attributes: " + JdlmsObjectToStringUtil.describeAttributes(ATTRIBUTE_ADDRESSES));
    LOGGER.info("Retrieving Push Setup Alarm");
    final List<GetResult> getResultList = this.dlmsHelper.getWithList(conn, device, ATTRIBUTE_ADDRESSES);
    GetPushSetupCommandExecutor.checkResultList(getResultList, ATTRIBUTE_ADDRESSES);
    final PushSetupAlarmDto.Builder pushSetupAlarmBuilder = new PushSetupAlarmDto.Builder();
    pushSetupAlarmBuilder.withLogicalName(new CosemObisCodeDto(OBIS_CODE.bytes()));
    pushSetupAlarmBuilder.withPushObjectList(this.dlmsHelper.readListOfObjectDefinition(getResultList.get(INDEX_PUSH_OBJECT_LIST), "Push Object List"));
    pushSetupAlarmBuilder.withSendDestinationAndMethod(this.dlmsHelper.readSendDestinationAndMethod(getResultList.get(INDEX_SEND_DESTINATION_AND_METHOD), "Send Destination And Method"));
    pushSetupAlarmBuilder.withCommunicationWindow(this.dlmsHelper.readListOfWindowElement(getResultList.get(INDEX_COMMUNICATION_WINDOW), "Communication Window"));
    pushSetupAlarmBuilder.withRandomisationStartInterval(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_RANDOMISATION_START_INTERVAL), "Randomisation Start Interval").intValue());
    pushSetupAlarmBuilder.withNumberOfRetries(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_NUMBER_OF_RETRIES), "Number of Retries").intValue());
    pushSetupAlarmBuilder.withRepetitionDelay(this.dlmsHelper.readLongNotNull(getResultList.get(INDEX_REPETITION_DELAY), "Repetition Delay").intValue());
    return pushSetupAlarmBuilder.build();
}
Also used : GetResult(org.openmuc.jdlms.GetResult) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) CosemObisCodeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemObisCodeDto)

Example 9 with PushSetupAlarmDto

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

the class PushSetupAlarmDtoConverterTest method convertTest.

@Test
void convertTest() {
    final List<WindowElement> testList = Collections.singletonList(new WindowElement(new CosemDateTime(), new CosemDateTime()));
    when(this.pushSetupAlarm.getCommunicationWindow()).thenReturn(testList);
    final CosemObisCode code = new CosemObisCode(1, 2, 3, 4, 5, 6);
    when(this.pushSetupAlarm.getPushObjectList()).thenReturn(Collections.singletonList(new CosemObjectDefinition(1, code, 2)));
    final PushSetupAlarmDto result = this.pushSetupAlarmDtoConverter.convert(this.pushSetupAlarm, null, this.mappingContext);
    assertThat(result.getCommunicationWindow()).isNotNull();
    assertThat(result.getPushObjectList()).isNotNull();
}
Also used : WindowElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement) CosemObisCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) Test(org.junit.jupiter.api.Test)

Example 10 with PushSetupAlarmDto

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

the class PushSetupAlarmMappingTest method testPushSetupAlarmMappingWithLists.

// To test Mapping if lists contain values
@Test
public void testPushSetupAlarmMappingWithLists() {
    // build test data
    final CosemObisCode logicalName = new CosemObisCode(new int[] { 1, 2, 3, 4, 5, 6 });
    final CosemObjectDefinition cosemObjectDefinition = new CosemObjectDefinition(1, logicalName, 2);
    final CosemDateTime startTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
    final CosemDateTime endTime = new CosemDateTime(new CosemDate(2016, 3, 17), new CosemTime(11, 52, 45), 0, new ClockStatus(ClockStatus.STATUS_NOT_SPECIFIED));
    final WindowElement windowElement = new WindowElement(startTime, endTime);
    final PushSetupAlarm pushSetupAlarm = new PushSetupAlarmBuilder().withFilledLists(cosemObjectDefinition, windowElement).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);
    this.checkNonEmptyListMapping(pushSetupAlarm, pushSetupAlarmDto);
}
Also used : WindowElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement) CosemObisCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode) PushSetupAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm) ClockStatus(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus) CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) PushSetupAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) 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