-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SMHE-2164: Add SetSpecificAttributeValue
SMHE-2164: Set watchdog value
- Loading branch information
Showing
31 changed files
with
1,072 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...artmetering/glue/steps/ws/smartmetering/smartmeteringadhoc/SetSpecificAttributeValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// SPDX-FileCopyrightText: Copyright Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.opensmartgridplatform.cucumber.platform.smartmetering.glue.steps.ws.smartmetering.smartmeteringadhoc; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
import java.util.Map; | ||
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.SetSpecificAttributeValueAsyncRequest; | ||
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.SetSpecificAttributeValueAsyncResponse; | ||
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.SetSpecificAttributeValueRequest; | ||
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.SetSpecificAttributeValueResponse; | ||
import org.opensmartgridplatform.cucumber.core.ScenarioContext; | ||
import org.opensmartgridplatform.cucumber.platform.PlatformKeys; | ||
import org.opensmartgridplatform.cucumber.platform.smartmetering.PlatformSmartmeteringKeys; | ||
import org.opensmartgridplatform.cucumber.platform.smartmetering.support.ws.smartmetering.adhoc.SetSpecificAttributeValueRequestFactory; | ||
import org.opensmartgridplatform.cucumber.platform.smartmetering.support.ws.smartmetering.adhoc.SmartMeteringAdHocRequestClient; | ||
import org.opensmartgridplatform.cucumber.platform.smartmetering.support.ws.smartmetering.adhoc.SmartMeteringAdHocResponseClient; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
public class SetSpecificAttributeValue { | ||
|
||
@Autowired | ||
private SmartMeteringAdHocRequestClient< | ||
SetSpecificAttributeValueAsyncResponse, SetSpecificAttributeValueRequest> | ||
requestClient; | ||
|
||
@Autowired | ||
private SmartMeteringAdHocResponseClient< | ||
SetSpecificAttributeValueResponse, SetSpecificAttributeValueAsyncRequest> | ||
responseClient; | ||
|
||
@When("^the Set Specific Attribute Value request is received$") | ||
public void whenTheSetSpecificAttributeValueRequestIsReceived(final Map<String, String> settings) | ||
throws Throwable { | ||
|
||
final SetSpecificAttributeValueRequest request = | ||
SetSpecificAttributeValueRequestFactory.fromParameterMap(settings); | ||
final SetSpecificAttributeValueAsyncResponse asyncResponse = | ||
this.requestClient.doRequest(request); | ||
|
||
assertThat(asyncResponse).as("AsyncResponse should not be null").isNotNull(); | ||
ScenarioContext.current() | ||
.put(PlatformKeys.KEY_CORRELATION_UID, asyncResponse.getCorrelationUid()); | ||
} | ||
|
||
@Then("^the Set Specific Attribute Value response should be returned$") | ||
public void thenTheValueShouldBeSetOnTheDevice(final Map<String, String> settings) | ||
throws Throwable { | ||
|
||
final SetSpecificAttributeValueAsyncRequest asyncRequest = | ||
SetSpecificAttributeValueRequestFactory.fromScenarioContext(); | ||
final SetSpecificAttributeValueResponse response = | ||
this.responseClient.getResponse(asyncRequest); | ||
|
||
assertThat(response.getResult().name()) | ||
.as("Result is not as expected.") | ||
.isEqualTo(settings.get(PlatformSmartmeteringKeys.RESULT)); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...smartmetering/support/ws/smartmetering/adhoc/SetSpecificAttributeValueRequestFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-FileCopyrightText: Copyright Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.opensmartgridplatform.cucumber.platform.smartmetering.support.ws.smartmetering.adhoc; | ||
|
||
import java.math.BigInteger; | ||
import java.util.Map; | ||
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.AllowedObjectType; | ||
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.SetSpecificAttributeValueAsyncRequest; | ||
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.SetSpecificAttributeValueRequest; | ||
import org.opensmartgridplatform.cucumber.platform.smartmetering.PlatformSmartmeteringKeys; | ||
import org.opensmartgridplatform.cucumber.platform.smartmetering.support.ws.smartmetering.RequestFactoryHelper; | ||
|
||
public class SetSpecificAttributeValueRequestFactory { | ||
|
||
private SetSpecificAttributeValueRequestFactory() { | ||
// Private constructor for utility class | ||
} | ||
|
||
public static SetSpecificAttributeValueRequest fromParameterMap( | ||
final Map<String, String> parameters) { | ||
final SetSpecificAttributeValueRequest request = new SetSpecificAttributeValueRequest(); | ||
request.setDeviceIdentification( | ||
parameters.get(PlatformSmartmeteringKeys.DEVICE_IDENTIFICATION)); | ||
request.setObjectType( | ||
AllowedObjectType.valueOf(parameters.get(PlatformSmartmeteringKeys.OBJECT_TYPE))); | ||
request.setAttribute(new BigInteger(parameters.get(PlatformSmartmeteringKeys.ATTRIBUTE))); | ||
request.setIntValue(new BigInteger(parameters.get(PlatformSmartmeteringKeys.INT_VALUE))); | ||
return request; | ||
} | ||
|
||
public static SetSpecificAttributeValueAsyncRequest fromScenarioContext() { | ||
final SetSpecificAttributeValueAsyncRequest asyncRequest = | ||
new SetSpecificAttributeValueAsyncRequest(); | ||
asyncRequest.setCorrelationUid(RequestFactoryHelper.getCorrelationUidFromScenarioContext()); | ||
asyncRequest.setDeviceIdentification( | ||
RequestFactoryHelper.getDeviceIdentificationFromScenarioContext()); | ||
return asyncRequest; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...resources/features/osgp-adapter-ws-smartmetering/ad-hoc/SetSpecificAttributeValue.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SPDX-FileCopyrightText: Contributors to the GXF project | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
@SmartMetering @Platform @SmartMeteringAdHoc | ||
Feature: SmartMetering AdHoc | ||
As a grid operator | ||
I want to be able to set a specific attribute value in a device | ||
So I can change the configuration of a device | ||
|
||
Scenario Outline: Set watchdog timer for a <protocol> <version> device | ||
Given a dlms device | ||
| DeviceIdentification | <deviceIdentification> | | ||
| DeviceType | SMART_METER_E | | ||
| Protocol | <protocol> | | ||
| ProtocolVersion | <version> | | ||
When the Set Specific Attribute Value request is received | ||
| DeviceIdentification | <deviceIdentification> | | ||
| ObjectType | WATCHDOG_TIMER | | ||
| Attribute | 2 | | ||
| IntValue | 42 | | ||
Then the Set Specific Attribute Value response should be returned | ||
| DeviceIdentification | <deviceIdentification> | | ||
| Result | <response> | | ||
|
||
Examples: | ||
| deviceIdentification | protocol | version | response | | ||
| TEST1024000000001 | DSMR | 4.2.2 | OK | | ||
@NightlyBuildOnly | ||
Examples: | ||
| deviceIdentification | protocol | version | response | | ||
| TEST1024000000001 | DSMR | 2.2 | NOT_OK | | ||
| TEST1031000000001 | SMR | 4.3 | OK | | ||
| TEST1027000000001 | SMR | 5.0.0 | OK | | ||
| TEST1028000000001 | SMR | 5.1 | OK | | ||
| TEST1029000000001 | SMR | 5.2 | OK | | ||
| TEST1030000000001 | SMR | 5.5 | OK | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...g/infra/jms/core/messageprocessors/SetSpecificAttributeValueResponseMessageProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// SPDX-FileCopyrightText: Copyright Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.opensmartgridplatform.adapter.domain.smartmetering.infra.jms.core.messageprocessors; | ||
|
||
import org.opensmartgridplatform.adapter.domain.smartmetering.application.services.AdhocService; | ||
import org.opensmartgridplatform.adapter.domain.smartmetering.infra.jms.core.OsgpCoreResponseMessageProcessor; | ||
import org.opensmartgridplatform.adapter.domain.smartmetering.infra.jms.ws.WebServiceResponseMessageSender; | ||
import org.opensmartgridplatform.shared.exceptionhandling.ComponentType; | ||
import org.opensmartgridplatform.shared.exceptionhandling.OsgpException; | ||
import org.opensmartgridplatform.shared.infra.jms.MessageMetadata; | ||
import org.opensmartgridplatform.shared.infra.jms.MessageProcessorMap; | ||
import org.opensmartgridplatform.shared.infra.jms.MessageType; | ||
import org.opensmartgridplatform.shared.infra.jms.ResponseMessage; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class SetSpecificAttributeValueResponseMessageProcessor | ||
extends OsgpCoreResponseMessageProcessor { | ||
|
||
private final AdhocService adhocService; | ||
|
||
@Autowired | ||
public SetSpecificAttributeValueResponseMessageProcessor( | ||
final WebServiceResponseMessageSender responseMessageSender, | ||
@Qualifier("domainSmartMeteringInboundOsgpCoreResponsesMessageProcessorMap") | ||
final MessageProcessorMap messageProcessorMap, | ||
@Qualifier("domainSmartMeteringAdhocService") final AdhocService adhocService) { | ||
super( | ||
responseMessageSender, | ||
messageProcessorMap, | ||
MessageType.SET_SPECIFIC_ATTRIBUTE_VALUE, | ||
ComponentType.DOMAIN_SMART_METERING); | ||
this.adhocService = adhocService; | ||
} | ||
|
||
@Override | ||
protected boolean hasRegularResponseObject(final ResponseMessage responseMessage) { | ||
// Only the Result (OK/NOK/Exception) is returned, no need to check the (contents of the | ||
// dataObject). | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void handleMessage( | ||
final MessageMetadata deviceMessageMetadata, | ||
final ResponseMessage responseMessage, | ||
final OsgpException osgpException) { | ||
this.adhocService.handleSetSpecificAttributeValueResponse( | ||
deviceMessageMetadata, | ||
responseMessage.getResult(), | ||
osgpException, | ||
(String) responseMessage.getDataObject()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ring/infra/jms/ws/messageprocessors/SetSpecificAttributeValueRequestMessageProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-FileCopyrightText: Copyright Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.opensmartgridplatform.adapter.domain.smartmetering.infra.jms.ws.messageprocessors; | ||
|
||
import org.opensmartgridplatform.adapter.domain.smartmetering.application.services.AdhocService; | ||
import org.opensmartgridplatform.adapter.domain.smartmetering.infra.jms.BaseRequestMessageProcessor; | ||
import org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetSpecificAttributeValueRequest; | ||
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException; | ||
import org.opensmartgridplatform.shared.infra.jms.MessageMetadata; | ||
import org.opensmartgridplatform.shared.infra.jms.MessageProcessorMap; | ||
import org.opensmartgridplatform.shared.infra.jms.MessageType; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class SetSpecificAttributeValueRequestMessageProcessor extends BaseRequestMessageProcessor { | ||
|
||
private final AdhocService adhocService; | ||
|
||
@Autowired | ||
protected SetSpecificAttributeValueRequestMessageProcessor( | ||
@Qualifier("domainSmartMeteringInboundWebServiceRequestsMessageProcessorMap") | ||
final MessageProcessorMap messageProcessorMap, | ||
@Qualifier("domainSmartMeteringAdhocService") final AdhocService adhocService) { | ||
super(messageProcessorMap, MessageType.SET_SPECIFIC_ATTRIBUTE_VALUE); | ||
this.adhocService = adhocService; | ||
} | ||
|
||
@Override | ||
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final Object dataObject) | ||
throws FunctionalException { | ||
|
||
final SetSpecificAttributeValueRequest request = (SetSpecificAttributeValueRequest) dataObject; | ||
|
||
this.adhocService.setSpecificAttributeValue(deviceMessageMetadata, request); | ||
} | ||
} |
Oops, something went wrong.