Search in sources :

Example 1 with GetPowerQualityProfileRequestData

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

the class GetPowerQualityProfileDataMapperTest method shouldConvertValueObjectToDto.

@Test
public void shouldConvertValueObjectToDto() {
    final GetPowerQualityProfileRequestData source = new GetPowerQualityProfileRequestData("PUBLIC", BEGIN_DATE.toDate(), END_DATE.toDate());
    final GetPowerQualityProfileRequestDataDto result = this.mapper.map(source, GetPowerQualityProfileRequestDataDto.class);
    assertThat(result.getBeginDate()).withFailMessage(MAPPED_FIELD_VALUE_MESSAGE).isEqualTo(BEGIN_DATE.toDate());
    assertThat(result.getEndDate()).withFailMessage(MAPPED_FIELD_VALUE_MESSAGE).isEqualTo(END_DATE.toDate());
}
Also used : GetPowerQualityProfileRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto) GetPowerQualityProfileRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileRequestData) Test(org.junit.jupiter.api.Test)

Example 2 with GetPowerQualityProfileRequestData

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

the class GetGetPowerQualityProfileRequestMappingTest method shouldConvertGetPowerQualityProfileRequest.

@Test
public void shouldConvertGetPowerQualityProfileRequest() {
    final GetPowerQualityProfileRequest source = this.makeRequest();
    final GetPowerQualityProfileRequestData result = this.mapper.map(source, GetPowerQualityProfileRequestData.class);
    assertThat(result).as(MAPPED_OBJECT_NULL_MESSAGE).isNotNull();
    assertThat(result.getProfileType()).as(MAPPED_FIELD_VALUE_MESSAGE).isEqualTo(source.getProfileType());
    assertThat(this.toGregorianCalendar(new DateTime(result.getBeginDate()))).as(MAPPED_FIELD_VALUE_MESSAGE).isEqualTo(source.getBeginDate());
    assertThat(this.toGregorianCalendar(new DateTime(result.getEndDate()))).as(MAPPED_FIELD_VALUE_MESSAGE).isEqualTo(source.getEndDate());
}
Also used : GetPowerQualityProfileRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileRequestData) GetPowerQualityProfileRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetPowerQualityProfileRequest) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test)

Example 3 with GetPowerQualityProfileRequestData

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

the class GetPowerQualityProfileRequestDataConverter method convert.

@Override
public GetPowerQualityProfileRequestData convert(final GetPowerQualityProfileRequest source, final Type<? extends GetPowerQualityProfileRequestData> destinationType, final MappingContext context) {
    final GetPowerQualityProfileRequestData data = new GetPowerQualityProfileRequestData(source.getProfileType(), source.getBeginDate().toGregorianCalendar().getTime(), source.getEndDate().toGregorianCalendar().getTime());
    if (source.getSelectedValues() != null) {
        final List<CaptureObjectDefinition> captureObjectDefinitions = source.getSelectedValues().getCaptureObject();
        captureObjectDefinitions.forEach(cod -> data.getSelectedValues().add(this.convert(cod)));
    }
    return data;
}
Also used : CaptureObjectDefinition(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.CaptureObjectDefinition) GetPowerQualityProfileRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileRequestData)

Example 4 with GetPowerQualityProfileRequestData

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

the class GetPowerQualityProfileRequestMapperTest method testGetPowerQualityProfileRequest.

@Test
public void testGetPowerQualityProfileRequest() {
    final GetPowerQualityProfileRequest getPowerQualityProfileRequest = this.makeRequest();
    final GetPowerQualityProfileRequestData result = this.mapper.map(getPowerQualityProfileRequest, GetPowerQualityProfileRequestData.class);
    assertThat(result).withFailMessage("mapping GetPowerQualityProfileRequest should not return null").isNotNull();
    assertThat(result).withFailMessage("mapping GetPowerQualityProfileRequest should return correct type").isOfAnyClassIn(GetPowerQualityProfileRequestData.class);
    assertThat(result.getBeginDate()).withFailMessage(MAPPED_VALUE_MESSAGE).isEqualTo(DATE);
    assertThat(result.getEndDate()).withFailMessage(MAPPED_VALUE_MESSAGE).isEqualTo(DATE);
}
Also used : GetPowerQualityProfileRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileRequestData) GetPowerQualityProfileRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileRequest) Test(org.junit.jupiter.api.Test)

Aggregations

GetPowerQualityProfileRequestData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileRequestData)4 Test (org.junit.jupiter.api.Test)3 DateTime (org.joda.time.DateTime)1 GetPowerQualityProfileRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetPowerQualityProfileRequest)1 CaptureObjectDefinition (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.CaptureObjectDefinition)1 GetPowerQualityProfileRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileRequest)1 GetPowerQualityProfileRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto)1