use of org.opensmartgridplatform.cucumber.platform.glue.steps.database.ws.ResponseDataBuilder in project open-smart-grid-platform by OSGP.
the class WsCoreResponseDataSteps method aResponseDataRecord.
@Given("^a response data record in ws-core$")
@Transactional("txMgrWsCore")
public ResponseData aResponseDataRecord(final Map<String, String> settings) {
final ResponseData responseData = this.responseDataRepository.save(new ResponseDataBuilder().fromSettings(settings).build());
final Date creationTime = DateTimeHelper.getDateTime(settings.get(PlatformKeys.KEY_CREATION_TIME)).toDate();
LOGGER.info("Creating response data record with correlationUid: {} and creationTime: {}", responseData.getCorrelationUid(), creationTime);
ScenarioContext.current().put(PlatformKeys.KEY_CORRELATION_UID, responseData.getCorrelationUid());
try {
// (as it will be overridden on first save)
if (settings.containsKey(PlatformKeys.KEY_CREATION_TIME)) {
final Field fld = responseData.getClass().getSuperclass().getDeclaredField("creationTime");
fld.setAccessible(true);
fld.set(responseData, creationTime);
this.responseDataRepository.saveAndFlush(responseData);
LOGGER.info("Response data record saved with correlationUid: {} and creationTime: {}", responseData.getCorrelationUid(), creationTime);
}
} catch (final Exception e) {
LOGGER.error("Exception", e);
Assertions.fail("Failed to create response data record in ws-core.");
}
return responseData;
}
use of org.opensmartgridplatform.cucumber.platform.glue.steps.database.ws.ResponseDataBuilder in project open-smart-grid-platform by OSGP.
the class WsPublicLightingResponseDataSteps method createResponseDataRecord.
private ResponseData createResponseDataRecord(final Map<String, String> settings, final ResponseDataRepository responseDataRepository) {
ResponseData responseData = new ResponseDataBuilder().fromSettings(settings).build();
responseData = responseDataRepository.save(responseData);
ScenarioContext.current().put(PlatformKeys.KEY_CORRELATION_UID, responseData.getCorrelationUid());
try {
// (as it will be overridden on first save)
if (settings.containsKey(PlatformKeys.KEY_CREATION_TIME)) {
final Field fld = responseData.getClass().getSuperclass().getDeclaredField("creationTime");
fld.setAccessible(true);
fld.set(responseData, DateTimeHelper.getDateTime(settings.get(PlatformKeys.KEY_CREATION_TIME)).toDate());
responseDataRepository.saveAndFlush(responseData);
}
} catch (final Exception e) {
LOGGER.error("Exception", e);
Assertions.fail("Failed to create response data record.");
}
return responseData;
}
use of org.opensmartgridplatform.cucumber.platform.glue.steps.database.ws.ResponseDataBuilder in project open-smart-grid-platform by OSGP.
the class WsMicrogridsResponseDataSteps method aResponseDataRecord.
@Given("^a response data record$")
@Transactional("txMgrWsMicrogrids")
public ResponseData aResponseDataRecord(final Map<String, String> settings) {
ResponseData responseData = new ResponseDataBuilder().fromSettings(settings).build();
responseData = this.microgridsResponseDataRepository.save(responseData);
ScenarioContext.current().put(PlatformKeys.KEY_CORRELATION_UID, responseData.getCorrelationUid());
try {
// (as it will be overridden on first save)
if (settings.containsKey(PlatformKeys.KEY_CREATION_TIME)) {
final Field fld = responseData.getClass().getSuperclass().getDeclaredField("creationTime");
fld.setAccessible(true);
fld.set(responseData, DateTimeHelper.getDateTime(settings.get(PlatformKeys.KEY_CREATION_TIME)).toDate());
this.microgridsResponseDataRepository.saveAndFlush(responseData);
}
} catch (final Exception e) {
LOGGER.error("Exception", e);
Assertions.fail("Failed to create response data record.");
}
return responseData;
}
use of org.opensmartgridplatform.cucumber.platform.glue.steps.database.ws.ResponseDataBuilder in project open-smart-grid-platform by OSGP.
the class WsSmartMeteringResponseDataSteps method aResponseDataRecord.
@Given("^a response data record$")
@Transactional("txMgrWsSmartMetering")
public ResponseData aResponseDataRecord(final Map<String, String> settings) {
final ResponseData responseData = this.smartMeteringResponseDataRepository.save(new ResponseDataBuilder().fromSettings(settings).build());
ScenarioContext.current().put(PlatformKeys.KEY_CORRELATION_UID, responseData.getCorrelationUid());
try {
// (as it will be overridden on first save)
if (settings.containsKey(PlatformKeys.KEY_CREATION_TIME)) {
final Field fld = responseData.getClass().getSuperclass().getDeclaredField("creationTime");
fld.setAccessible(true);
fld.set(responseData, DateTimeHelper.getDateTime(settings.get(PlatformKeys.KEY_CREATION_TIME)).toDate());
this.smartMeteringResponseDataRepository.saveAndFlush(responseData);
}
} catch (final Exception e) {
LOGGER.error("Exception", e);
Assertions.fail("Failed to create response data record.");
}
return responseData;
}
Aggregations