Search in sources :

Example 1 with SystemEventTypeDto

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

the class SystemEventMappingTest method testWithNonEmptyValue.

// is not empty
@Test
void testWithNonEmptyValue() {
    // build test data
    final String deviceId = "deviceId";
    final SystemEventTypeDto systemEventType = SystemEventTypeDto.INVOCATION_COUNTER_THRESHOLD_REACHED;
    final Date timestamp = new Date();
    final String reason = "reason123";
    final SystemEventDto systemEventDto = new SystemEventDto(deviceId, systemEventType, timestamp, reason);
    // actual mapping
    final SystemEvent systemEvent = this.mapperFactory.getMapperFacade().map(systemEventDto, SystemEvent.class);
    // test mapping
    assertThat(systemEvent).isNotNull();
    assertThat(systemEvent.getDeviceIdentification()).isEqualTo(deviceId);
    assertThat(systemEvent.getSystemEventType().name()).isEqualTo(systemEventType.name());
    assertThat(systemEvent.getTimestamp()).isEqualTo(timestamp);
    assertThat(systemEvent.getReason()).isEqualTo(reason);
}
Also used : SystemEvent(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SystemEvent) SystemEventTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventTypeDto) SystemEventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 2 with SystemEventTypeDto

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

the class SystemEventMappingTest method testWithNullVariables.

// Test if mapping a SystemEvent object succeeds with null
// variables, although it
@Test
void testWithNullVariables() {
    // build test data
    final String deviceId = null;
    final SystemEventTypeDto systemEventType = null;
    final Date timestamp = null;
    final String reason = null;
    final SystemEventDto systemEventDto = new SystemEventDto(deviceId, systemEventType, timestamp, reason);
    // actual mapping
    final SystemEvent systemEvent = this.mapperFactory.getMapperFacade().map(systemEventDto, SystemEvent.class);
    // test mapping
    assertThat(systemEvent).isNotNull();
    assertThat(systemEvent.getDeviceIdentification()).isNull();
    assertThat(systemEvent.getSystemEventType()).isNull();
    assertThat(systemEvent.getTimestamp()).isNull();
    assertThat(systemEvent.getReason()).isNull();
}
Also used : SystemEvent(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SystemEvent) SystemEventTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventTypeDto) SystemEventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

Date (java.util.Date)2 Test (org.junit.jupiter.api.Test)2 SystemEvent (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SystemEvent)2 SystemEventDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto)2 SystemEventTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventTypeDto)2