Search in sources :

Example 1 with PushSetupAlarm

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm 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 2 with PushSetupAlarm

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm 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 3 with PushSetupAlarm

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm in project open-smart-grid-platform by OSGP.

the class PushSetupAlarmConverter method convertTo.

@Override
public org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm convertTo(final PushSetupAlarm source, final Type<org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm> destinationType, final MappingContext context) {
    if (source == null) {
        return null;
    }
    final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm pushSetupAlarm = new org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm();
    if (source.hasSendDestinationAndMethod()) {
        final SendDestinationAndMethod sendDestinationAndMethod = source.getSendDestinationAndMethod();
        final String destination = sendDestinationAndMethod.getDestination();
        if (!destination.matches("\\S++:\\d++")) {
            throw new IllegalArgumentException("Unable to parse destination as \"<host>:<port>\": " + destination);
        }
        final String[] hostAndPort = destination.split(":");
        pushSetupAlarm.setHost(hostAndPort[0]);
        pushSetupAlarm.setPort(new BigInteger(hostAndPort[1]));
    }
    if (source.hasPushObjectList()) {
        final List<PushObject> convertedPushObjectList = this.mapperFacade.mapAsList(source.getPushObjectList(), PushObject.class);
        pushSetupAlarm.getPushObjectList().addAll(convertedPushObjectList);
    }
    return pushSetupAlarm;
}
Also used : SendDestinationAndMethod(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SendDestinationAndMethod) PushSetupAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm) PushObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushObject) BigInteger(java.math.BigInteger)

Example 4 with PushSetupAlarm

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm in project open-smart-grid-platform by OSGP.

the class SetPushSetupAlarmRequestMessageProcessor method handleMessage.

@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final Object dataObject) throws FunctionalException {
    final PushSetupAlarm pushSetupAlarm = (PushSetupAlarm) dataObject;
    this.configurationService.setPushSetupAlarm(deviceMessageMetadata, pushSetupAlarm);
}
Also used : PushSetupAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm)

Example 5 with PushSetupAlarm

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm in project open-smart-grid-platform by OSGP.

the class PushSetupAlarmConverter method convertFrom.

@Override
public PushSetupAlarm convertFrom(final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm source, final Type<PushSetupAlarm> destinationType, final MappingContext context) {
    if (source == null) {
        return null;
    }
    final PushSetupAlarm.Builder builder = new PushSetupAlarm.Builder();
    if (source.getHost() != null && source.getPort() != null) {
        final String destination = source.getHost() + ":" + source.getPort();
        final SendDestinationAndMethod sendDestinationAndMethod = new SendDestinationAndMethod(TransportServiceType.TCP, destination, MessageType.A_XDR_ENCODED_X_DLMS_APDU);
        builder.withSendDestinationAndMethod(sendDestinationAndMethod);
    }
    final List<PushObject> sourcePushObjects = source.getPushObjectList();
    if (sourcePushObjects != null) {
        final List<CosemObjectDefinition> convertedPushObjectList = this.mapperFacade.mapAsList(source.getPushObjectList(), CosemObjectDefinition.class);
        builder.withPushObjectList(convertedPushObjectList);
    }
    return builder.build();
}
Also used : SendDestinationAndMethod(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SendDestinationAndMethod) PushSetupAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm) PushObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushObject) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)

Aggregations

PushSetupAlarm (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm)6 Test (org.junit.jupiter.api.Test)3 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)3 PushSetupAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)3 PushObject (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushObject)2 SendDestinationAndMethod (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SendDestinationAndMethod)2 WindowElement (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 ClockStatus (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus)1 CosemDate (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate)1 CosemDateTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime)1 CosemObisCode (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode)1 CosemTime (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime)1