Search in sources :

Example 1 with ConfigurationObject

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

the class SetConfigurationObjectRequestMappingTest method testSetConfigurationObjectRequestMappingComplete.

// Tests if mapping with a complete SetConfigurationObjectRequestData object
// succeeds
@Test
public void testSetConfigurationObjectRequestMappingComplete() {
    // build test data
    final String deviceIdentification = "nr1";
    final GprsOperationModeType gprsOperationModeType = GprsOperationModeType.ALWAYS_ON;
    final ConfigurationFlagType configurationFlagType = ConfigurationFlagType.DISCOVER_ON_OPEN_COVER;
    final ConfigurationFlag configurationFlag = new ConfigurationFlag(configurationFlagType, true);
    final List<ConfigurationFlag> configurationFlagList = new ArrayList<>();
    configurationFlagList.add(configurationFlag);
    final ConfigurationFlags configurationFlags = new ConfigurationFlags(configurationFlagList);
    final ConfigurationObject configurationObject = new ConfigurationObject(gprsOperationModeType, configurationFlags);
    final SetConfigurationObjectRequestData setConfigurationObjectRequestData = new SetConfigurationObjectRequestData(configurationObject);
    // actual mapping
    final SetConfigurationObjectRequest setConfigurationObjectRequest = new SetConfigurationObjectRequest(deviceIdentification, setConfigurationObjectRequestData);
    final SetConfigurationObjectRequestDto setConfigurationObjectRequestDto = this.configurationMapper.map(setConfigurationObjectRequest, SetConfigurationObjectRequestDto.class);
    // check values
    assertThat(setConfigurationObjectRequestDto).isNotNull();
    assertThat(setConfigurationObjectRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
    this.checkSetConfigurationObjectRequestData(gprsOperationModeType, configurationFlagType, configurationFlags, setConfigurationObjectRequestDto);
}
Also used : GprsOperationModeType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GprsOperationModeType) ConfigurationObject(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationObject) SetConfigurationObjectRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequest) ArrayList(java.util.ArrayList) ConfigurationFlag(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlag) SetConfigurationObjectRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDto) ConfigurationFlagType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlagType) ConfigurationFlags(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlags) SetConfigurationObjectRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequestData) Test(org.junit.jupiter.api.Test)

Example 2 with ConfigurationObject

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

the class SetConfigurationObjectRequestMappingTest method testMappingWithEmptyList.

// Test if mapping with ConfigurationFlags with an empty list succeeds.
@Test
public void testMappingWithEmptyList() {
    // build test data
    final String deviceIdentification = "nr1";
    final GprsOperationModeType gprsOperationModeType = GprsOperationModeType.ALWAYS_ON;
    final ConfigurationFlags configurationFlags = new ConfigurationFlags(new ArrayList<>());
    final ConfigurationObject configurationObject = new ConfigurationObject(gprsOperationModeType, configurationFlags);
    final SetConfigurationObjectRequestData setConfigurationObjectRequestData = new SetConfigurationObjectRequestData(configurationObject);
    // actual mapping
    final SetConfigurationObjectRequest setConfigurationObjectRequest = new SetConfigurationObjectRequest(deviceIdentification, setConfigurationObjectRequestData);
    final SetConfigurationObjectRequestDto setConfigurationObjectRequestDto = this.configurationMapper.map(setConfigurationObjectRequest, SetConfigurationObjectRequestDto.class);
    // check values
    assertThat(setConfigurationObjectRequestDto).isNotNull();
    assertThat(setConfigurationObjectRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
    final ConfigurationObjectDto configurationObjectDto = setConfigurationObjectRequestDto.getSetConfigurationObjectRequestData().getConfigurationObject();
    assertThat(configurationObjectDto).isNotNull();
    // Check if both configurationFlags instances have an empty list
    assertThat(configurationObjectDto.getConfigurationFlags().getFlags()).isEmpty();
}
Also used : GprsOperationModeType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GprsOperationModeType) ConfigurationObject(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationObject) SetConfigurationObjectRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequest) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) SetConfigurationObjectRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDto) ConfigurationFlags(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlags) SetConfigurationObjectRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequestData) Test(org.junit.jupiter.api.Test)

Example 3 with ConfigurationObject

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

the class GetConfigurationObjectResponseMappingTest method testMapConfigurationObjectDto.

@Test
public void testMapConfigurationObjectDto() {
    final ConfigurationObjectDto dto = this.makeConfigurationObjectDto();
    final ConfigurationObject result = this.mapper.map(dto, ConfigurationObject.class);
    assertThat(result).withFailMessage("mapping ConfigurationObjectDto should not return null").isNotNull();
    assertThat(result).withFailMessage("mapping ConfigurationObjectDto should return correct type").isOfAnyClassIn(ConfigurationObject.class);
}
Also used : ConfigurationObject(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationObject) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 ConfigurationObject (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationObject)3 ConfigurationFlags (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlags)2 GprsOperationModeType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GprsOperationModeType)2 SetConfigurationObjectRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequest)2 SetConfigurationObjectRequestData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequestData)2 ConfigurationObjectDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto)2 SetConfigurationObjectRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDto)2 ArrayList (java.util.ArrayList)1 ConfigurationFlag (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlag)1 ConfigurationFlagType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlagType)1