Created
June 6, 2018 18:18
-
-
Save shankybnl/bd739d15d0e35c165d0e48103b06e3b2 to your computer and use it in GitHub Desktop.
PilotSteps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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