Search in sources :

Example 1 with FirmwareVersion

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

the class GetFirmwareVersion method theFirmwareVersionResultShouldBeReturned.

@Then("^the firmware version result should be returned$")
public void theFirmwareVersionResultShouldBeReturned(final Map<String, String> settings) throws Throwable {
    final GetFirmwareVersionAsyncRequest getFirmwareVersionAsyncRequest = FirmwareVersionRequestFactory.fromScenarioContext();
    final GetFirmwareVersionResponse getFirmwareVersionResponse = this.smartMeteringConfigurationClient.retrieveGetFirmwareVersionResponse(getFirmwareVersionAsyncRequest);
    assertThat(getFirmwareVersionResponse.getResult()).as("Get firmware version response has result null").isNotNull();
    assertThat(getFirmwareVersionResponse.getResult()).as("Response should be OK").isEqualTo(OsgpResultType.OK);
    final List<FirmwareVersion> firmwareVersions = getFirmwareVersionResponse.getFirmwareVersion();
    this.checkFirmwareVersionResult(settings, firmwareVersions);
}
Also used : GetFirmwareVersionAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionAsyncRequest) GetFirmwareVersionResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionResponse) FirmwareVersion(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.FirmwareVersion) Then(io.cucumber.java.en.Then)

Example 2 with FirmwareVersion

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

the class BundledGetFirmwareVersionSteps method theBundleResponseShouldContainAGetFirmwareVersionResponse.

@Then("^the bundle response should contain a get firmware version response$")
public void theBundleResponseShouldContainAGetFirmwareVersionResponse(final Map<String, String> settings) throws Throwable {
    final Response response = this.getNextBundleResponse();
    assertThat(response).isInstanceOf(GetFirmwareVersionResponse.class);
    final GetFirmwareVersionResponse getFirmwareVersionResponse = (GetFirmwareVersionResponse) response;
    final List<FirmwareVersion> firmwareVersions = getFirmwareVersionResponse.getFirmwareVersions();
    this.getFirmwareVersionSteps.checkFirmwareVersionResult(settings, firmwareVersions);
}
Also used : GetFirmwareVersionGasResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetFirmwareVersionGasResponse) Response(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.Response) GetFirmwareVersionResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetFirmwareVersionResponse) GetFirmwareVersionResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetFirmwareVersionResponse) GetFirmwareVersion(org.opensmartgridplatform.cucumber.platform.smartmetering.glue.steps.ws.smartmetering.smartmeteringconfiguration.GetFirmwareVersion) FirmwareVersion(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.FirmwareVersion) Then(io.cucumber.java.en.Then)

Example 3 with FirmwareVersion

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

the class SmartMeteringConfigurationEndpoint method getGetFirmwareVersionResponse.

/**
 * Gets the Firmware version response from the database (if it is there) and returns {@link
 * GetFirmwareVersionResponse} containing those firmware versions.
 *
 * @param organisationIdentification {@link String} containing the identification of the
 *     organization
 * @param request {@link GetFirmwareVersionAsyncRequest} containing the correlation id as the
 *     response identifier
 * @return {@link GetFirmwareVersionResponse} containing the firmware version(s) for the device.
 * @throws OsgpException is thrown when the correlationId cannot be found in the database
 */
@PayloadRoot(localPart = "GetFirmwareVersionAsyncRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public GetFirmwareVersionResponse getGetFirmwareVersionResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetFirmwareVersionAsyncRequest request) throws OsgpException {
    log.info("GetFirmwareVersionResponse Request received from organisation {} for device: {}.", organisationIdentification, request.getDeviceIdentification());
    final GetFirmwareVersionResponse response = new GetFirmwareVersionResponse();
    try {
        final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
        if (responseData != null) {
            response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
            if (responseData.getMessageData() != null) {
                final List<FirmwareVersion> target = response.getFirmwareVersion();
                final FirmwareVersionResponse firmwareVersionResponse = (FirmwareVersionResponse) responseData.getMessageData();
                target.addAll(this.configurationMapper.mapAsList(firmwareVersionResponse.getFirmwareVersions(), FirmwareVersion.class));
            } else {
                log.info("Get Firmware Version firmware is null");
            }
        }
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : GetFirmwareVersionResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionResponse) GetKeysResponseData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) GetFirmwareVersionResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionResponse) FirmwareVersionResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.FirmwareVersionResponse) FirmwareVersion(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.FirmwareVersion) IOException(java.io.IOException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 4 with FirmwareVersion

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

the class GetFirmwareVersion method checkFirmwareVersionResult.

public void checkFirmwareVersionResult(final Map<String, String> settings, final List<FirmwareVersion> firmwareVersions) {
    final Map<FirmwareModule, String> expectedVersionsByModule = this.deviceFirmwareModuleSteps.getFirmwareModuleVersions(settings, true);
    assertThat(firmwareVersions.size()).as("Number of firmware modules").isEqualTo(expectedVersionsByModule.size());
    for (final FirmwareVersion receivedFirmwareVersion : firmwareVersions) {
        assertThat(receivedFirmwareVersion.getFirmwareModuleType()).as("The received firmware module type is null").isNotNull();
        assertThat(receivedFirmwareVersion.getVersion()).as("The received firmware version is null").isNotNull();
        final String moduleDescription = receivedFirmwareVersion.getFirmwareModuleType().name();
        final String moduleVersion = receivedFirmwareVersion.getVersion();
        final FirmwareModule firmwareModule = this.firmwareModuleRepository.findByDescriptionIgnoreCase(moduleDescription);
        assertThat(firmwareModule).as("Received version \"" + moduleVersion + "\" for unknown firmware module \"" + moduleDescription + "\"").isNotNull();
        assertThat(moduleVersion).as("Received version \"" + moduleVersion + "\" for firmware module \"" + moduleDescription + "\" which was not expected").isNotNull();
        final String expectedVersion = expectedVersionsByModule.get(firmwareModule);
        assertThat(moduleVersion).as("Version for firmware module \"" + moduleDescription + "\"").isEqualTo(expectedVersion);
    }
}
Also used : FirmwareModule(org.opensmartgridplatform.domain.core.entities.FirmwareModule) ReadSettingsHelper.getNullOrNonEmptyString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getNullOrNonEmptyString) FirmwareVersion(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.FirmwareVersion)

Aggregations

FirmwareVersion (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.FirmwareVersion)4 Then (io.cucumber.java.en.Then)2 GetFirmwareVersionResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionResponse)2 IOException (java.io.IOException)1 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 GetFirmwareVersionGasResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetFirmwareVersionGasResponse)1 GetFirmwareVersionResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetFirmwareVersionResponse)1 Response (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.Response)1 GetFirmwareVersionAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetFirmwareVersionAsyncRequest)1 GetKeysResponseData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData)1 ReadSettingsHelper.getNullOrNonEmptyString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getNullOrNonEmptyString)1 GetFirmwareVersion (org.opensmartgridplatform.cucumber.platform.smartmetering.glue.steps.ws.smartmetering.smartmeteringconfiguration.GetFirmwareVersion)1 FirmwareModule (org.opensmartgridplatform.domain.core.entities.FirmwareModule)1 FirmwareVersionResponse (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.FirmwareVersionResponse)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1