Search in sources :

Example 1 with SetKeysRequestData

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetKeysRequestData in project open-smart-grid-platform by OSGP.

the class KeySetMappingTest method testWithEmptyArrays.

/**
 * Tests the mapping of a KeySet object with empty byte arrays.
 */
@Test
public void testWithEmptyArrays() {
    // build test data
    final SetKeysRequestData keySetOriginal = new SetKeysRequestData();
    final byte[] authenticationKey = {};
    keySetOriginal.setAuthenticationKey(authenticationKey);
    final byte[] encryptionKey = {};
    keySetOriginal.setEncryptionKey(encryptionKey);
    // actual mapping
    final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetKeysRequestData keySetMapped = this.configurationMapper.map(keySetOriginal, org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetKeysRequestData.class);
    // check mapping
    assertThat(keySetMapped).isNotNull();
    assertThat(keySetMapped.getAuthenticationKey()).isNotNull();
    assertThat(keySetMapped.getAuthenticationKey().length == 0).isTrue();
    assertThat(keySetMapped.getEncryptionKey()).isNotNull();
    assertThat(keySetMapped.getEncryptionKey().length == 0).isTrue();
}
Also used : SetKeysRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetKeysRequestData) Test(org.junit.jupiter.api.Test)

Example 2 with SetKeysRequestData

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetKeysRequestData in project open-smart-grid-platform by OSGP.

the class KeySetMappingTest method testWithNullArrays.

/**
 * Tests the mapping of a KeySet object with byte arrays that are null.
 */
// Test mapping with null arrays
@Test
public void testWithNullArrays() {
    // build test data
    final SetKeysRequestData keySetOriginal = new SetKeysRequestData();
    final byte[] authenticationKey = null;
    keySetOriginal.setAuthenticationKey(authenticationKey);
    final byte[] encryptionKey = null;
    keySetOriginal.setEncryptionKey(encryptionKey);
    // actual mapping
    final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetKeysRequestData keySetMapped = this.configurationMapper.map(keySetOriginal, org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetKeysRequestData.class);
    // check mapping
    assertThat(keySetMapped).isNotNull();
    assertThat(keySetMapped.getAuthenticationKey()).isNull();
    assertThat(keySetMapped.getEncryptionKey()).isNull();
}
Also used : SetKeysRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetKeysRequestData) Test(org.junit.jupiter.api.Test)

Example 3 with SetKeysRequestData

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetKeysRequestData in project open-smart-grid-platform by OSGP.

the class KeySetMappingTest method testWithFilledArrays.

/**
 * Tests the mapping of a KeySet object with filled byte arrays.
 */
@Test
public void testWithFilledArrays() {
    // build test data
    final SetKeysRequestData keySetOriginal = new SetKeysRequestData();
    final byte[] authenticationKey = BYTE_ARRAY;
    keySetOriginal.setAuthenticationKey(authenticationKey);
    final byte[] encryptionKey = BYTE_ARRAY;
    keySetOriginal.setEncryptionKey(encryptionKey);
    // actual mapping
    final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetKeysRequestData keySetMapped = this.configurationMapper.map(keySetOriginal, org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetKeysRequestData.class);
    // check mapping
    assertThat(keySetMapped).isNotNull();
    this.checkMappingFilledArray(keySetMapped.getAuthenticationKey());
    this.checkMappingFilledArray(keySetMapped.getEncryptionKey());
}
Also used : SetKeysRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetKeysRequestData) Test(org.junit.jupiter.api.Test)

Example 4 with SetKeysRequestData

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetKeysRequestData in project open-smart-grid-platform by OSGP.

the class ReplaceKeysRequestFactory method fromParameterMap.

public static ReplaceKeysRequest fromParameterMap(final Map<String, String> requestParameters) {
    final ReplaceKeysRequest replaceKeysRequest = new ReplaceKeysRequest();
    replaceKeysRequest.setDeviceIdentification(getString(requestParameters, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    final SetKeysRequestData setKeysRequestData = SetKeysRequestDataFactory.fromParameterMap(requestParameters);
    replaceKeysRequest.setSetKeysRequestData(setKeysRequestData);
    return replaceKeysRequest;
}
Also used : ReplaceKeysRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ReplaceKeysRequest) SetKeysRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetKeysRequestData)

Example 5 with SetKeysRequestData

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetKeysRequestData in project open-smart-grid-platform by OSGP.

the class SetKeysRequestDataFactory method fromParameterMap.

public static SetKeysRequestData fromParameterMap(final Map<String, String> requestParameters) {
    final SetKeysRequestData setKeysRequestData = new SetKeysRequestData();
    setKeysRequestData.setAuthenticationKey(RequestFactoryHelper.hexDecodeDeviceKey(getSoapKey(requestParameters, PlatformKeys.KEY_DEVICE_AUTHENTICATIONKEY), PlatformKeys.KEY_DEVICE_AUTHENTICATIONKEY));
    setKeysRequestData.setEncryptionKey(RequestFactoryHelper.hexDecodeDeviceKey(getSoapKey(requestParameters, PlatformKeys.KEY_DEVICE_ENCRYPTIONKEY), PlatformKeys.KEY_DEVICE_ENCRYPTIONKEY));
    return setKeysRequestData;
}
Also used : SetKeysRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetKeysRequestData)

Aggregations

SetKeysRequestData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetKeysRequestData)5 Test (org.junit.jupiter.api.Test)3 ReplaceKeysRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ReplaceKeysRequest)1