Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PilotSteps.java
@Given("^Vehicle of pilot (\\d+) gets \"([^\"]*)\" by (\\d+) minutes")
public void vehicleOfPilotGetsByMinutes(long pilotId, String timeChange, int timeUpdateInMinutes) throws Throwable {
// Write code here that turns the phrase above into concrete actions
session = CrudOperations.createHibernateConnection();
List<PilotActivity> pilotActivity = session.createQuery("from PilotActivity where isActive=true order by id desc").setMaxResults(1).list();
DateTime currentExpectedStartTimeAtCreation = pilotActivity.get(0).getExpectedStartTimeAtCreation();
DateTime updatedStartTimeAtCreation;
if (timeChange.contains("delayed")) {
updatedStartTimeAtCreation = new DateTime(currentExpectedStartTimeAtCreation).plusMinutes(timeUpdateInMinutes);
} else {
updatedStartTimeAtCreation = new DateTime(currentExpectedStartTimeAtCreation).minusMinutes(timeUpdateInMinutes);
}
String updateExpectedStartTimeAtCreation = "update PilotActivity p set p.expectedStartTimeAtCreation = :updatedStartTimeAtCreation where p.pilotId = :pilotId";
query = session.createQuery(updateExpectedStartTimeAtCreation).setParameter("updatedStartTimeAtCreation", updatedStartTimeAtCreation)
.setParameter("pilotId", pilotId);
int result = query.executeUpdate();
LogUtil.info(result + " rows updated successfully");
CrudOperations.commitAndCloseHibernateConnection();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.