Search in sources :

Example 1 with SetKeysRequestData

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

the class SetKeysRequestMappingTest method testWithEmptyArrays.

// To test mapping when arrays are empty
@Test
public void testWithEmptyArrays() {
    // build test data
    final byte[] authenthicationKey = new byte[1];
    final byte[] encryptionKey = new byte[1];
    final SetKeysRequestData keySet = new SetKeysRequestData(authenthicationKey, encryptionKey);
    // actual mapping
    final SetKeysRequestDto keySetDto = this.configurationMapper.map(keySet, SetKeysRequestDto.class);
    // check if mapping succeeded
    assertThat(keySetDto).isNotNull();
    assertThat(keySetDto.getAuthenticationKey()).isNotNull();
    assertThat(keySetDto.getEncryptionKey()).isNotNull();
    assertThat(keySetDto.getAuthenticationKey().length).isEqualTo(keySet.getAuthenticationKey().length);
    assertThat(keySet.getEncryptionKey().length).isEqualTo(keySetDto.getEncryptionKey().length);
}
Also used : SetKeysRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetKeysRequestDto) SetKeysRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetKeysRequestData) Test(org.junit.jupiter.api.Test)

Example 2 with SetKeysRequestData

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

the class SetKeysRequestMappingTest method testWithNullArrays.

// To test mapping when arrays are null
@Test
public void testWithNullArrays() {
    // build test data
    final byte[] authenthicationKey = null;
    final byte[] encryptionKey = null;
    final SetKeysRequestData keySet = new SetKeysRequestData(authenthicationKey, encryptionKey);
    // actual mapping
    final SetKeysRequestDto keySetDto = this.configurationMapper.map(keySet, SetKeysRequestDto.class);
    // check if mapping succeeded
    assertThat(keySetDto).isNotNull();
    assertThat(keySetDto.getAuthenticationKey()).isNull();
    assertThat(keySetDto.getEncryptionKey()).isNull();
}
Also used : SetKeysRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetKeysRequestDto) SetKeysRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetKeysRequestData) Test(org.junit.jupiter.api.Test)

Example 3 with SetKeysRequestData

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

the class SetKeysRequestMappingTest method testWithArrays.

// To test mapping when arrays hold a value
@Test
public void testWithArrays() {
    // build test data
    final byte[] authenthicationKey = { 1 };
    final byte[] encryptionKey = { 1 };
    final SetKeysRequestData keySet = new SetKeysRequestData(authenthicationKey, encryptionKey);
    // actual mapping
    final SetKeysRequestDto keySetDto = this.configurationMapper.map(keySet, SetKeysRequestDto.class);
    // check if mapping succeeded
    assertThat(keySetDto).isNotNull();
    assertThat(keySetDto.getAuthenticationKey()).isNotNull();
    assertThat(keySetDto.getEncryptionKey()).isNotNull();
    assertThat(keySetDto.getAuthenticationKey().length).isEqualTo(keySet.getAuthenticationKey().length);
    assertThat(keySet.getEncryptionKey().length).isEqualTo(keySetDto.getEncryptionKey().length);
    assertThat(keySetDto.getAuthenticationKey()[0]).isEqualTo(keySet.getAuthenticationKey()[0]);
    assertThat(keySetDto.getEncryptionKey()[0]).isEqualTo(keySet.getEncryptionKey()[0]);
}
Also used : SetKeysRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetKeysRequestDto) SetKeysRequestData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetKeysRequestData) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 SetKeysRequestData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetKeysRequestData)3 SetKeysRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetKeysRequestDto)3