Search in sources :

Example 1 with Manufacturer

use of org.opensmartgridplatform.domain.core.entities.Manufacturer in project open-smart-grid-platform by OSGP.

the class DlmsDeviceSteps method theDlmsDeviceWithIdentificationExistsWithDeviceModel.

@Then("^the dlms device with identification \"([^\"]*)\" exists with device model$")
public void theDlmsDeviceWithIdentificationExistsWithDeviceModel(final String deviceIdentification, final Map<String, String> deviceModelAttributes) throws Throwable {
    this.theDlmsDeviceWithIdentificationExists(deviceIdentification);
    final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification);
    final DeviceModel deviceModel = device.getDeviceModel();
    assertThat(deviceModel.getModelCode()).as(PlatformKeys.DEVICEMODEL_MODELCODE).isEqualTo(deviceModelAttributes.get(PlatformKeys.DEVICEMODEL_MODELCODE));
    final Manufacturer manufacturer = deviceModel.getManufacturer();
    assertThat(manufacturer.getCode()).as(PlatformKeys.MANUFACTURER_CODE).isEqualTo(deviceModelAttributes.get(PlatformKeys.MANUFACTURER_CODE));
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.entities.DeviceModel) Device(org.opensmartgridplatform.domain.core.entities.Device) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer) Then(io.cucumber.java.en.Then)

Example 2 with Manufacturer

use of org.opensmartgridplatform.domain.core.entities.Manufacturer in project open-smart-grid-platform by OSGP.

the class DeviceModelSteps method theEntityDeviceModelExists.

/**
 * Generic method to check if the device model is created as expected in the database.
 *
 * @param expectedEntity The expected settings.
 * @throws Throwable
 */
@Then("^the entity device model exists$")
public void theEntityDeviceModelExists(final Map<String, String> expectedEntity) throws Throwable {
    final String modelCode = getString(expectedEntity, PlatformKeys.KEY_DEVICE_MODEL_MODELCODE, PlatformDefaults.DEFAULT_DEVICE_MODEL_MODEL_CODE);
    final String modelDescription = getString(expectedEntity, PlatformKeys.KEY_DEVICE_MODEL_DESCRIPTION, PlatformDefaults.DEFAULT_DEVICE_MODEL_DESCRIPTION);
    final Manufacturer manufacturer = this.manufacturerRepository.findByCode(getString(expectedEntity, PlatformKeys.MANUFACTURER_CODE, PlatformDefaults.DEFAULT_MANUFACTURER_CODE));
    final List<DeviceModel> entityList = this.deviceModelRepository.findByManufacturer(manufacturer);
    for (final DeviceModel deviceModel : entityList) {
        if (deviceModel.getModelCode().equals(modelCode)) {
            assertThat(deviceModel.getDescription()).isEqualTo(modelDescription);
            return;
        }
    }
    Assertions.fail();
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.entities.DeviceModel) Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) Then(io.cucumber.java.en.Then)

Example 3 with Manufacturer

use of org.opensmartgridplatform.domain.core.entities.Manufacturer in project open-smart-grid-platform by OSGP.

the class DeviceModelSteps method theEntityDeviceModelDoesNotExists.

/**
 * Generic method to check if the device model is NOT created as expected in the database.
 *
 * @param entity The settings.
 * @throws Throwable
 */
@Then("^the entity device model does not exist$")
public void theEntityDeviceModelDoesNotExists(final Map<String, String> entity) throws Throwable {
    final String modelCode = getString(entity, PlatformKeys.KEY_DEVICE_MODEL_MODELCODE, PlatformDefaults.DEFAULT_DEVICE_MODEL_MODEL_CODE);
    final Manufacturer manufacturer = this.manufacturerRepository.findByCode(getString(entity, PlatformKeys.MANUFACTURER_CODE, PlatformDefaults.DEFAULT_MANUFACTURER_CODE));
    final List<DeviceModel> entityList = this.deviceModelRepository.findByManufacturer(manufacturer);
    for (final DeviceModel deviceModel : entityList) {
        assertThat(deviceModel.getModelCode()).isNotEqualTo(modelCode);
    }
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.entities.DeviceModel) Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) Then(io.cucumber.java.en.Then)

Example 4 with Manufacturer

use of org.opensmartgridplatform.domain.core.entities.Manufacturer in project open-smart-grid-platform by OSGP.

the class ManufacturerSteps method aManufacturer.

/**
 * Generic method which adds a manufacturer using the settings.
 *
 * @param settings The settings for the manufacturer to be used.
 * @throws Throwable
 */
@Given("^a manufacturer$")
public void aManufacturer(final Map<String, String> settings) throws Throwable {
    final Manufacturer manufacturer = new ManufacturerBuilder().withSettings(settings).build();
    this.manufacturerRepository.save(manufacturer);
}
Also used : ManufacturerBuilder(org.opensmartgridplatform.cucumber.platform.core.builders.ManufacturerBuilder) Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer) Given(io.cucumber.java.en.Given)

Example 5 with Manufacturer

use of org.opensmartgridplatform.domain.core.entities.Manufacturer in project open-smart-grid-platform by OSGP.

the class CoreDatabase method insertDefaultData.

/**
 * This method is used to create default data not directly related to the specific tests. For
 * example: The test-org organization which is used to send authorized requests to the platform.
 */
@Transactional("txMgrCore")
public void insertDefaultData() {
    if (this.organisationRepository.findByOrganisationIdentification(PlatformDefaults.DEFAULT_ORGANIZATION_IDENTIFICATION) == null) {
        // Create test organization used within the tests.
        final Organisation testOrg = new Organisation(PlatformDefaults.DEFAULT_ORGANIZATION_IDENTIFICATION, PlatformDefaults.DEFAULT_ORGANIZATION_DESCRIPTION, PlatformDefaults.DEFAULT_PREFIX, PlatformFunctionGroup.ADMIN);
        testOrg.addDomain(PlatformDomain.COMMON);
        testOrg.addDomain(PlatformDomain.PUBLIC_LIGHTING);
        testOrg.addDomain(PlatformDomain.TARIFF_SWITCHING);
        testOrg.setIsEnabled(true);
        this.organisationRepository.save(testOrg);
    }
    // Create default test manufacturer
    final Manufacturer manufacturer = new Manufacturer(PlatformDefaults.DEFAULT_MANUFACTURER_CODE, PlatformDefaults.DEFAULT_MANUFACTURER_NAME, false);
    this.manufacturerRepository.save(manufacturer);
    // Create the default test model
    final DeviceModel deviceModel = new DeviceModel(manufacturer, PlatformDefaults.DEFAULT_DEVICE_MODEL_MODEL_CODE, PlatformDefaults.DEFAULT_DEVICE_MODEL_DESCRIPTION, true);
    this.deviceModelRepository.save(deviceModel);
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.entities.DeviceModel) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Manufacturer (org.opensmartgridplatform.domain.core.entities.Manufacturer)30 DeviceModel (org.opensmartgridplatform.domain.core.entities.DeviceModel)18 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)13 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)10 Transactional (org.springframework.transaction.annotation.Transactional)10 DeviceFirmwareFile (org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile)7 FirmwareFile (org.opensmartgridplatform.domain.core.entities.FirmwareFile)6 ExistingEntityException (org.opensmartgridplatform.domain.core.exceptions.ExistingEntityException)6 Device (org.opensmartgridplatform.domain.core.entities.Device)5 Then (io.cucumber.java.en.Then)4 ArrayList (java.util.ArrayList)3 ConstraintViolationException (javax.validation.ConstraintViolationException)3 UnknownEntityException (org.opensmartgridplatform.domain.core.exceptions.UnknownEntityException)3 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)3 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)3 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)3 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)2 FirmwareModule (org.opensmartgridplatform.domain.core.entities.FirmwareModule)2 Given (io.cucumber.java.en.Given)1 Date (java.util.Date)1