Search in sources :

Example 1 with ActivateSecretsRequest

use of org.opensmartgridplatform.ws.schema.core.secret.management.ActivateSecretsRequest in project open-smart-grid-platform by OSGP.

the class SecretManagementService method activateNewKeys.

public void activateNewKeys(final MessageMetadata messageMetadata, final String deviceIdentification, final List<SecurityKeyType> keyTypes) {
    final ActivateSecretsRequest request = new ActivateSecretsRequest();
    request.setDeviceId(deviceIdentification);
    request.setSecretTypes(new SecretTypes());
    final List<SecretType> secretTypeList = request.getSecretTypes().getSecretType();
    keyTypes.forEach(kt -> secretTypeList.add(kt.toSecretType()));
    this.secretManagementClient.activateSecretsRequest(messageMetadata, request);
}
Also used : SecretType(org.opensmartgridplatform.ws.schema.core.secret.management.SecretType) SecretTypes(org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes) ActivateSecretsRequest(org.opensmartgridplatform.ws.schema.core.secret.management.ActivateSecretsRequest)

Example 2 with ActivateSecretsRequest

use of org.opensmartgridplatform.ws.schema.core.secret.management.ActivateSecretsRequest in project open-smart-grid-platform by OSGP.

the class SecretManagementServiceTest method testActivateKeys.

@Test
public void testActivateKeys() throws ProtocolAdapterException {
    final List<SecurityKeyType> keyTypes = Arrays.asList(KEY_TYPE);
    final ArgumentCaptor<ActivateSecretsRequest> activateSecretsCaptor = ArgumentCaptor.forClass(ActivateSecretsRequest.class);
    // EXECUTE
    this.secretManagementTestService.activateNewKeys(messageMetadata, DEVICE_IDENTIFICATION, keyTypes);
    // ASSERT
    verify(this.secretManagementClient).activateSecretsRequest(same(messageMetadata), activateSecretsCaptor.capture());
    final ActivateSecretsRequest capturedArgument = activateSecretsCaptor.getValue();
    assertThat(capturedArgument.getDeviceId()).isEqualTo(DEVICE_IDENTIFICATION);
    assertThat(capturedArgument.getSecretTypes().getSecretType().get(0)).isEqualTo(KEY_TYPE.toSecretType());
}
Also used : ActivateSecretsRequest(org.opensmartgridplatform.ws.schema.core.secret.management.ActivateSecretsRequest) SecurityKeyType(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.SecurityKeyType) Test(org.junit.jupiter.api.Test)

Aggregations

ActivateSecretsRequest (org.opensmartgridplatform.ws.schema.core.secret.management.ActivateSecretsRequest)2 Test (org.junit.jupiter.api.Test)1 SecurityKeyType (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.SecurityKeyType)1 SecretType (org.opensmartgridplatform.ws.schema.core.secret.management.SecretType)1 SecretTypes (org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes)1