Search in sources :

Example 1 with PushSetupSms

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

the class PushSetupSmsMappingTest method testPushSetupSmsMappingWithLists.

// To test Mapping if lists contain values
@Test
public void testPushSetupSmsMappingWithLists() {
    // 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 PushSetupSms pushSetupSms = new PushSetupSmsBuilder().withFilledLists(cosemObjectDefinition, windowElement).build();
    // actual mapping
    final PushSetupSmsDto pushSetupSmsDto = this.configurationMapper.map(pushSetupSms, PushSetupSmsDto.class);
    // check values
    this.checkCosemObisCodeMapping(pushSetupSms.getLogicalName(), pushSetupSmsDto.getLogicalName());
    this.checkSendDestinationAndMethodMapping(pushSetupSms, pushSetupSmsDto);
    this.checkIntegerMapping(pushSetupSms, pushSetupSmsDto);
    this.checkNonEmptyListMapping(pushSetupSms, pushSetupSmsDto);
}
Also used : WindowElement(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.WindowElement) CosemObisCode(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObisCode) ClockStatus(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClockStatus) PushSetupSms(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms) CosemTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemTime) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition) CosemDateTime(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDateTime) PushSetupSmsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto) CosemDate(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemDate) Test(org.junit.jupiter.api.Test)

Example 2 with PushSetupSms

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

the class PushSetupSmsMappingTest method testPushSetupSmsMappingNull.

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

Example 3 with PushSetupSms

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

the class PushSetupSmsConverter method convertTo.

@Override
public org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupSms convertTo(final PushSetupSms source, final Type<org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupSms> destinationType, final MappingContext context) {
    if (source == null) {
        return null;
    }
    if (!source.hasSendDestinationAndMethod()) {
        throw new IllegalArgumentException("Unable to map PushSetup Sms without SendDestinationAndMethod.");
    }
    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(":");
    final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupSms pushSetup = new org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupSms();
    pushSetup.setHost(hostAndPort[0]);
    pushSetup.setPort(new BigInteger(hostAndPort[1]));
    return pushSetup;
}
Also used : SendDestinationAndMethod(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SendDestinationAndMethod) PushSetupSms(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms) BigInteger(java.math.BigInteger)

Example 4 with PushSetupSms

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

the class SetPushSetupSmsRequestMessageProcessor method handleMessage.

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

Example 5 with PushSetupSms

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

the class PushSetupSmsMappingTest method testPushSetupSmsMappingWithEmptyLists.

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

Aggregations

PushSetupSms (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupSms)6 Test (org.junit.jupiter.api.Test)3 PushSetupSmsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupSmsDto)3 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)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