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));
}
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();
}
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);
}
}
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);
}
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);
}
Aggregations