Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into feature/FDP-622
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianoFavoroso committed Jul 19, 2023
2 parents 1545ab6 + 24b375a commit 8ea0be6
Show file tree
Hide file tree
Showing 23 changed files with 354 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.OsgpResultType;
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.CoupleMbusDeviceAsyncRequest;
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.CoupleMbusDeviceAsyncResponse;
import org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.CoupleMbusDeviceByChannelAsyncRequest;
Expand Down Expand Up @@ -89,33 +89,28 @@ public void theCoupleGMeterRequestOnChannelIsReceivedForAnInactiveDevice(
}
}

@Then("^the Couple response is \"([^\"]*)\"$")
public void theCoupleResponseIs(final String status) throws WebServiceSecurityException {

@Then("^the Couple response has the following values$")
public void theCoupleResponseIs(final Map<String, String> values)
throws WebServiceSecurityException {
final CoupleMbusDeviceAsyncRequest asyncRequest =
CoupleMbusDeviceRequestFactory.fromScenarioContext();
final CoupleMbusDeviceResponse response =
this.smartMeteringInstallationClient.getCoupleMbusDeviceResponse(asyncRequest);

assertThat(response.getResult()).as("Result").isNotNull();
assertThat(response.getResult().name()).as("Result").isEqualTo(status);
}

@Then("^the Couple response is \"([^\"]*)\" and contains$")
public void theCoupleResponseIsAndContains(final String status, final List<String> resultList)
throws WebServiceSecurityException {

final CoupleMbusDeviceAsyncRequest coupleMbusDeviceAsyncRequest =
CoupleMbusDeviceRequestFactory.fromScenarioContext();
final CoupleMbusDeviceResponse response =
this.smartMeteringInstallationClient.getCoupleMbusDeviceResponse(
coupleMbusDeviceAsyncRequest);

assertThat(response.getResult()).as("Result").isNotNull();
assertThat(response.getResult().name()).as("Result").isEqualTo(status);
assertThat(this.checkDescription(response.getDescription(), resultList))
.as("Description should contain all of " + resultList)
.isTrue();
assertThat(response.getResult()).isEqualTo(OsgpResultType.OK);
if (values.containsKey(PlatformKeys.KEY_MBUS_DEVICE_IDENTIFICATION)) {
final String mbusDeviceIdentification =
values.get(PlatformKeys.KEY_MBUS_DEVICE_IDENTIFICATION);
assertThat(response.getMbusDeviceIdentification()).isEqualTo(mbusDeviceIdentification);
}
if (values.containsKey(PlatformKeys.KEY_CHANNEL)) {
final short channel = Short.parseShort(values.get(PlatformKeys.KEY_CHANNEL));
assertThat(response.getChannelElementValues().getChannel()).isEqualTo(channel);
}
if (values.containsKey(PlatformKeys.KEY_PRIMARY_ADDRESS)) {
final short primaryAddress = Short.parseShort(values.get(PlatformKeys.KEY_PRIMARY_ADDRESS));
assertThat(response.getChannelElementValues().getPrimaryAddress()).isEqualTo(primaryAddress);
}
}

@Then("^retrieving the Couple response results in an exception$")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ Feature: SmartMetering Installation - Couple M-Bus Device
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
When the Couple G-meter "TESTG101205673117" request is received for E-meter "TEST1024000000001"
Then the Couple response is "OK"
Then the Couple response has the following values
| MbusDeviceIdentification | TESTG101205673117 |
| Channel | 1 |
| PrimaryAddress | 9 |
And the M-Bus device "TESTG101205673117" is coupled to device "TEST1024000000001" on M-Bus channel "1" with PrimaryAddress "9"

Examples:
Expand Down Expand Up @@ -59,7 +62,10 @@ Feature: SmartMetering Installation - Couple M-Bus Device
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
When the Couple G-meter "TESTG101205673117" request is received for E-meter "TEST1024000000001"
Then the Couple response is "OK"
Then the Couple response has the following values
| MbusDeviceIdentification | TESTG101205673117 |
| Channel | 1 |
| PrimaryAddress | 9 |
And the M-Bus device "TESTG101205673117" is coupled to device "TEST1024000000001" on M-Bus channel "1" with PrimaryAddress "9"

@NightlyBuildOnly
Expand Down Expand Up @@ -88,7 +94,10 @@ Feature: SmartMetering Installation - Couple M-Bus Device
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
When the Couple G-meter "TESTG101205673117" request is received for E-meter "TEST1024000000001"
Then the Couple response is "OK"
Then the Couple response has the following values
| MbusDeviceIdentification | TESTG101205673117 |
| Channel | 2 |
| PrimaryAddress | 9 |
And the M-Bus device "TESTG101205673117" is coupled to device "TEST1024000000001" on M-Bus channel "2" with PrimaryAddress "9"

@NightlyBuildOnly
Expand Down Expand Up @@ -153,7 +162,10 @@ Feature: SmartMetering Installation - Couple M-Bus Device
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
When the Couple G-meter "TESTG101205673117" request is received for E-meter "TEST1024000000001"
Then the Couple response is "OK"
Then the Couple response has the following values
| MbusDeviceIdentification | TESTG101205673117 |
| Channel | 2 |
| PrimaryAddress | 9 |
And the M-Bus device "TESTG101205673117" is coupled to device "TEST1024000000001" on M-Bus channel "2" with PrimaryAddress "9"

@NightlyBuildOnly
Expand Down Expand Up @@ -212,7 +224,10 @@ Feature: SmartMetering Installation - Couple M-Bus Device
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
When the Couple G-meter "TESTG101205673117" request is received for E-meter "TEST1024000000001"
Then the Couple response is "OK"
Then the Couple response has the following values
| MbusDeviceIdentification | TESTG101205673117 |
| Channel | 2 |
| PrimaryAddress | 9 |
And the M-Bus device "TESTG102400000001" is coupled to device "TEST1024000000001" on M-Bus channel "1" with PrimaryAddress "3"
And the M-Bus device "TESTG101205673117" is coupled to device "TEST1024000000001" on M-Bus channel "2" with PrimaryAddress "9"

Expand Down Expand Up @@ -258,7 +273,10 @@ Feature: SmartMetering Installation - Couple M-Bus Device
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
When the Couple G-meter "TESTG101205673117" request is received for E-meter "TEST1024000000001"
Then the Couple response is "OK"
Then the Couple response has the following values
| MbusDeviceIdentification | TESTG101205673117 |
| Channel | 1 |
| PrimaryAddress | 3 |
And the M-Bus device "TESTG101205673117" is coupled to device "TEST1024000000001" on M-Bus channel "1" with PrimaryAddress "3"
And the values for the M-Bus client for channel 1 on device simulator "TEST1024000000001" are
| MbusPrimaryAddress | 3 |
Expand Down Expand Up @@ -287,7 +305,10 @@ Feature: SmartMetering Installation - Couple M-Bus Device
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
When the Couple G-meter "TESTG101205673117" request is received for E-meter "TEST1024000000001"
Then the Couple response is "OK"
Then the Couple response has the following values
| MbusDeviceIdentification | TESTG101205673117 |
| Channel | 1 |
| PrimaryAddress | 0 |
And the M-Bus device "TESTG101205673117" is coupled to device "TEST1024000000001" on M-Bus channel "1"
And the values for the M-Bus client for channel 1 on device simulator "TEST1024000000001" are
| MbusIdentificationNumber | 12056731 |
Expand Down Expand Up @@ -322,7 +343,10 @@ Feature: SmartMetering Installation - Couple M-Bus Device
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
When the Couple G-meter "TESTG101205673117" request is received for E-meter "TEST1024000000001"
Then the Couple response is "OK"
Then the Couple response has the following values
| MbusDeviceIdentification | TESTG101205673117 |
| Channel | 2 |
| PrimaryAddress | 3 |
And the M-Bus device "TESTG101205673117" is coupled to device "TEST1024000000001" on M-Bus channel "2" with PrimaryAddress "3"
And the values for the M-Bus client for channel 1 on device simulator "TEST1024000000001" are
| MbusPrimaryAddress | 241 |
Expand Down Expand Up @@ -392,7 +416,10 @@ Feature: SmartMetering Installation - Couple M-Bus Device
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
When the Couple G-meter "TESTG101205673117" request is received for E-meter "TEST1024000000001"
Then the Couple response is "OK"
Then the Couple response has the following values
| MbusDeviceIdentification | TESTG101205673117 |
| Channel | 1 |
| PrimaryAddress | 3 |
And the M-Bus device "TESTG101205673117" is coupled to device "TEST1024000000001" on M-Bus channel "1" with PrimaryAddress "3"
And the values for the M-Bus client for channel 2 on device simulator "TEST1024000000001" are
| MbusPrimaryAddress | 241 |
Expand Down Expand Up @@ -448,7 +475,10 @@ Feature: SmartMetering Installation - Couple M-Bus Device
| MbusVersion | 66 |
| MbusDeviceTypeIdentification | 3 |
When the Couple G-meter "TESTG101205673117" request is received for E-meter "TEST1024000000001"
Then the Couple response is "OK"
Then the Couple response has the following values
| MbusDeviceIdentification | TESTG101205673117 |
| Channel | 1 |
| PrimaryAddress | 3 |
And the M-Bus device "TESTG101205673117" is coupled to device "TEST1024000000001" on M-Bus channel "1" with PrimaryAddress "3"
And the values for the M-Bus client for channel 1 on device simulator "TEST1024000000001" are
| MbusPrimaryAddress | 3 |
Expand Down Expand Up @@ -518,7 +548,10 @@ Feature: SmartMetering Installation - Couple M-Bus Device
| GatewayDeviceIdentification | <GatewayDeviceIdentification> |
| Channel | 1 |
When the Couple G-meter "TESTG101205673117" request is received for E-meter "TEST1024000000001" with force
Then the Couple response is "OK"
Then the Couple response has the following values
| MbusDeviceIdentification | TESTG101205673117 |
| Channel | 1 |
| PrimaryAddress | 3 |
And the M-Bus device "TESTG101205673117" is coupled to device "TEST1024000000001" on M-Bus channel "1" with PrimaryAddress "3"
And the values for the M-Bus client for channel 1 on device simulator "TEST1024000000001" are
| MbusPrimaryAddress | 3 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public class PlatformKeys extends Keys {
public static final String KEY_DEVICE_ICCID = "ICC_id";

public static final String KEY_DEVICE_IDENTIFICATION = "DeviceIdentification";
public static final String KEY_MBUS_DEVICE_IDENTIFICATION = "MbusDeviceIdentification";
public static final String KEY_PRIMARY_ADDRESS = "PrimaryAddress";

public static final String ALIAS = "Alias";
public static final String CONTAINER_STREET = "ContainerStreet";
public static final String CONTAINER_NUMBER = "ContainerNumber";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
import org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CoupleMbusDeviceByChannelRequestData;
import org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponse;
import org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CoupleMbusDeviceRequestData;
import org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CoupleMbusDeviceResponse;
import org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DecoupleMbusDeviceAdministrativeRequestData;
import org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DecoupleMbusDeviceAdministrativeResponse;
import org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DecoupleMbusDeviceByChannelRequestData;
import org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DecoupleMbusDeviceByChannelResponse;
import org.opensmartgridplatform.domain.core.valueobjects.smartmetering.DecoupleMbusDeviceRequestData;
import org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponseDto;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceResponseDto;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.DecoupleMbusDeviceResponseDto;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.MbusChannelElementsResponseDto;
import org.opensmartgridplatform.dto.valueobjects.smartmetering.SmartMeteringDeviceDto;
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
import org.opensmartgridplatform.shared.exceptionhandling.OsgpException;
Expand Down Expand Up @@ -151,14 +152,24 @@ public void coupleMbusDeviceByChannel(
@Transactional(value = "transactionManager")
public void handleCoupleMbusDeviceResponse(
final MessageMetadata messageMetadata,
final ResponseMessageResultType result,
final OsgpException exception,
final MbusChannelElementsResponseDto dataObject)
final ResponseMessageResultType responseMessageResultType,
final OsgpException osgpException,
final CoupleMbusDeviceResponseDto dataObject)
throws FunctionalException {
if (exception == null) {

if (osgpException == null) {
this.mBusGatewayService.handleCoupleMbusDeviceResponse(messageMetadata, dataObject);
}
this.handleResponse("coupleMbusDevice", messageMetadata, result, exception);

final ResponseMessage responseMessage =
ResponseMessage.newResponseMessageBuilder()
.withMessageMetadata(messageMetadata)
.withResult(responseMessageResultType)
.withOsgpException(osgpException)
.withDataObject(this.commonMapper.map(dataObject, CoupleMbusDeviceResponse.class))
.build();

this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}

@Transactional(value = "transactionManager")
Expand Down
Loading

0 comments on commit 8ea0be6

Please sign in to comment.