Skip to content

Commit 6dc52c4

Browse files
committed
Merge branch 'development' into feature/SMHE-1748_SF_JasperW_to_shared
2 parents e2c0a72 + e4f2ce1 commit 6dc52c4

File tree

138 files changed

+1101
-558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+1101
-558
lines changed

integration-tests/cucumber-tests-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SPDX-License-Identifier: Apache-2.0
1212
<parent>
1313
<groupId>org.opensmartgridplatform</groupId>
1414
<artifactId>parent-integration-tests</artifactId>
15-
<version>5.48.0-SNAPSHOT</version>
15+
<version>5.49.0-SNAPSHOT</version>
1616
<relativePath>../parent-integration-tests/pom.xml</relativePath>
1717
</parent>
1818

integration-tests/cucumber-tests-execution/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SPDX-License-Identifier: Apache-2.0
1212
<parent>
1313
<groupId>org.opensmartgridplatform</groupId>
1414
<artifactId>parent-integration-tests</artifactId>
15-
<version>5.48.0-SNAPSHOT</version>
15+
<version>5.49.0-SNAPSHOT</version>
1616
<relativePath>../parent-integration-tests/pom.xml</relativePath>
1717
</parent>
1818

integration-tests/cucumber-tests-platform-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SPDX-License-Identifier: Apache-2.0
1313
<parent>
1414
<groupId>org.opensmartgridplatform</groupId>
1515
<artifactId>parent-integration-tests</artifactId>
16-
<version>5.48.0-SNAPSHOT</version>
16+
<version>5.49.0-SNAPSHOT</version>
1717
<relativePath>../parent-integration-tests/pom.xml</relativePath>
1818
</parent>
1919

integration-tests/cucumber-tests-platform-distributionautomation/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SPDX-License-Identifier: Apache-2.0
1313
<parent>
1414
<groupId>org.opensmartgridplatform</groupId>
1515
<artifactId>parent-integration-tests</artifactId>
16-
<version>5.48.0-SNAPSHOT</version>
16+
<version>5.49.0-SNAPSHOT</version>
1717
<relativePath>../parent-integration-tests/pom.xml</relativePath>
1818
</parent>
1919

integration-tests/cucumber-tests-platform-microgrids/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SPDX-License-Identifier: Apache-2.0
1313
<parent>
1414
<groupId>org.opensmartgridplatform</groupId>
1515
<artifactId>parent-integration-tests</artifactId>
16-
<version>5.48.0-SNAPSHOT</version>
16+
<version>5.49.0-SNAPSHOT</version>
1717
<relativePath>../parent-integration-tests/pom.xml</relativePath>
1818
</parent>
1919

integration-tests/cucumber-tests-platform-publiclighting/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SPDX-License-Identifier: Apache-2.0
1212
<parent>
1313
<groupId>org.opensmartgridplatform</groupId>
1414
<artifactId>parent-integration-tests</artifactId>
15-
<version>5.48.0-SNAPSHOT</version>
15+
<version>5.49.0-SNAPSHOT</version>
1616
<relativePath>../parent-integration-tests/pom.xml</relativePath>
1717
</parent>
1818

integration-tests/cucumber-tests-platform-smartmetering/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SPDX-License-Identifier: Apache-2.0
1313
<parent>
1414
<groupId>org.opensmartgridplatform</groupId>
1515
<artifactId>parent-integration-tests</artifactId>
16-
<version>5.48.0-SNAPSHOT</version>
16+
<version>5.49.0-SNAPSHOT</version>
1717
<relativePath>../parent-integration-tests/pom.xml</relativePath>
1818
</parent>
1919

integration-tests/cucumber-tests-platform-smartmetering/src/test/java/org/opensmartgridplatform/cucumber/platform/smartmetering/AcceptanceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"classpath:features/osgp-adapter-ws-core",
1717
"classpath:features/osgp-adapter-ws-smartmetering"
1818
},
19-
tags = {"not @Skip", "not @NightlyBuildOnly"},
19+
tags = {"@blahgxf"},
2020
glue = {
2121
"classpath:org.opensmartgridplatform.cucumber.platform.glue",
2222
"classpath:org.opensmartgridplatform.cucumber.platform.common.glue",

integration-tests/cucumber-tests-platform-smartmetering/src/test/java/org/opensmartgridplatform/cucumber/platform/smartmetering/glue/steps/simulator/SimulatedConfigurationObjectSteps.java

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
import static org.assertj.core.api.Assertions.assertThat;
88

9-
import com.fasterxml.jackson.databind.JsonNode;
109
import com.fasterxml.jackson.databind.node.ArrayNode;
1110
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
1211
import com.fasterxml.jackson.databind.node.ObjectNode;
1312
import io.cucumber.java.en.Given;
1413
import io.cucumber.java.en.Then;
1514
import java.util.List;
1615
import java.util.Map;
16+
import lombok.extern.slf4j.Slf4j;
1717
import org.openmuc.jdlms.ObisCode;
1818
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag;
1919
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags;
@@ -24,6 +24,7 @@
2424
import org.opensmartgridplatform.dlms.interfaceclass.attribute.DataAttribute;
2525
import org.springframework.beans.factory.annotation.Autowired;
2626

27+
@Slf4j
2728
public class SimulatedConfigurationObjectSteps {
2829

2930
private static final int CLASS_ID = InterfaceClass.DATA.id();
@@ -35,8 +36,9 @@ public class SimulatedConfigurationObjectSteps {
3536

3637
@Autowired private JsonObjectCreator jsonObjectCreator;
3738

38-
@Given("device simulation of {string} with configuration object")
39-
public void deviceSimulationOfConfigurationObject(
39+
@Given(
40+
"device simulation of {string} with configuration object values in structure type value attribute")
41+
public void deviceSimulationOfConfigurationObjectValuesInStructureTypeValueAttribute(
4042
final String deviceIdentification, final Map<String, String> settings) {
4143

4244
this.deviceSimulatorSteps.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
@@ -49,16 +51,52 @@ public void deviceSimulationOfConfigurationObject(
4951
CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_VALUE, attributeValue, OBJECT_DESCRIPTION);
5052
}
5153

52-
@Then("device simulation of {string} should be with configuration object")
53-
public void deviceSimulationOfShouldBeWithConfigurationObject(
54+
@Given(
55+
"device simulation of {string} with configuration object values in bitstring type value attribute")
56+
public void deviceSimulationOfConfigurationObjectValuesInBitstringTypeValueAttribute(
5457
final String deviceIdentification, final Map<String, String> settings) {
5558

59+
this.deviceSimulatorSteps.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
60+
61+
final ConfigurationObject configurationObject =
62+
ConfigurationObjectFactory.fromParameterMap(settings);
63+
final ObjectNode attributeValue =
64+
this.createBitstringForConfigurationObject(configurationObject, new JsonNodeFactory(false));
65+
this.deviceSimulatorSteps.setDlmsAttributeValue(
66+
CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_VALUE, attributeValue, OBJECT_DESCRIPTION);
67+
}
68+
69+
@Then(
70+
"device simulation should have values in a bitstring type value attribute of the configuration object")
71+
public void
72+
deviceSimulationShouldHaveValuesInABitstringTypeValueAttributeOfTheConfigurationObject(
73+
final Map<String, String> settings) {
74+
75+
final ConfigurationObject expectedConfigurationObject =
76+
ConfigurationObjectFactory.fromParameterMap(settings);
77+
final ObjectNode expectedValue =
78+
this.createBitstringForConfigurationObject(
79+
expectedConfigurationObject, new JsonNodeFactory(false));
80+
81+
this.assertDlmsAttributeValue(expectedValue);
82+
}
83+
84+
@Then(
85+
"device simulation should have values in a structure type value attribute of the configuration object")
86+
public void
87+
deviceSimulationShouldHaveValuesInAStructureTypeValueAttributeOfTheConfigurationObject(
88+
final Map<String, String> settings) {
89+
5690
final ConfigurationObject expectedConfigurationObject =
5791
ConfigurationObjectFactory.fromParameterMap(settings);
5892
final ObjectNode expectedValue =
5993
this.createStructureForConfigurationObject(
6094
expectedConfigurationObject, new JsonNodeFactory(false));
6195

96+
this.assertDlmsAttributeValue(expectedValue);
97+
}
98+
99+
private void assertDlmsAttributeValue(final ObjectNode expectedValue) {
62100
final ObjectNode actualValue =
63101
this.deviceSimulatorSteps.getDlmsAttributeValue(
64102
CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_VALUE, OBJECT_DESCRIPTION);
@@ -71,22 +109,35 @@ private ObjectNode createStructureForConfigurationObject(
71109

72110
final ObjectNode structureForConfigurationObject = jsonNodeFactory.objectNode();
73111
this.jsonObjectCreator.setTypeNode(structureForConfigurationObject, "structure");
112+
74113
final ArrayNode configurationObjectElements = jsonNodeFactory.arrayNode();
114+
75115
configurationObjectElements.add(
76116
this.createGprsOperationModeForConfigurationObject(
77117
configurationObject.getGprsOperationMode(), jsonNodeFactory));
78-
configurationObjectElements.add(
79-
this.createFlagsForConfigurationObject(
80-
configurationObject.getConfigurationFlags(), jsonNodeFactory));
118+
119+
final String flagsString = this.createFlagString(configurationObject.getConfigurationFlags());
120+
final ObjectNode flagsForConfigurationObject =
121+
this.jsonObjectCreator.createAttributeValue("bit-string", flagsString, jsonNodeFactory);
122+
configurationObjectElements.add(flagsForConfigurationObject);
123+
81124
structureForConfigurationObject.set("value", configurationObjectElements);
82125

83126
return structureForConfigurationObject;
84127
}
85128

129+
private ObjectNode createBitstringForConfigurationObject(
130+
final ConfigurationObject configurationObject, final JsonNodeFactory jsonNodeFactory) {
131+
132+
final String flagsString = this.createFlagString(configurationObject.getConfigurationFlags());
133+
134+
return this.jsonObjectCreator.createAttributeValue("bit-string", flagsString, jsonNodeFactory);
135+
}
136+
86137
private ObjectNode createGprsOperationModeForConfigurationObject(
87138
final GprsOperationModeType gprsOperationMode, final JsonNodeFactory jsonNodeFactory) {
88139

89-
String textValue;
140+
final String textValue;
90141
if (gprsOperationMode == GprsOperationModeType.ALWAYS_ON) {
91142
textValue = "1";
92143
} else if (gprsOperationMode == GprsOperationModeType.TRIGGERED) {
@@ -97,9 +148,7 @@ private ObjectNode createGprsOperationModeForConfigurationObject(
97148
return this.jsonObjectCreator.createAttributeValue("enumerate", textValue, jsonNodeFactory);
98149
}
99150

100-
private JsonNode createFlagsForConfigurationObject(
101-
final ConfigurationFlags configurationFlags, final JsonNodeFactory jsonNodeFactory) {
102-
151+
private String createFlagString(final ConfigurationFlags configurationFlags) {
103152
final int bitStringLength = 16;
104153
final char[] flags = new char[bitStringLength];
105154
for (int i = 0; i < bitStringLength; i++) {
@@ -114,7 +163,6 @@ private JsonNode createFlagsForConfigurationObject(
114163
}
115164
}
116165
}
117-
return this.jsonObjectCreator.createAttributeValue(
118-
"bit-string", new String(flags), jsonNodeFactory);
166+
return new String(flags);
119167
}
120168
}

integration-tests/cucumber-tests-platform-smartmetering/src/test/java/org/opensmartgridplatform/cucumber/platform/smartmetering/glue/steps/ws/smartmetering/smartmeteringbundle/BundledGetConfigurationObjectSteps.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import io.cucumber.java.en.Given;
1111
import io.cucumber.java.en.Then;
1212
import java.util.Map;
13+
import org.apache.commons.lang3.StringUtils;
1314
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetConfigurationObjectRequest;
1415
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetConfigurationObjectResponse;
1516
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.Response;
@@ -18,6 +19,8 @@
1819

1920
public class BundledGetConfigurationObjectSteps extends BaseBundleSteps {
2021

22+
static final String GPRS_OPERATION_MODE = "GprsOperationMode";
23+
2124
@Given("^the bundle request contains a get configuration object action$")
2225
public void theBundleRequestContainsAGetConfigurationObject() throws Throwable {
2326

@@ -49,9 +52,14 @@ public void theBundleResponseShouldContainAConfigurationObjectResponse(
4952
final ConfigurationObject configurationObject =
5053
((GetConfigurationObjectResponse) response).getConfigurationObject();
5154

52-
assertThat(configurationObject.getGprsOperationMode().toString())
53-
.as("The gprs operation mode is not equal")
54-
.isEqualTo(values.get("GprsOperationMode"));
55+
if (values.containsKey(GPRS_OPERATION_MODE)
56+
&& StringUtils.isNotBlank(values.get(GPRS_OPERATION_MODE))) {
57+
assertThat(configurationObject.getGprsOperationMode())
58+
.as("The gprs operation mode is not equal")
59+
.hasToString(values.get(GPRS_OPERATION_MODE));
60+
} else {
61+
assertThat(configurationObject.getGprsOperationMode()).isNull();
62+
}
5563

5664
configurationObject
5765
.getConfigurationFlags()

integration-tests/cucumber-tests-platform-smartmetering/src/test/java/org/opensmartgridplatform/cucumber/platform/smartmetering/glue/steps/ws/smartmetering/smartmeteringconfiguration/SetConfigurationObject.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ public void theSetConfigurationObjectRequestIsReceived(final Map<String, String>
5151
@Then("^the configuration object should be set on the device$")
5252
public void theConfigurationObjectShouldBeSetOnTheDevice(final Map<String, String> settings)
5353
throws Throwable {
54+
this.theConfigurationObjectShouldBeSetOrNotOnTheDevice(settings, OsgpResultType.OK);
55+
}
56+
57+
@Then("^the configuration object should not be set on the device$")
58+
public void theConfigurationObjectShouldNotBeSetOnTheDevice(final Map<String, String> settings)
59+
throws Throwable {
60+
this.theConfigurationObjectShouldBeSetOrNotOnTheDevice(settings, OsgpResultType.NOT_OK);
61+
}
62+
63+
public void theConfigurationObjectShouldBeSetOrNotOnTheDevice(
64+
final Map<String, String> settings, final OsgpResultType result) throws Throwable {
5465
final SetConfigurationObjectAsyncRequest setConfigurationObjectAsyncRequest =
5566
SetConfigurationObjectRequestFactory.fromScenarioContext();
5667
final SetConfigurationObjectResponse setConfigurationObjectResponse =
@@ -59,6 +70,6 @@ public void theConfigurationObjectShouldBeSetOnTheDevice(final Map<String, Strin
5970

6071
assertThat(setConfigurationObjectResponse.getResult())
6172
.as("Set configuration object result")
62-
.isEqualTo(OsgpResultType.OK);
73+
.isEqualTo(result);
6374
}
6475
}

integration-tests/cucumber-tests-platform-smartmetering/src/test/java/org/opensmartgridplatform/cucumber/platform/smartmetering/glue/steps/ws/smartmetering/smartmeteringconfiguration/SetRandomisationSettings.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,22 @@ public void theSetRandomisationSettingsRequestIsReceived(final Map<String, Strin
4141

4242
@Then("the randomisation settings should be set on the device")
4343
public void theRandomisationSettingsShouldBeSetOnTheDevice() throws Throwable {
44+
this.theRandomisationSettingsShouldResultIn(OsgpResultType.OK);
45+
}
46+
47+
@Then("the randomisation settings should not be set on the device")
48+
public void theRandomisationSettingsShouldNotBeSetOnTheDevice() throws Throwable {
49+
this.theRandomisationSettingsShouldResultIn(OsgpResultType.NOT_OK);
50+
}
51+
52+
private void theRandomisationSettingsShouldResultIn(final OsgpResultType result)
53+
throws Throwable {
4454
final SetRandomisationSettingsAsyncRequest asyncRequest =
4555
SetRandomisationSettingsFactory.fromScenarioContext();
4656
final SetRandomisationSettingsResponse response =
4757
this.smartMeteringConfigurationClient.retrieveSetRandomisationSettingsResponse(
4858
asyncRequest);
4959

50-
assertThat(response.getResult()).isEqualTo(OsgpResultType.OK);
60+
assertThat(response.getResult()).isEqualTo(result);
5161
}
5262
}

integration-tests/cucumber-tests-platform-smartmetering/src/test/java/org/opensmartgridplatform/cucumber/platform/smartmetering/support/ws/smartmetering/configuration/ConfigurationObjectFactory.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.List;
1010
import java.util.Map;
1111
import java.util.Set;
12+
import org.apache.commons.lang3.StringUtils;
1213
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag;
1314
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlagType;
1415
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags;
@@ -85,17 +86,23 @@ private static void setConfigurationFlags(
8586
final int numberOfFlags =
8687
Integer.parseInt(requestParameters.get(PlatformSmartmeteringKeys.CONFIGURATION_FLAG_COUNT));
8788
for (int i = 1; i <= numberOfFlags; i++) {
88-
configurationFlagList.add(getConfigurationFlag(requestParameters, i));
89+
if (isConfigurationFlagDefined(requestParameters, i)) {
90+
configurationFlagList.add(getConfigurationFlag(requestParameters, i));
91+
}
92+
}
93+
if (configurationFlagList.isEmpty()) {
94+
return;
8995
}
9096
configurationFlags.getConfigurationFlag().addAll(configurationFlagList);
9197
configurationObject.setConfigurationFlags(configurationFlags);
9298
}
9399

94100
private static ConfigurationFlag getConfigurationFlag(
95101
final Map<String, String> parameters, final int index) {
102+
final Boolean configurationFlagEnabled = getConfigurationFlagEnabled(parameters, index);
96103
final ConfigurationFlag configurationFlag = new ConfigurationFlag();
97104
configurationFlag.setConfigurationFlagType(getConfigurationFlagType(parameters, index));
98-
configurationFlag.setEnabled(getConfigurationFlagEnabled(parameters, index));
105+
configurationFlag.setEnabled(configurationFlagEnabled);
99106
return configurationFlag;
100107
}
101108

@@ -113,4 +120,11 @@ private static boolean getConfigurationFlagEnabled(
113120
SettingsHelper.makeKey(PlatformSmartmeteringKeys.CONFIGURATION_FLAG_ENABLED, index);
114121
return ReadSettingsHelper.getBoolean(parameters, key);
115122
}
123+
124+
private static boolean isConfigurationFlagDefined(
125+
final Map<String, String> parameters, final int index) {
126+
final String key =
127+
SettingsHelper.makeKey(PlatformSmartmeteringKeys.CONFIGURATION_FLAG_ENABLED, index);
128+
return StringUtils.isNotBlank(parameters.get(key));
129+
}
116130
}

0 commit comments

Comments
 (0)