diff options
author | Andreas Fankhauser hiddenalpha.ch | 2024-08-13 18:17:03 +0200 |
---|---|---|
committer | Andreas Fankhauser hiddenalpha.ch | 2024-08-13 18:17:03 +0200 |
commit | 9587169d86de6064b7ff6d2e6fc5a41124945be1 (patch) | |
tree | 754c3c9efc0b680040b5fd8e959dd43f9a87b01c /src | |
parent | 89b3569688e00625f4f868005196f6e15104d098 (diff) | |
download | UnspecifiedGarbage-9587169d86de6064b7ff6d2e6fc5a41124945be1.zip UnspecifiedGarbage-9587169d86de6064b7ff6d2e6fc5a41124945be1.tar.gz |
Udpate misc notes.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/paisa-nonslim/foo.js | 16 | ||||
-rw-r--r-- | src/main/paisa-nonslim/patches/benjy.patch | 20 | ||||
-rw-r--r-- | src/main/paisa-nonslim/patches/blart.patch | 16 | ||||
-rw-r--r-- | src/main/paisa-nonslim/patches/caveman.patch | 26 | ||||
-rw-r--r-- | src/main/paisa-nonslim/patches/trillian.patch | 10477 |
5 files changed, 104 insertions, 10451 deletions
diff --git a/src/main/paisa-nonslim/foo.js b/src/main/paisa-nonslim/foo.js index 740bd36..ef08bcc 100644 --- a/src/main/paisa-nonslim/foo.js +++ b/src/main/paisa-nonslim/foo.js @@ -656,12 +656,9 @@ Related: function setPlatformVersionInService( app, thingyName, onDone ){ if( typeof onDone != "function" ) throw TypeError("onDone"); - TODO_vFICAIhVAgBuAgIA(); - function TODO_vFICAIhVAgBuAgIA(){ - getMangledPlatformVersion(app, updateParent); - } + getMangledPlatformVersion(app, updateParent); function updateParent( ex, mangledPlatformVersion ){ - if( !mangledPlatformVersion ){ onDone(Error("mangledPlatformVersion missing: "+ thingyName)); return; } + if( !mangledPlatformVersion ){ endFn(Error("mangledPlatformVersion missing: "+ thingyName)); return; } log.write("[DEBUG] "+ thingyName +" - Set platform version "+ mangledPlatformVersion +"\n"); var child = child_process.spawn( "mvn", ["versions:update-parent", "-DgenerateBackupPoms=false", "-DallowDowngrade=true", @@ -673,7 +670,7 @@ Related: child.stderr.on("data", logAsString); child.on("close", function( code, signal ){ if( code !== 0 || signal !== null ){ - onDone(Error("code "+ code +", signal "+ signal)); + endFn(Error("code "+ code +", signal "+ signal)); return; } updateProperty(mangledPlatformVersion); @@ -690,12 +687,15 @@ Related: child.stderr.on("data", logAsString); child.on("close", function( code, signal ){ if( code !== 0 || signal !== null ){ - onDone(Error("code "+ code +", signal "+ signal)); + endFn(Error("code "+ code +", signal "+ signal)); return; } - onDone(); + endFn(); }); } + function endFn( ex, ret ){ + onDone(ex, ret); + } } diff --git a/src/main/paisa-nonslim/patches/benjy.patch b/src/main/paisa-nonslim/patches/benjy.patch index 07c15b3..0129ff1 100644 --- a/src/main/paisa-nonslim/patches/benjy.patch +++ b/src/main/paisa-nonslim/patches/benjy.patch @@ -14,6 +14,26 @@ .executeSonar() +--- a/pom.xml ++++ b/pom.xml +@@ -32,6 +32,16 @@ + + </properties> + ++ <dependencyManagement> ++ <dependencies> ++ <dependency> ++ <groupId>jakarta.annotation</groupId> ++ <artifactId>jakarta.annotation-api</artifactId> ++ <version>3.0.0</version> <!-- TODO move this version somewhere else --> ++ </dependency> ++ </dependencies> ++ </dependencyManagement> ++ + <!-- All Projects which inherit setting from this parent project --> + <modules> + <module>benjy-web</module> + --- a/benjy-web/pom.xml +++ b/benjy-web/pom.xml diff --git a/src/main/paisa-nonslim/patches/blart.patch b/src/main/paisa-nonslim/patches/blart.patch index f517b0a..525c5e0 100644 --- a/src/main/paisa-nonslim/patches/blart.patch +++ b/src/main/paisa-nonslim/patches/blart.patch @@ -10,6 +10,22 @@ storage: [version: '00.24.00.00'], + +--- a/pom.xml ++++ b/pom.xml +@@ -83,6 +83,11 @@ + </exclusion> + </exclusions> + </dependency> ++ <dependency> ++ <groupId>org.eclipse.jetty.ee10</groupId> ++ <artifactId>jetty-ee10-webapp</artifactId> ++ <version>12.0.12</version> <!-- TODO move this version somewhere else --> ++ </dependency> + </dependencies> + </dependencyManagement> + + --- a/blart-web/pom.xml +++ b/blart-web/pom.xml @@ -84,6 +84,7 @@ diff --git a/src/main/paisa-nonslim/patches/caveman.patch b/src/main/paisa-nonslim/patches/caveman.patch index 1952ca9..0d95dc0 100644 --- a/src/main/paisa-nonslim/patches/caveman.patch +++ b/src/main/paisa-nonslim/patches/caveman.patch @@ -2,22 +2,40 @@ --- a/Jenkinsfile +++ b/Jenkinsfile -@@ -11,11 +11,11 @@ serviceBuildPipeline([ +@@ -10,13 +10,13 @@ + jslPipeline + .checkout() .setBranchVersion() -- .buildMaven([spotless: true, slim: true]) +- .buildMaven([spotless: true]) + .buildMaven([spotless: true]) .withInstances([ instances: [ testInstance: [ services: [ - eagle: [version: '02.01.19.00'], -- platform: [version: '03.06.44.00'], + eagle: [version: '02.01.26.01-PR-379-SNAPSHOT'], +- platform: [version: '03.06.40.01-PR-388-SNAPSHOT'], + platform: [version: '${j21.platform.version}'], storage: [version: '00.24.00.00'], caveman: [version: '%currentBranch%'] ] +--- a/pom.xml ++++ b/pom.xml +@@ -115,6 +115,11 @@ + <version>${jimfs.version}</version> + <scope>test</scope> + </dependency> ++ <dependency> ++ <groupId>org.eclipse.jetty.ee10</groupId> ++ <artifactId>jetty-ee10-webapp</artifactId> ++ <version>12.0.12</version> <!-- TODO move this version somewhere else --> ++ </dependency> + </dependencies> + </dependencyManagement> + + + --- a/caveman-web/pom.xml +++ b/caveman-web/pom.xml @@ -71,4 +71,5 @@ diff --git a/src/main/paisa-nonslim/patches/trillian.patch b/src/main/paisa-nonslim/patches/trillian.patch index 3691a49..b8106fe 100644 --- a/src/main/paisa-nonslim/patches/trillian.patch +++ b/src/main/paisa-nonslim/patches/trillian.patch @@ -2,10471 +2,70 @@ --- a/Jenkinsfile +++ b/Jenkinsfile -@@ -12,7 +12,7 @@ serviceBuildPipeline([ +@@ -13,7 +13,7 @@ jslPipeline .checkout() .setBranchVersion() -- .buildMaven([slim: true]) -+ .buildMaven() +- .buildMaven([spotless: false]) ++ .buildMaven([spotless: false]) .runKarma() .buildDocker() .withInstances([instances: [ -@@ -26,36 +26,36 @@ serviceBuildPipeline([ +@@ -20,44 +20,44 @@ + backend: [ + services: [ + houston: [version: '02.01.68.01-PR-519-SNAPSHOT'], +- platform: [version: '03.06.40.01-java-21-support-trillian-SNAPSHOT'], ++ platform: [version: '${j21.platform.version}'], + storage: [version: '00.24.00.00'], +- astra: [version: '04.00.11.01-PR-168-SNAPSHOT'] ++ astra: [version: '04.00.13.00'] + ] + ], vehicle1: [ services: [ - eagle: [version: '02.01.19.00'], -- platform: [version: '03.06.32.00'], -+ platform: [version: '0.0.0-SDCISA-15648-ed1d4665-SNAPSHOT'], + eagle: [version: '02.01.26.01-PR-379-SNAPSHOT'], +- platform: [version: '03.06.40.01-java-21-support-trillian-SNAPSHOT'], ++ platform: [version: '${j21.platform.version}'], storage: [version: '00.24.00.00'], trillian: [version: '%currentBranch%'], -- slarti: [version: '03.14.37.00'], -- zaphake: [version: '03.00.17.00'], -- megacamel: [version: '03.00.13.00'] -+ slarti: [version: '${j21.service.mangledVersion}'], -+ zaphake: [version: '${j21.service.mangledVersion}'], -+ megacamel: [version: '${j21.service.mangledVersion}'] +- slarti: [version: '03.15.12.01-PR-1019-SNAPSHOT'], ++ slarti: [version: '${j21.slarti.mangledVersion}'], + zaphake: [version: '03.00.22.01-PR-60-SNAPSHOT'], +- megacamel: [version: '03.00.15.01-PR-46-SNAPSHOT'] ++ megacamel: [version: '${j21.megacamel.mangledVersion}'] ], houstonInstance: 'backend' ], vehicle2: [ services: [ - eagle: [version: '02.01.19.00'], -- platform: [version: '03.06.32.00'], -+ platform: [version: '0.0.0-SDCISA-15648-ed1d4665-SNAPSHOT'], + eagle: [version: '02.01.26.01-PR-379-SNAPSHOT'], +- platform: [version: '03.06.40.01-java-21-support-trillian-SNAPSHOT'], ++ platform: [version: '${j21.platform.version}'], storage: [version: '00.24.00.00'], trillian: [version: '%currentBranch%'], -- slarti: [version: '03.14.37.00'], -- zaphake: [version: '03.00.17.00'], -- megacamel: [version: '03.00.13.00'] -+ slarti: [version: '${j21.service.mangledVersion}'], -+ zaphake: [version: '${j21.service.mangledVersion}'], -+ megacamel: [version: '${j21.service.mangledVersion}'] +- slarti: [version: '03.15.12.01-PR-1019-SNAPSHOT'], ++ slarti: [version: '${j21.slarti.mangledVersion}'], + zaphake: [version: '03.00.22.01-PR-60-SNAPSHOT'], +- megacamel: [version: '03.00.15.01-PR-46-SNAPSHOT'] ++ megacamel: [version: '${j21.megacamel.mangledVersion}'] ], houstonInstance: 'backend' ], vehicle3: [ services: [ - eagle: [version: '02.01.19.00'], -- platform: [version: '03.06.32.00'], -+ platform: [version: '0.0.0-SDCISA-15648-ed1d4665-SNAPSHOT'], + eagle: [version: '02.01.26.01-PR-379-SNAPSHOT'], +- platform: [version: '03.06.40.01-java-21-support-trillian-SNAPSHOT'], ++ platform: [version: '${j21.platform.version}'], storage: [version: '00.24.00.00'], trillian: [version: '%currentBranch%'], -- slarti: [version: '03.14.37.00'], -- zaphake: [version: '03.00.17.00'], -- megacamel: [version: '03.00.13.00'] -+ slarti: [version: '${j21.service.mangledVersion}'], -+ zaphake: [version: '${j21.service.mangledVersion}'], -+ megacamel: [version: '${j21.service.mangledVersion}'] +- slarti: [version: '03.15.12.01-PR-1019-SNAPSHOT'], ++ slarti: [version: '${j21.slarti.mangledVersion}'], + zaphake: [version: '03.00.22.01-PR-60-SNAPSHOT'], +- megacamel: [version: '03.00.15.01-PR-46-SNAPSHOT'] ++ megacamel: [version: '${j21.megacamel.mangledVersion}'] ], houstonInstance: 'backend' ] ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/CustomTypeRegistryConfigurer.java -+++ /dev/null -@@ -1,29 +0,0 @@ --package ch.post.it.paisa.trillian.test; -- --import io.cucumber.core.api.TypeRegistry; --import io.cucumber.core.api.TypeRegistryConfigurer; --import io.cucumber.cucumberexpressions.CaptureGroupTransformer; --import io.cucumber.cucumberexpressions.ParameterType; --import org.joda.time.DateTime; -- --import java.util.Locale; -- --public class CustomTypeRegistryConfigurer implements TypeRegistryConfigurer { -- @Override -- public Locale locale() { -- return Locale.ENGLISH; -- } -- -- @Override -- public void configureTypeRegistry(TypeRegistry typeRegistry) { -- // for date format '2020.1.1 09:55' -- typeRegistry.defineParameterType(new ParameterType<>("dateTime", "(\\d+).(\\d+).(\\d+) (\\d+):(\\d+)", -- DateTime.class, new CaptureGroupTransformer<DateTime>() { -- @Override -- public DateTime transform(final String[] args) throws Throwable { -- return new DateTime(Integer.parseInt(args[0]), Integer.parseInt(args[1]), -- Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4])); -- } -- }, false, false)); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/NotificationLabelConstants.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/NotificationLabelConstants.java -deleted file mode 100644 -index 94260fc..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/NotificationLabelConstants.java -+++ /dev/null -@@ -1,30 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test; -- --public class NotificationLabelConstants { -- public static final String CALL_DIAL_TEXT = "Rufaufbau..."; -- public static final String ACTIVE_CALL_LABEL = "Aktives Gespräch mit"; -- public static final String INCOMING_CALL_RING = "Eingehender Anruf"; -- public static final String INCOMING_CALL_LABEL = "Anruf von"; -- public static final String UNKNOWN_NUMBER = "Unbekannt"; -- public static final String CALL_ENDED_TEXT = "Der Anruf wurde beendet"; -- public static final String INCOMING_CALLER_ALPHA = "Douglas Adams (00359888148672)"; -- public static final String INCOMING_CALL_NUMBER = "00359888148672"; -- public static final String OUTGOING_CALL_NUMBER = "004179000777"; -- public static final String OUTGOING_CALLER_ALPHA = "Tom Tester (004179000777)"; -- public static final String DUMMY_DETAILS = "Linie 42, Andromeda links"; -- -- -- public static final int WAIT_TIME_AFTER_EVENT = 1000; -- public static final int WAIT_TIME_AFTER_EVENT_LONG = 3000; -- public static final int WAIT_TIME_AFTER_EVENT_CALLDURATION = 7000; -- public static final int WAIT_TIME_TIMEOUT = 12000; -- --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/RestAssuredSupport.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/RestAssuredSupport.java -deleted file mode 100644 -index 4e048fc..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/RestAssuredSupport.java -+++ /dev/null -@@ -1,117 +0,0 @@ --package ch.post.it.paisa.trillian.test; -- --import ch.post.it.paisa.alice.service.domain.core.json.ExtendedObjectMapper; --import com.fasterxml.jackson.core.JsonProcessingException; --import com.fasterxml.jackson.databind.ObjectMapper; --import io.restassured.mapper.ObjectMapperDeserializationContext; --import io.restassured.mapper.ObjectMapperSerializationContext; --import io.restassured.response.ValidatableResponse; --import org.apache.http.HttpStatus; -- --import java.io.IOException; -- --import static com.jayway.awaitility.Awaitility.await; --import static io.restassured.RestAssured.given; --import static java.util.concurrent.TimeUnit.MILLISECONDS; --import static java.util.concurrent.TimeUnit.SECONDS; -- --/** -- * Improved REST API access using rest assured capabilities. -- * <p> -- * Similar to ch.post.it.paisa.alice.service.test.core.rest.RestHelper but: -- * <p> -- * <ul> -- * <li> it contains also GET support. Especially the method waitForResource - it polls until -- * the resource is available. This way we don't need to defined hardcoded wait(timeout) -- * all along the e2e tests. -- * </li> -- * it provides imple variable replacement in method signature -- * <li> -- * <p> -- * </li> -- * </ul> -- */ --public class RestAssuredSupport { -- -- private static final ObjectMapper jsonMapper = new ExtendedObjectMapper(); -- -- public static ValidatableResponse get(String url, Object... pathParams) { -- try { -- return given() -- .contentType("application/json; charset=utf-8") -- .when().get(url, pathParams) -- .then().assertThat().statusCode(HttpStatus.SC_OK); -- } catch (Exception | AssertionError e) { -- throw new AssertionError("failed to get resource at " + url + ": " + e.getMessage()); -- } -- } -- -- public static <T> T waitForResource(String api, Class<T> cls, Object... pathParams) { -- final ValidatableResponse[] response = {null}; -- await() -- .with() -- .pollInterval(500, MILLISECONDS) -- .atMost(6, SECONDS) -- .until(() -> response[0] = get(api, pathParams)); -- return extractResponse(response[0], cls); -- } -- -- public static ValidatableResponse deleteResource(String url) { -- return given() -- .contentType("application/json; charset=utf-8") -- .when().delete(url) -- .then(); -- } -- -- public static <T> T putResource(String api, T resource, Object... pathParams) { -- String json = toJson(resource); -- put(api, json, pathParams); -- return resource; -- } -- -- public static <T> T extractResponse(ValidatableResponse response, Class<T> cls) { -- return response.extract().body().as(cls, restassuredJsonMapper(cls)); -- } -- -- public static <T> io.restassured.mapper.ObjectMapper restassuredJsonMapper(Class<T> cls) { -- return new io.restassured.mapper.ObjectMapper() { -- @Override -- public Object deserialize(ObjectMapperDeserializationContext context) { -- try { -- return jsonMapper.readValue(context.getDataToDeserialize().asString(), cls); -- } catch (IOException e) { -- throw new RuntimeException("failed to parse json", e); -- } -- } -- -- @Override -- public Object serialize(ObjectMapperSerializationContext context) { -- try { -- return jsonMapper.writeValueAsString(context.getObjectToSerialize()); -- } catch (JsonProcessingException e) { -- throw new RuntimeException("failed to write json", e); -- } -- } -- }; -- } -- -- public static void put(String url, String content, Object... pathParams) { -- try { -- given() -- .contentType("application/json; charset=utf-8") -- .body(content) -- .put(url, pathParams) -- .then().assertThat().statusCode(HttpStatus.SC_OK); -- } catch (Exception | AssertionError e) { -- throw new AssertionError("failed to put resource at " + url + ": " + e.getMessage()); -- } -- } -- -- private static String toJson(Object object) { -- try { -- return jsonMapper.writeValueAsString(object); -- } catch (JsonProcessingException e) { -- throw new IllegalArgumentException("could not serialize object to json", e); -- } -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/SeleniumContext.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/SeleniumContext.java -deleted file mode 100644 -index c2e4616..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/SeleniumContext.java -+++ /dev/null -@@ -1,52 +0,0 @@ --package ch.post.it.paisa.trillian.test; -- --import ch.post.it.paisa.alice.service.test.core.selenium.Browser; --import ch.post.it.paisa.alice.service.test.core.selenium.BrowserContext; --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.ui.TrillianSeleniumFactory; --import io.cucumber.core.api.Scenario; --import org.openqa.selenium.NoSuchElementException; --import org.openqa.selenium.StaleElementReferenceException; --import org.openqa.selenium.WebDriver; --import org.openqa.selenium.support.ui.FluentWait; --import org.openqa.selenium.support.ui.Wait; -- --import java.time.Duration; -- -- --public class SeleniumContext { -- private static final Browser browser = BrowserContext.createBrowser("trillian"); -- private static final WebDriver webDriver = browser.getWebDriver(); -- private static final SeleniumHelper seleniumHelper = new SeleniumHelper(browser); -- private static final TrillianSeleniumFactory trillianSeleniumFactory = new TrillianSeleniumFactory(webDriver, seleniumHelper); -- -- public static WebDriver getDriver() { -- return browser.getWebDriver(); -- } -- -- public static TrillianSeleniumFactory getTrillianSeleniumFactory() { -- return trillianSeleniumFactory; -- } -- -- public static SeleniumHelper getSeleniumHelper() { -- return seleniumHelper; -- } -- -- public static Wait<WebDriver> getWait() { -- return new FluentWait<>(webDriver) -- .withTimeout(Duration.ofSeconds(10)) -- .pollingEvery(Duration.ofMillis(200)) -- .ignoring(NoSuchElementException.class) -- .ignoring(StaleElementReferenceException.class); -- } -- -- public static void logIfFailed(Scenario scenario) { -- if (scenario.isFailed()) { -- BrowserContext.saveBrowserLogsAndScreenshot(scenario.getName()); -- } -- } -- -- public static void writeBrowserScreenshot(String name) { -- browser.takeScreenshot(name); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/TestPaths.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/TestPaths.java -deleted file mode 100644 -index b23f63f..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/TestPaths.java -+++ /dev/null -@@ -1,70 +0,0 @@ --package ch.post.it.paisa.trillian.test; -- --import ch.post.it.paisa.api.logloc.v1.path.LoglocAPI; --import ch.post.it.paisa.api.timetable.planner.v1.path.TimetablePlannerAPI; --import ch.post.it.paisa.api.timetable.registration.v1.path.TimetableRegistrationAPI; --import ch.post.it.paisa.api.timetable.wait.v1.path.TimetableWaitAPI; --import ch.post.it.paisa.api.vehicle.profile.v1.path.VehicleProfileAPI; --import ch.post.it.paisa.api.vehicle.v1.path.VehicleAPI; -- --import static org.springframework.util.Assert.notNull; -- --public class TestPaths { -- -- public static String getHoustonBaseUrl(){ -- return "http://" + HOUSTON_HOST + ":" + HOUSTON_PORT + HOUSTON_PATH; -- } -- -- public static String getEagle1BaseUrl() { -- return "http://" + EAGLE1_HOST + ":" + EAGLE1_PORT + EAGLE1_PATH; -- } -- -- public static String getEagle2BaseUrl() { -- String host = System.getProperty("server2.host", "localhost"); -- String port = System.getProperty("server2.port"); -- notNull(port, "missing 'server2.port' configuration for eagle server 2"); -- return "http://" + host + ":" + port + "/eagle"; -- } -- -- public static String getEagle3BaseUrl() { -- String host = System.getProperty("server3.host", "localhost"); -- String port = System.getProperty("server3.port"); -- notNull(port, "missing 'server3.port' configuration for eagle server 3"); -- return "http://" + host + ":" + port + "/eagle"; -- } -- -- -- public static String HOUSTON_HOST = System.getProperty("server.host", "localhost"); -- public static String HOUSTON_PORT = System.getProperty("server.port", "7013"); -- public static String HOUSTON_PATH = "/houston"; -- -- public static String EAGLE1_HOST = System.getProperty("server1.host", "localhost"); -- public static String EAGLE1_PORT = System.getProperty("server1.port", "7012"); -- public static String EAGLE1_PATH = "/eagle"; -- -- public static final String TRILLIAN_1_SERVICE_BASE_URL = getEagle1BaseUrl() + "/services/trillian"; -- -- public static final String GSM_STREAM_MOCK_SERVICES = TRILLIAN_1_SERVICE_BASE_URL + "/services/mock/GSMStreamMock/readFromGSM"; -- public static final String TRILLIAN_GSM_SERVICE_HANGUP = TRILLIAN_1_SERVICE_BASE_URL + "/services/rest/GSMService/hangup"; -- public static final String NOTIFICATION_DIRECTLY_OVER_EAGLE = getEagle1BaseUrl() + "/notifications/channels/messages"; -- public static final String CALLLOG_URL_BASEURL = getEagle1BaseUrl() + "/communication/v1/calllog/calls"; -- public static final String TRIP_INITIALIZATION = getEagle1BaseUrl() + TimetableRegistrationAPI.trip.initialization.RESOURCE; -- public static final String TRIP_POSITION = getEagle1BaseUrl() + LoglocAPI.trips.current.position.RESOURCE; -- public static final String WAIT_TRIPS = getEagle1BaseUrl() + TimetableWaitAPI.trips.RESOURCE; -- public static final String WAIT_CONFIRMATION = getEagle1BaseUrl() + TimetableWaitAPI.trips.fetcherTripInstanceId$.stops.fetcherStopId$.departures.departureTime$.confirmation.RESOURCE; -- public static final String SELECTED_INBOUND_CONNECTION = getEagle1BaseUrl() + "/data/trillian/trips/{fetcherTripInstanceId}/stops/{fetcherStopId}/departures/{departureTime}/connections/inbound/selected"; -- public static final String ACTIVE_CALL_URL = getEagle1BaseUrl() + "/communication/v1/activeCall"; -- public static final String COMMUNICATION_MESSAGE_PATH = getEagle1BaseUrl() + "/communication/messaging/v1"; -- -- public static String DEPARTUREBOARD_URL = getEagle1BaseUrl() + TimetablePlannerAPI.departureboard.RESOURCE; -- -- public final static String SLARTI_1_START_PAGE = getEagle1BaseUrl() + "/services/slarti/index.html"; -- -- private final static String VEHICLE_PATH = "/vehicles/{vehicleId}"; -- public final static String VEHICLE_PROFILE_IDENTIFICATION_PATH = VEHICLE_PATH + VehicleProfileAPI.identification.RESOURCE; -- -- public final static String VEHICLE_CONTACT_PATH = "/from/vehicles/{vehicleId}" + VehicleAPI.profile.contact.RESOURCE; -- -- public final static String VEHICLE_PROFILE_AFFILIATION_PATH = VEHICLE_PATH + VehicleProfileAPI.affiliation.RESOURCE; -- --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/TrillianTestRestHelper.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/TrillianTestRestHelper.java -deleted file mode 100644 -index 65ee46d..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/TrillianTestRestHelper.java -+++ /dev/null -@@ -1,357 +0,0 @@ --package ch.post.it.paisa.trillian.test; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.communication.messaging.v1.TextMessage; --import ch.post.it.paisa.api.communication.v1.CallInfo; --import ch.post.it.paisa.api.communication.v1.path.CommunicationAPI; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.SyncSpeed; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.Timings; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.path.PAISAControlcenterPhonebookAPI; --import ch.post.it.paisa.api.notifications.v1.Notification; --import ch.post.it.paisa.api.timetable.common.v1.TripInstance; --import ch.post.it.paisa.api.timetable.wait.v1.WaitConfirmation; --import ch.post.it.paisa.api.timetable.wait.v1.WaitRecommendation; --import ch.post.it.paisa.api.timetable.wait.v1.WaitReport; --import ch.post.it.paisa.api.timetable.wait.v1.WaitRequest; --import ch.post.it.paisa.api.timetable.wait.v1.path.TimetableWaitAPI; --import ch.post.it.paisa.api.vehicle.messaging.v1.path.PAISAVehicleMessagingAPI; --import ch.post.it.paisa.api.vehicle.profile.v1.Affiliation; --import ch.post.it.paisa.api.vehicle.status.v3.PlanningArea; --import ch.post.it.paisa.api.vehicle.status.v3.path.VehicleStatusAPI; --import io.restassured.RestAssured; --import io.restassured.response.Response; --import org.apache.http.HttpStatus; --import org.joda.time.DateTime; --import org.joda.time.format.DateTimeFormat; --import org.joda.time.format.DateTimeFormatter; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; --import org.springframework.web.client.RestClientException; -- --import java.security.MessageDigest; --import java.util.*; --import java.util.stream.Collectors; -- --import static ch.post.it.paisa.trillian.test.RestAssuredSupport.waitForResource; --import static ch.post.it.paisa.trillian.test.TestPaths.*; --import static ch.post.it.paisa.trillian.test.ui.ControllerTest.ensurePresent; --import static com.jayway.awaitility.Awaitility.await; --import static io.restassured.RestAssured.given; --import static java.util.Collections.emptyList; --import static java.util.concurrent.TimeUnit.MILLISECONDS; --import static java.util.concurrent.TimeUnit.SECONDS; -- --public class TrillianTestRestHelper { -- -- private static final Logger LOG = LoggerFactory.getLogger(TrillianTestRestHelper.class); -- private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormat.forPattern("HHmmss"); -- public static final Integer DEFAULT_PLANNING_AREA_ID = 1; -- public static final String DEFAULT_VEHICLE = "vehicle_1"; -- public static final String DEFAULT_PHONEBOOK_ID = "SELENIUM_TEST_PHONEBOOK"; -- public static final String DEFAULT_PHONEBOOK_NAME = "SELENIUM_TEST_PHONEBOOK_NAME"; -- -- -- // Api specific URLs -- private TrillianTestRestHelper() { -- } -- -- -- /** -- * Sends a text message -- * <p> -- * When creating the object a random UUID is generated -- * This UUID is then returned so that the caller can -- * do something with the created message later -- * (maybe delete generated test data) -- */ -- public static String sendMessage(final String text, final boolean confirm) { -- final TextMessage message = new TextMessage(); -- message.setTimestamp(DateTime.now()); -- message.setText(text); -- message.setAcknowledge(confirm); -- message.setUuid(UUID.randomUUID().toString()); -- message.setRecipientVehicleId("martin.pnet.ch"); -- message.setSenderVehicleId("SENDER"); -- RestHelper.put(message, COMMUNICATION_MESSAGE_PATH + "/text/message/" + message.getUuid()); -- return message.getUuid(); -- } -- -- -- /** -- * Deletes a message by the specified UUID -- * <p> -- * Also deletes the respective acknowledge object for the message -- */ -- public static void deleteTextMessageById(final String uuid) { -- RestHelper.del(COMMUNICATION_MESSAGE_PATH + "/text/message/" + uuid); -- } -- -- public static void deletePhonebook(final String phonebookId) { -- deletePhonebook(DEFAULT_PLANNING_AREA_ID, phonebookId); -- } -- -- public static void deletePhonebook(final Integer planningAreaId, final String phonebookId) { -- final String bookUrl = PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.RESOURCE -- .replace("{planningAreaId}", planningAreaId.toString()) -- .replace("{bookId}", phonebookId); -- -- final String bookInfoUrl = PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE -- .replace("{planningAreaId}", planningAreaId.toString()) -- .replace("{bookId}", phonebookId); -- -- RestHelper.del(getHoustonBaseUrl() + bookUrl); -- RestHelper.del(getHoustonBaseUrl() + bookInfoUrl); -- -- RestHelper.del(getEagle1BaseUrl() + bookUrl); -- RestHelper.del(getEagle1BaseUrl() + bookInfoUrl); -- } -- -- public static void deleteVehicleMessagingNotifications() { -- RestHelper.del(getEagle1BaseUrl() + PAISAVehicleMessagingAPI.notifications.RESOURCE); -- } -- -- -- public static void putSyncParametersToHouston() { -- SyncSpeed syncSpeed = new SyncSpeed(); -- Timings timings = new Timings().withRepetitionIntervalSeconds(2); -- timings.setCollectionWindowSizeSeconds(2); -- syncSpeed.setBooks(timings); -- syncSpeed.setDrivers(timings); -- syncSpeed.setVehicles(timings); -- syncSpeed.setVehicleContacts(timings); -- RestHelper.put(syncSpeed, getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.sync.parameter.RESOURCE); -- } -- -- public enum GsmEvent { -- CLIP("+CLIP: \"" + NotificationLabelConstants.INCOMING_CALL_NUMBER + "\",145,,,,0"), -- RING("+CRING: VOICE"), -- NO_CARRIER("NO CARRIER"), -- BUSY("BUSY"), -- OK("OK"), -- CONNECT("CONNECT"), -- COLP("+COLP: \"0888148672\",129,,,"); -- -- private final String eventString; -- -- GsmEvent(final String eventString) { -- this.eventString = eventString; -- } -- -- public String getEventString() { -- return eventString; -- } -- } -- -- public static void triggerEvent(final GsmEvent event) { -- RestAssured.given(). -- contentType("application/json"). -- given().body(event.getEventString()).put(GSM_STREAM_MOCK_SERVICES, new Object[0]); -- } -- -- -- public static void hangup() { -- if (isCallStatusActive()) { -- RestHelper.put(TRILLIAN_GSM_SERVICE_HANGUP); -- } -- } -- -- public static void putSlartiNotification(final Notification notification) { -- RestHelper.put(notification, NOTIFICATION_DIRECTLY_OVER_EAGLE + "/" + notification.getMessage().getId()); -- } -- -- public static void addCallLogEntry(final CallInfo callLogEntry) { -- RestHelper.put(callLogEntry, CALLLOG_URL_BASEURL + "/" + callLogEntry.getId()); -- } -- -- -- public static void waitUntilPhonebooksSynced(Integer planningAreaId, int expectedContacts) { -- if (expectedContacts >= 0) { -- LOG.info("Expected contacts to be found on server : " + expectedContacts); -- final String urlContacts = getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.contacts.RESOURCE.replace("{planningAreaId}", planningAreaId.toString()).replace("{bookId}", DEFAULT_PHONEBOOK_ID); -- await() -- .with() -- .pollInterval(1000, MILLISECONDS) -- .atMost(60, SECONDS) -- .until(() -> { -- int contactSize = getIdsOfItemsInCollection(urlContacts).size(); -- LOG.info("Contacts found on server : " + contactSize); -- return contactSize == expectedContacts; -- }); -- } -- final String urlInfo = getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE.replace("{planningAreaId}", planningAreaId.toString()).replace("{bookId}", DEFAULT_PHONEBOOK_ID); -- await() -- .with() -- .pollInterval(1000, MILLISECONDS) -- .atMost(60, SECONDS) -- .until(() -> RestAssured.when().get(urlInfo, new Object[0]).getStatusCode() == HttpStatus.SC_OK); -- } -- -- public static void waitUntilPhonebooksSynced(int expectedContacts) { -- waitUntilPhonebooksSynced(DEFAULT_PLANNING_AREA_ID, expectedContacts); -- } -- -- public static void waitUntilPhonebooksSynced() { -- waitUntilPhonebooksSynced(DEFAULT_PLANNING_AREA_ID, -1); -- } -- -- -- public static void publishCurrentPlanningArea(Integer planningAreaId) { -- RestHelper.put(new PlanningArea().withPlanningAreaId(planningAreaId), getEagle1BaseUrl() + VehicleStatusAPI.current.planningarea.RESOURCE); -- } -- -- public static void clearCallLog() { -- RestHelper.del(CALLLOG_URL_BASEURL); -- } -- -- /** -- * Sends the wait recommendation to the server -- */ -- public static void putWaitRecommendation(final WaitRecommendation wr) { -- final String depTime = TIME_FORMATTER.print(wr.getFetcher().getDepartureTime()); -- String url = getEagle1BaseUrl() + TimetableWaitAPI.trips.fetcherTripInstanceId$.stops.fetcherStopId$.departures.departureTime$.recommendation.RESOURCE; -- url = url.replace("{fetcherTripInstanceId}", wr.getFetcher().getTripInstanceId()); -- url = url.replace("{fetcherStopId}", wr.getFetcher().getDepartureStopId()); -- url = url.replace("{departureTime}", depTime); -- RestHelper.put(wr, url); -- ensurePresent(url); -- } -- -- public static void putTripInstanceInformationToZaphake(TripInstance... tripInstances) { -- RestHelper.post("{}", getEagle1BaseUrl() + "/services/zaphake/fpd/stop"); -- -- ZaphakeMockData zaphakeMockData = new ZaphakeMockData(); -- for (TripInstance tripInstance : tripInstances) { -- zaphakeMockData.addTripForBlock(tripInstance.getBlockNumber(), tripInstance); -- } -- RestHelper.put(zaphakeMockData, getEagle1BaseUrl() + "/data/zaphake/mock-data/mock-data-1"); -- RestHelper.post("{}", getEagle1BaseUrl() + "/services/zaphake/fpd/start"); -- } -- -- public static void publishDefaultAffiliation(String vehicleId) { -- Affiliation affiliation = new Affiliation(); -- affiliation.setFunctionalLocationId("dummy"); -- affiliation.setRegionId("dummy"); -- affiliation.setMainOperationGroup("dummy"); -- affiliation.setPlanningAreaId(DEFAULT_PLANNING_AREA_ID); -- -- String url = getHoustonBaseUrl() + VEHICLE_PROFILE_AFFILIATION_PATH.replace("{vehicleId}", vehicleId); -- -- RestHelper.put(affiliation, url); -- } -- -- /** -- * Adds a waitReport -- */ -- public static void putWaitReport(final WaitReport waitReport) { -- if (waitReport != null) { -- final String arrivalTime = TIME_FORMATTER.print(waitReport.getFeeder().getArrivalTime()); -- final String feederTripInstanceId = waitReport.getFeeder().getTripInstanceId(); -- final String feederStopId = waitReport.getFeeder().getArrivalStopId(); -- String url = getEagle1BaseUrl() + TimetableWaitAPI.trips.feederTripInstanceId$.stops.feederStopId$.arrivals.arrivalTime$.report.RESOURCE; -- url = url.replace("{feederTripInstanceId}", feederTripInstanceId); -- url = url.replace("{feederStopId}", feederStopId); -- url = url.replace("{arrivalTime}", arrivalTime); -- RestHelper.put(waitReport, url); -- -- -- // TODO: make sure it arrived on the rest endpoint used by the UI -- // http://ngu:7014/eagle/services/trillian/services/rest/connections/40-45/42/100400/10050 -- -- } -- } -- -- -- /** -- * Gets the waiting confirmation for the provided Waiting Recommendation if exists -- * <p> -- * Note that in case of 404 not found, the html error text will be returned, no exceptions -- */ -- public static WaitConfirmation getWaitConfirmation(final WaitRecommendation waitRecommendation) { -- final String fetcherTripInstanceId = waitRecommendation.getFetcher().getTripInstanceId(); -- final String fetcherStopId = waitRecommendation.getFetcher().getDepartureStopId(); -- final DateTimeFormatter fmt = DateTimeFormat.forPattern("HHmmss"); -- final String departureTime = fmt.print(waitRecommendation.getFetcher().getDepartureTime()); -- final String url = getEagle1BaseUrl() + TimetableWaitAPI.trips.fetcherTripInstanceId$.stops.fetcherStopId$.departures.departureTime$.confirmation.RESOURCE; -- return waitForResource(url, WaitConfirmation.class, fetcherTripInstanceId, fetcherStopId, departureTime); -- -- } -- -- /** -- * Returns the wait request -- */ -- public static WaitRequest getWaitRequest(final WaitReport waitReport) { -- if (waitReport == null) { -- return null; -- } -- String url = getEagle1BaseUrl() + TimetableWaitAPI.trips.feederTripInstanceId$.stops.feederStopId$.arrivals.arrivalTime$.request.RESOURCE; -- return waitForResource(url, WaitRequest.class, waitReport.getFeeder().getTripInstanceId(), waitReport.getFeeder().getArrivalStopId(), TIME_FORMATTER.print(waitReport.getFeeder().getArrivalTime())); -- } -- -- public static void putActiveCall(final CallInfo activeCall) { -- RestHelper.put(activeCall, ACTIVE_CALL_URL); -- } -- -- public static void deleteActiveCall() { -- RestHelper.del(ACTIVE_CALL_URL); -- } -- -- public static void deleteActiveCallOnAllVehicles() { -- RestHelper.del(ACTIVE_CALL_URL); -- RestHelper.del(getEagle2BaseUrl() + CommunicationAPI.activeCall.RESOURCE); -- RestHelper.del(getEagle3BaseUrl() + CommunicationAPI.activeCall.RESOURCE); -- } -- -- /** -- * Checks if there is an active call at the eagle -- * <p> -- * If the response to the active call is not empty and with status 200, -- * then the user is currently in a call -- */ -- public static boolean isCallStatusActive() { -- final Response r = RestAssured.given().get(ACTIVE_CALL_URL); -- return r.getStatusCode() == 200; -- } -- -- public static List<String> getIdsOfItemsInCollection(final String url, final Object... uriVariables) { -- try { -- Response response = given() -- .contentType("application/json; charset=utf-8") -- .get(url, uriVariables); -- -- if (response.statusCode() == 200) { -- @SuppressWarnings("unchecked") final Map<String, List<String>> idMap = response.body().as(HashMap.class, -- RestAssuredSupport.restassuredJsonMapper(HashMap.class)); -- -- if (idMap.values().isEmpty()) { -- return emptyList(); -- } -- -- return idMap -- .values() -- .iterator() -- .next() -- .stream() -- .filter(v -> !"empty".equals(v)) -- .map(v -> v.endsWith("/") ? v.substring(0, v.length() - 1) : v) -- .collect(Collectors.toList()); -- } else { -- return emptyList(); -- } -- } catch (final RestClientException e) { // NOSONAR -- LOG.warn("Unable to GET Object IDs from " + url); -- return emptyList(); -- } -- } -- -- public static String generateContactId(String name, String phoneNumber, MessageDigest messageDigest) { -- messageDigest.update((name + phoneNumber).getBytes()); -- // Side note #1: this id will appear in URLs -- // Side note #2: digest() will also reset() -- return base64ToUrlSafe(Base64.getEncoder().encodeToString(messageDigest.digest())); -- } -- -- public static String base64ToUrlSafe(String base64EncodedString) { -- return base64EncodedString.replaceAll("[\\+\\=\\/]", ""); -- } -- --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ZaphakeMockData.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ZaphakeMockData.java -deleted file mode 100644 -index ad39697..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ZaphakeMockData.java -+++ /dev/null -@@ -1,30 +0,0 @@ --package ch.post.it.paisa.trillian.test; -- --import ch.post.it.paisa.api.timetable.common.v1.TripInstance; --import com.fasterxml.jackson.annotation.JsonAutoDetect; -- --import java.util.ArrayList; --import java.util.HashMap; --import java.util.List; --import java.util.Map; -- --import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY; --import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; -- --/** -- * So we can put fake Trip information data to Timetable Information API and query it. -- */ --@JsonAutoDetect(fieldVisibility = ANY, setterVisibility = NONE, getterVisibility = NONE, isGetterVisibility = NONE) --public class ZaphakeMockData { -- private Map<String, List<TripInstance>> tripsPerBlock = new HashMap<>(); -- private List<String> proposals = new ArrayList<>(); -- -- public void addTripForBlock(String blockNumber, TripInstance tripInstance) { -- List<TripInstance> tripInstances = tripsPerBlock.get(blockNumber); -- if (tripInstances == null) { -- tripInstances = new ArrayList<>(); -- tripsPerBlock.put(blockNumber, tripInstances); -- } -- tripInstances.add(tripInstance); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/AbstractPhonebookSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/AbstractPhonebookSteps.java -deleted file mode 100644 -index 83ef582..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/AbstractPhonebookSteps.java -+++ /dev/null -@@ -1,79 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNavigation; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import org.openqa.selenium.By; --import org.openqa.selenium.StaleElementReferenceException; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.ui.WebDriverWait; -- --import java.time.Duration; --import java.util.List; -- --/** -- * Class AbstracPhonebookSteps. -- * This represents the common class for the phonebooktests. -- * -- * @author hoferchr -- * @version $$Revision$$ -- */ --public class AbstractPhonebookSteps extends AbstractSteps { -- -- protected static final int PHONE_BOOK_SELECTION_RETRY_COUNTER = 5; -- protected static final int PHONE_BOOK_SELECTION_RETRY_SLEEP_TIME = 5000; -- protected static final String VEHICLES_PHONEBOOK_NAME = "all_active_vehicles"; -- public static final int HOUSTON_WAIT_TIME = 2000; -- public static final String ACTIVE_VEHICLES_TRANSLATION = "Aktive Fahrzeuge Planungsbereich "; -- -- protected String getPhoneBookName(String phonebookKeyName, Integer planningarea) { -- if (!VEHICLES_PHONEBOOK_NAME.equals(phonebookKeyName)) { -- return phonebookKeyName; -- } -- return ACTIVE_VEHICLES_TRANSLATION + planningarea; -- } -- -- protected WebElement getPhonebook(String phonebookKeyName, Integer planningAreaId) { -- return getPhoneBookSelectionDiv().findElement( -- By.xpath("//button/span[text()='" + getPhoneBookName(phonebookKeyName, planningAreaId) + "']//parent::button")); -- } -- -- protected WebElement getPhoneBookSelectionDiv() { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- new WebDriverWait(driver, Duration.ofSeconds(10)) -- .ignoring(StaleElementReferenceException.class) -- .until(driver -> { -- List<WebElement> elements = driver.findElement(By.className("linti-menu-clearing")).findElements(By.tagName("div")); -- if (elements.size() > 0) { -- return true; -- } -- return false; -- }); -- -- return driver.findElement(By.className("linti-menu-clearing")).findElement(By.tagName("div")); -- } -- -- protected void waitForHoustonAction() { -- try { -- Thread.sleep(HOUSTON_WAIT_TIME); -- } catch (InterruptedException e) { -- // Do nothing -- } -- } -- -- protected void navigateToOverviewAndThenToPhonebookSelection() { -- try { -- final SlartiNavigation slartiNavigation = new SlartiNavigation(driver, seleniumHelper); -- slartiNavigation.touchTrillianModule(); -- BaseTestTrillian.switchToFrame("module-Trillian"); -- OverviewPage overviewPage = factory.getOverviewPage(); -- overviewPage.touchGoToPhonebookButton(); -- slartiNavigation.touchTrillianSideMenuByXpathStringSelector("shortcutmenu-Communication", "shortcutmenu-PhonebookSelection"); -- Thread.sleep(PHONE_BOOK_SELECTION_RETRY_SLEEP_TIME); -- } catch (InterruptedException ignore) { -- } -- } -- -- --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallLogSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallLogSteps.java -deleted file mode 100644 -index d3a6ebd..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallLogSteps.java -+++ /dev/null -@@ -1,140 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.communication.phonebook.v1.PhonebookEntry; --import ch.post.it.paisa.api.communication.phonebook.v1.PhonebookEntryType; --import ch.post.it.paisa.api.communication.v1.CallDirection; --import ch.post.it.paisa.api.communication.v1.CallInfo; --import ch.post.it.paisa.api.communication.v1.Contact; --import ch.post.it.paisa.api.communication.v1.path.CommunicationAPI; --import ch.post.it.paisa.trillian.test.TestPaths; --import ch.post.it.paisa.trillian.test.TrillianTestRestHelper; --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNavigation; --import ch.post.it.paisa.trillian.test.ui.mock.MockInstances; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Given; --import io.cucumber.java.en.Then; --import org.joda.time.DateTime; --import org.junit.Assert; --import org.openqa.selenium.By; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.ui.ExpectedConditions; --import org.springframework.util.StringUtils; -- --import java.util.List; --import java.util.Map; --import java.util.Objects; --import java.util.UUID; -- --import static ch.post.it.paisa.trillian.test.TestPaths.getEagle1BaseUrl; -- --public class CallLogSteps extends AbstractSteps { -- private final static String CALLLOG_URL_BASEURL = getEagle1BaseUrl() + "/communication/v1/calllog/calls"; -- private final static String XPATH_CALLOG_GLOBAL_ENTRIES = "//*[@id='callLogEntry']//li"; -- private final static String XPATH_CALLOG_ENTRY_CALL_TRIGGER_ADDON = "/a[1]"; -- -- @And("^Clear Call log$") -- public void clearCallLog() { -- RestHelper.del(CALLLOG_URL_BASEURL); -- } -- -- @And("^We click call entry at index (\\d+)$") -- public void clickCallEntryAtIndex(int xpathIndex) { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- WebElement el = BaseTestTrillian.getWait().until(ExpectedConditions.presenceOfElementLocated(By.xpath(XPATH_CALLOG_GLOBAL_ENTRIES -- + "[" + xpathIndex + "]" -- + XPATH_CALLOG_ENTRY_CALL_TRIGGER_ADDON))); -- -- el.click(); -- } -- -- @Given("^The following calllog entries are put$") -- public void theFollowingCalllogEntryIsPut(DataTable dataTable) { -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String name = row.get(0); -- String phoneNumber = row.get(1); -- -- final CallInfo entry = new CallInfo(); -- PhonebookEntry phonebookEntry = new PhonebookEntry(); -- phonebookEntry.setName(name); -- phonebookEntry.setPhoneNumber(phoneNumber); -- phonebookEntry.setType(PhonebookEntryType.DRIVER); -- entry.setDirection(CallDirection.OUT); -- entry.setName(name); -- -- entry.setPhoneNumber(phoneNumber); -- entry.setPhoneBookEntry(phonebookEntry); -- entry.setId(UUID.randomUUID().toString()); -- final DateTime initialTime = DateTime.now(); -- entry.setTime(initialTime.minusMinutes(4)); -- entry.setRejectTime(initialTime.minusMinutes(4).plusSeconds(5)); -- TrillianTestRestHelper.addCallLogEntry(entry); -- } -- } -- -- @Then("^We open the calllog view and wait for title$") -- public void openTheCalllogViewAndWaitForTitle() { -- final SlartiNavigation slartiNavigation = new SlartiNavigation(driver, seleniumHelper); -- slartiNavigation.touchTrillianModule(); -- BaseTestTrillian.switchToFrame("module-Trillian"); -- OverviewPage overviewPage = factory.getOverviewPage(); -- overviewPage.touchGoToCalllogButton(); -- BaseTestTrillian.getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("trillianCalllogTitle"))); -- } -- -- @Given("^Reset mock server on houston$") -- public void configureMockServerOnHouston() { -- MockInstances.getHouston().reset(); -- } -- -- @Given("^Reset mock server on all eagles$") -- public void resetMockServerOnEagle() { -- MockInstances.resetAllEagles(); -- } -- -- @Then("A call contact is POST with the following properties") -- public void aCallContactIsPOSTWithTheFollowingProperties(DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- String phoneNumber = data.get("phoneNumber"); -- String description = data.get("description"); -- String suppressNumber = data.get("suppressNumber"); -- Contact contact = new Contact() -- .withDescription(description) -- .withPhoneNumber(phoneNumber) -- .withSuppressNumber(Boolean.valueOf(suppressNumber)); -- RestHelper.post(contact, TestPaths.getEagle1BaseUrl() + CommunicationAPI.call.contact.RESOURCE); -- } -- -- @Then("The colllog view shows the call logs below") -- public void theColllogViewShowsTheCallLogsBelow(DataTable dataTable) { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- List<WebElement> callLogEntryList = seleniumHelper.getWebElements(XPATH_CALLOG_GLOBAL_ENTRIES); -- List<List<String>> rows = dataTable.asLists(String.class); -- -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String direction = row.get(0); -- String name = row.get(1); -- String phoneNumber = row.get(2); -- -- String directionIcon = Objects.equals(direction, "OUTGOING") ? "icon-phone-outgoing" : "icon-phone-incoming"; -- -- WebElement callLogEntry = callLogEntryList.get(i - 1); -- -- Assert.assertNotNull(callLogEntry.findElement(By.className(directionIcon))); -- Assert.assertEquals(name, callLogEntry.findElement(By.id("callLogTitle")).getText()); -- -- if (StringUtils.hasText(phoneNumber)) { -- Assert.assertEquals(phoneNumber, callLogEntry.findElement(By.id("callLogPhoneNumber")).getText()); -- } else { -- Assert.assertEquals(0, callLogEntry.findElements(By.id("callLogPhoneNumber")).size()); -- } -- } -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallLogUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallLogUiTest.java -deleted file mode 100644 -index 1e37873..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallLogUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions( glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/callLog.feature", plugin = { "pretty", "html:target/cucumber/callLog", "json:target/cucumber.callLog.json" }) --public class CallLogUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallRequestSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallRequestSteps.java -deleted file mode 100644 -index eb2270e..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallRequestSteps.java -+++ /dev/null -@@ -1,249 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.communication.messaging.v1.path.CommunicationMessagingAPI; --import ch.post.it.paisa.api.communication.modem.v1.CallState; --import ch.post.it.paisa.api.communication.modem.v1.Direction; --import ch.post.it.paisa.api.communication.modem.v1.State; --import ch.post.it.paisa.api.communication.modem.v1.path.CommunicationModemAPI; --import ch.post.it.paisa.api.vehicle.messaging.v1.CallRequest; --import ch.post.it.paisa.slarti.test.ui.elements.Notifications; --import ch.post.it.paisa.trillian.test.TestPaths; --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNavigation; --import ch.post.it.paisa.trillian.test.ui.pages.MessagingPage; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import com.jayway.awaitility.Duration; --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Then; --import io.cucumber.java.en.When; --import io.restassured.RestAssured; --import org.apache.http.HttpStatus; --import org.joda.time.DateTime; --import org.junit.Assert; --import org.openqa.selenium.By; --import org.openqa.selenium.TimeoutException; --import org.openqa.selenium.WebElement; -- --import java.util.Arrays; --import java.util.List; --import java.util.Map; -- --import static ch.post.it.paisa.trillian.test.RestAssuredSupport.waitForResource; --import static ch.post.it.paisa.trillian.test.TestPaths.getEagle1BaseUrl; --import static ch.post.it.paisa.trillian.test.TestPaths.getHoustonBaseUrl; --import static com.jayway.awaitility.Awaitility.given; --import static java.util.concurrent.TimeUnit.SECONDS; --import static org.junit.Assert.assertEquals; --import static org.junit.Assert.assertTrue; -- --public class CallRequestSteps extends AbstractSteps { -- -- @When("^We PUT a call request resource via Houston to \"(.+)\" with the following parameters$") -- public void We_PUT_a_call_request_response_via_Houston_to_vehicle_with_the_following_parameters(String vehicleId, DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- String phoneNumber = data.get("phoneNumber"); -- String name = data.get("name"); -- String withPriority = data.get("withPriority"); -- -- CallRequest callRequest = new CallRequest(); -- callRequest.setPhoneNumber(phoneNumber); -- callRequest.setName(name); -- callRequest.setWithPriority(Boolean.valueOf(withPriority)); -- callRequest.setPlanningAreaId(999); -- -- final String url = getHoustonBaseUrl() + "/to/vehicles/" + vehicleId + CommunicationMessagingAPI.callrequest.RESOURCE; -- -- RestHelper.put(callRequest, url); -- } -- -- @When("^A call request is displayed with name \"(.+)\", phone number \"(.+)\", and button \"(.+)\"$") -- public void A_call_request__is_displayed_with_name_phone_number_and_button(String name, String phoneNumber, String buttonText) { -- MessagingPage messagingPage = factory.getMessagingPage(); -- messagingPage.assertCallRequest(name, phoneNumber, buttonText); -- } -- -- @Then("^A call request is displayed with name \"(.+)\", phone number \"(.+)\"$") -- public void A_call_request_is_displayed_with_name_phone_number(String expectedName, String expectedPhoneNumber) { -- MessagingPage messagingPage = factory.getMessagingPage(); -- Assert.assertTrue(messagingPage.isMessagePresent(expectedName, expectedPhoneNumber)); -- } -- -- @Then("^A call request resource is present on \"(.+)\" NOT containing the key \"(.+)\"$") -- public void A_call_request_resource_is_present_on_vehicle_NOT_containing_the_key(String vehicleId, String key) { -- boolean resourceIsPresentAndContainsKey = isCallRequestResourcePresentAndContainsKey(vehicleId, key); -- Assert.assertFalse("The call request resource contains key \"" + key + "\"", resourceIsPresentAndContainsKey); -- } -- -- @Then("^A call request resource is present on \"(.+)\" containing the key \"(.+)\"$") -- public void A_call_request_resource_is_present_on_vehicle_containing_the_key(String vehicleId, String key) { -- boolean resourceIsPresentAndContainsKey = isCallRequestResourcePresentAndContainsKey(vehicleId, key); -- Assert.assertTrue("The call request resource does not contain key \"" + key + "\"", resourceIsPresentAndContainsKey); -- } -- -- private boolean isCallRequestResourcePresentAndContainsKey(String vehicleId, String key) { -- String url = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + CommunicationMessagingAPI.callrequest.RESOURCE; -- -- try { -- seleniumHelper.waitUntil((webDriver) -> RestAssured.when().get(url, new Object[0]).getStatusCode() == HttpStatus.SC_OK); -- } catch (TimeoutException e) { -- Assert.fail("The call request resource " + url + " is not present."); -- } -- -- String callRequestString = RestHelper.get(url); -- return callRequestString.contains(key); -- } -- -- @And("^A call request has been sent to \"([^\"]*)\" and is displayed on the Trillian message page$") -- public void aCallRequestHasBeenSentToAndIsDisplayedOnTheTrillianMessagePage(String vehicleId) { -- DataTable callRequestAsDataTable = createDataTableForSomeCallRequest(); -- We_PUT_a_call_request_response_via_Houston_to_vehicle_with_the_following_parameters(vehicleId, callRequestAsDataTable); -- -- new CommonSteps().weOpenTheTrillianTextMessagePageOn(vehicleId); -- -- Map<String, String> callRequestAsMap = callRequestAsDataTable.asMap(String.class, String.class); -- A_call_request__is_displayed_with_name_phone_number_and_button(callRequestAsMap.get("name"), callRequestAsMap.get("phoneNumber"), "Anrufen"); -- } -- -- -- private DataTable createDataTableForSomeCallRequest() { -- -- List<String> phoneNumber = Arrays.asList("phoneNumber", "+41780420042"); -- List<String> name = Arrays.asList("name", "Ford Prefect"); -- List<String> withPriority = Arrays.asList("withPriority", "false"); -- -- List<List<String>> rawTable = Arrays.asList(phoneNumber, name, withPriority); -- -- return DataTable.create(rawTable); -- } -- -- @And("^The resource \"([^\"]*)\" is NOT present on the eagle$") -- public void theResourceIsNOTPresentOnTheEagle(String path) { -- delete(getEagle1BaseUrl() + path); -- } -- -- @Then("^The resource \"([^\"]*)\" is present on the eagle$") -- public void theResourceIsPresentOnTheEagle(String path) { -- ensurePresent(getEagle1BaseUrl() + path); -- } -- -- -- @Then("^The resource \"([^\"]*)\" with phonenumber \"([^\"]*)\" is present on the eagle$") -- public void theResourceWithPhonenumberIsPresentOnTheEagle(String url, String phonenumber) { -- ch.post.it.paisa.api.vehicle.messaging.v1.CallRequest callRequest = waitForResource(getEagle1BaseUrl() + url, ch.post.it.paisa.api.vehicle.messaging.v1.CallRequest.class); -- Assert.assertEquals(phonenumber, callRequest.getPhoneNumber()); -- } -- -- -- @And("^The resource \"([^\"]*)\" is NOT present on the houston$") -- public void theResourceIsNOTPresentOnTheHouston(String path) { -- delete(getHoustonBaseUrl() + path); -- } -- -- @And("^The resource \"([^\"]*)\" is present on the houston$") -- public void theResourceIsPresentOnTheHouston(String path) { -- ensurePresent(getHoustonBaseUrl() + path); -- } -- -- @And("^We hit the call request button$") -- public void weHitTheCallRequestButton() { -- OverviewPage overviewPage = factory.getOverviewPage(); -- overviewPage.touchCallbackRequestButton(); -- } -- -- @And("^We navigate to the Trillian overview page$") -- public void weNavigateToTheTrillianOverviewPage() { -- final SlartiNavigation slartiNavigation = new SlartiNavigation(driver, seleniumHelper); -- slartiNavigation.touchTrillianModule(); -- BaseTestTrillian.switchToFrame("module-Trillian"); -- } -- -- -- @And("^We open the notification center$") -- public void weOpenTheNotificationCenter() throws Exception { -- factory.notificationCenter().open(); -- } -- -- @Then("^The a notification is displayed with text \"([^\"]*)\", phone number \"([^\"]*)\", and button \"([^\"]*)\"$") -- public void theANotificationIsDisplayedWithTextPhoneNumberAndButton(String text, String phoneNumber, String okButtonText) { -- seleniumHelper.waitUntil(webDriver -> factory.notificationCenter().getNotificationElements().size() > 0); -- -- Notifications notifications = factory.notifications(); -- Assert.assertTrue(notifications.getNotificationTitle().contains(text)); -- Assert.assertTrue(notifications.getNotificationTitle().contains(phoneNumber)); -- -- seleniumHelper.switchToRoot(); -- WebElement okButtonElement = seleniumHelper.getWebElement("//*[@id='displayNotification']//notification-message//button[contains(@class,'notification-ok-button')]"); -- Assert.assertEquals(okButtonText, okButtonElement.getText()); -- } -- -- @And("^The resources \"([^\"]*)\" are deleted$") -- public void theResourcesAreDeleted(String notificationsPath) { -- deleteAllChildren(getEagle1BaseUrl() + "/" + notificationsPath); -- } -- -- @Then("^A call state is PUT with the following properties for vehicle \"([^\"]+)\"$") -- public void A_call_state_is_PUT_with_the_following_properties(String vehicleId, DataTable table) { -- String baseUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId); -- given().await().atMost(new Duration(30, SECONDS)).until(() -> { -- CallState callState = RestAssured.get(baseUrl + CommunicationModemAPI.call.state.RESOURCE).as(CallState.class); -- List<List<String>> lists = table.asLists(); -- assertEquals(lists.get(1).get(1), callState.getDirection().toString()); -- assertEquals(lists.get(2).get(1), callState.getState().toString()); -- assertEquals(lists.get(3).get(1), callState.getPhoneNumber()); -- }); -- } -- -- -- @When("^We click on hangup-button$") -- public void We_click_on_hangup_button() { -- assertTrue("The hangup button is shown", seleniumHelper.waitUntilTheWebElementDisplayedByXpath("//*[@id='dialpadHangupCall']")); -- WebElement dialpadHangupCall = seleniumHelper.getWebElementById("dialpadHangupCall"); -- dialpadHangupCall.click(); -- } -- -- @And("^We hang up a possibly active phone call on \"([^\"]*)\"$") -- public void weHangupPhoneCallOn(String vehicle) { -- //Request URL: http://192.168.42.1:7012/eagle/communication/modem/v1/call/control/hangup -- //Request Method: POST -- RestHelper.post(null, TestHelper.getEagleBaseUrlFromVehicleId(vehicle) + CommunicationModemAPI.call.control.hangup.RESOURCE); -- } -- -- @And("^We hit the phonebook favourites button on the driving screen$") -- public void weHitThePhonebookFavouritesButtonOnDrivingScreen() { -- BaseTestTrillian.switchToFrame("module-SlartiComboModule"); -- BaseTestTrillian.waitAndTouchByWebElement("btn-phonebook"); -- BaseTestTrillian.switchToFrame("module-Trillian"); -- } -- -- @When("^We open the driving screen on \"([^\"]*)\"$") -- public void weOpenTheDrivingScreenOn(String vehicleId) { -- openTheSlartiStartPageOnVehicle(vehicleId, true); -- } -- -- @And("^We hit the call request button on favourite contacts$") -- public void weHitTheCallRequestButtonOnFavouriteContacts() { -- seleniumHelper.touchByWebElement(driver.findElement(By.xpath("//*[@id='favouriteContacts3']"))); -- } -- -- @When("Megacamel signals an incoming call from number {string}") -- public void megacamelSignalsAnIncomingCallFromNumberWithTheFollowingProperties(String phoneNumber) { -- CallState call = new CallState(); -- call.setDirection(Direction.INCOMING); -- call.setPhoneNumber(phoneNumber); -- call.setState(State.INCOMING); -- call.setTimestamp(new DateTime()); -- RestHelper.put(call, TestPaths.getEagle1BaseUrl() + CommunicationModemAPI.call.state.RESOURCE); -- } -- -- @And("Megacamel signals idle") -- public void megacamelSignalsIdle() { -- CallState call = new CallState(); -- call.setDirection(Direction.NONE); -- call.setState(State.NONE); -- call.setTimestamp(new DateTime()); -- RestHelper.put(call, TestPaths.getEagle1BaseUrl() + CommunicationModemAPI.call.state.RESOURCE); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallRequestUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallRequestUiTest.java -deleted file mode 100644 -index 6d99674..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallRequestUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions( glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/callRequest.feature", plugin = { "pretty", "html:target/cucumber/callRequest", "json:target/cucumber.callRequest.json" }) --public class CallRequestUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallUiTest.java -deleted file mode 100644 -index 92c669c..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CallUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions( glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/call.feature", plugin = { "pretty", "html:target/cucumber/call", "json:target/cucumber.call.json" }) --public class CallUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CommonSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CommonSteps.java -deleted file mode 100644 -index 9cea91b..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/CommonSteps.java -+++ /dev/null -@@ -1,323 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.alice.service.domain.core.json.ExtendedObjectMapper; --import ch.post.it.paisa.api.logloc.v1.path.LoglocAPI; --import ch.post.it.paisa.api.notifications.v1.NotificationsAPIPaths; --import ch.post.it.paisa.api.timetable.common.v1.TripInstance; --import ch.post.it.paisa.api.timetable.information.v1.path.TimetableInformationAPI; --import ch.post.it.paisa.api.timetable.registration.v1.*; --import ch.post.it.paisa.api.timetable.registration.v1.path.TimetableRegistrationAPI; --import ch.post.it.paisa.slarti.test.ui.elements.Login; --import ch.post.it.paisa.slarti.test.ui.elements.Navigation; --import ch.post.it.paisa.slarti.test.ui.elements.trourtrip.TourTripHome; --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.DialPad; --import ch.post.it.paisa.trillian.test.ui.elements.KeypadDialog; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNavigation; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNotification; --import ch.post.it.paisa.trillian.test.ui.mock.MockInstances; --import ch.post.it.paisa.trillian.test.ui.pages.CallLogPage; --import ch.post.it.paisa.trillian.test.ui.pages.MessagingPage; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import com.fasterxml.jackson.databind.JsonNode; --import io.cucumber.core.api.Scenario; --import io.cucumber.java.After; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Given; --import io.cucumber.java.en.Then; --import io.cucumber.java.en.When; --import io.restassured.RestAssured; --import io.restassured.response.Response; --import org.apache.http.HttpStatus; --import org.joda.time.DateTime; --import org.junit.Assert; --import org.openqa.selenium.By; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.ui.ExpectedConditions; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; -- --import java.nio.charset.StandardCharsets; -- --import static ch.post.it.paisa.trillian.test.RestAssuredSupport.deleteResource; -- --public class CommonSteps extends AbstractSteps { -- -- private static final Logger LOG = LoggerFactory.getLogger(CommonSteps.class); -- -- private static void deleteTripInitializationToPreventDrivingScreenLanding(String vehicleId) { -- String baseUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId); -- deleteResource(baseUrl + TimetableRegistrationAPI.block.initialization.RESOURCE); -- deleteResource(baseUrl + TimetableRegistrationAPI.trip.initialization.RESOURCE); -- deleteResource(baseUrl + LoglocAPI.trips.current.position.RESOURCE); -- } -- -- @Given("^On \"(.+)\", no user is logged in$") -- public void On_vehicle_no_user_is_logged_in(String vehicleId) { -- deleteTripInitializationToPreventDrivingScreenLanding(vehicleId); -- openSlartiStartPage(vehicleId); -- -- final Login login = new Login(seleniumHelper); -- if (login.isLoginActive()) { -- LOG.info("There is no one logged in, so do not try to logout."); -- return; -- } -- -- goToTourtripHomeFromDrivingScreen(); -- -- final Navigation navigation = new Navigation(seleniumHelper); -- navigation.touchTourTripModule(); -- -- final TourTripHome tourTripHome = new TourTripHome(seleniumHelper); -- tourTripHome.touchEndOfShiftButton(); -- -- login.touchEndOfShiftConfirmButton(); -- login.touchconfirmQueueDialogConfirmButtonIfPossible(); -- -- login.touchSessionEndReceiptAbortButton(); -- } -- -- @Given("^\"(.+)\" is logged in on \"(.+)\"$") -- public void is_logged_in_on(String fullName, String vehicleId) { -- login(fullName.split(" ")[0], fullName.split(" ")[1], vehicleId); -- } -- -- @When("^We open the Slarti start page on \"(.+)\"$") -- public void We_open_the_Slarti_start_page_on_vehicle(String vehicleId) { -- openTheSlartiStartPageOnVehicle(vehicleId, false); -- } -- -- @Then("A notification {string} with message {string} and accept-button {string} on vehicle {string} is displayed") -- public void aNotificationWithMessageAndAcceptButtonOnVehicleIsDisplayed(String notificationId, String notificationMessage, String buttonText, String vehicleId) { -- // notification was put -- ensurePresent(TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + "/" + NotificationsAPIPaths.Channels.ChannelName.NotificationId.PATH, "messages", notificationId); -- -- boolean testPassed = false; -- // the data has to be synced from the houston to the eagle, might take a short while -- for (int retry = 0; retry < RETRY_COUNTER; retry++) { -- final SlartiNotification slartiNotification = factory.getNotification(); -- if (!notificationMessage.equals(slartiNotification.getNotificationTitle())) { -- try { -- Thread.sleep(RETRY_SLEEP_TIME); -- } catch (InterruptedException ignore) { -- } -- continue; -- } -- slartiNotification.assertHasOKButton(); -- slartiNotification.assertOKButtonTextEqualTo(buttonText); -- -- testPassed = true; -- break; -- } -- Assert.assertTrue("Could not find notification message:'" + notificationMessage + "' even after a couple of retries", testPassed); -- } -- -- @Then("^A notification is displayed with message \"([^\"]*)\" and cancel-button \"([^\"]*)\"$") -- public void A_notification_is_displayed_with_message_and_canncel_button(String notificationMessage, String buttonText) { -- final SlartiNotification slartiNotification = factory.getNotification(); -- slartiNotification.assertNotificationTitleEqualTo(notificationMessage); -- slartiNotification.assertHasCancelButton(); -- slartiNotification.assertCancelButtonTextEqualTo(buttonText); -- } -- -- @Then("^A notification is displayed with message \"([^\"]*)\", accept-button \"([^\"]*)\", and cancel-button \"([^\"]*)\"$") -- public void A_notification_is_displayed_with_message_accept_button_and_cancel_button(String notificationMessage, String okButtonText, String cancelButtonText) { -- final SlartiNotification slartiNotification = factory.getNotification(); -- slartiNotification.assertNotificationTitleEqualTo(notificationMessage); -- slartiNotification.assertHasOKButton(); -- slartiNotification.assertOKButtonTextEqualTo(okButtonText); -- slartiNotification.assertHasCancelButton(); -- slartiNotification.assertCancelButtonTextEqualTo(cancelButtonText); -- } -- -- @Then("^A notification is displayed with message \"([^\"]*)\"$") -- public void A_notification_is_displayed_with_message(String message) { -- final SlartiNotification slartiNotification = factory.getNotification(); -- slartiNotification.assertNotificationTitleEqualTo(message); -- } -- -- @When("^We click on accept-button \"(.+)\"$") -- public void We_click_on_accept_button(String buttonText) { -- seleniumHelper.switchToRoot(); -- final SlartiNotification slartiNotification = factory.getNotification(); -- slartiNotification.assertOKButtonTextEqualTo(buttonText); -- slartiNotification.touchNotificationButtonOk(); -- } -- -- @When("^We click on cancel-button \"(.+)\"$") -- public void We_click_on_cancel_button(String buttonText) { -- seleniumHelper.switchToRoot(); -- final SlartiNotification slartiNotification = factory.getNotification(); -- slartiNotification.assertCancelButtonTextEqualTo(buttonText); -- slartiNotification.touchNotificationButtonCancel(); -- } -- -- @When("^We navigate to the Trillian message page$") -- public void We_navigate_to_the_Trillian_message_page() { -- final SlartiNavigation slartiNavigation = new SlartiNavigation(driver, seleniumHelper); -- slartiNavigation.touchTrillianModule(); -- -- BaseTestTrillian.switchToFrame("module-Trillian"); -- OverviewPage overviewPage = factory.getOverviewPage(); -- overviewPage.touchGoToMessagesButton(); -- seleniumHelper.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.id("headerbarTitle"))); -- } -- -- @Then("^The Trillian message page is displayed$") -- public void The_Trillian_message_page_is_displayed() { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- seleniumHelper.waitUntil(ExpectedConditions.visibilityOfElementLocated(By.id("headerbarTitle"))); -- } -- -- @And("^\"([^\"]*)\" logs in on \"([^\"]*)\"$") -- public void logsInOn(String fullName, String vehicleId) { -- is_logged_in_on(fullName, vehicleId); -- } -- -- @And("^A phone call was performed on \"([^\"]*)\" and is displayed in the Trillian call log$") -- public void aPhoneCallWasPerformedOnAndIsDisplayedInTheTrillianCallLog(String vehicleId) { -- -- We_open_the_Slarti_start_page_on_vehicle(vehicleId); -- -- OverviewPage overviewPage = navigateToAndGetTrillianOverviewPage(); -- overviewPage.touchDialPadButton(); -- -- KeypadDialog keypadDialog = factory.getKeypadDialog(); -- keypadDialog.waitForTitle(); -- -- DialPad dialPad = factory.getDialPad(); -- dialPad.dialKeyByKey("42"); -- dialPad.assertNumberFieldTextEquals("42"); -- dialPad.touchDialPadCallButton(); -- -- A_notification_is_displayed_with_message_and_canncel_button("Rufaufbau... 42", "Aufhängen"); -- We_click_on_cancel_button("Aufhängen"); -- -- navigateToAndGetTrillianOverviewPage(); -- overviewPage.touchGoToCalllogButton(); -- CallLogPage callLogPage = factory.getCalllogPage(); -- callLogPage.waitForTitle(); -- -- Assert.assertEquals("We have not found the expected number of entries in the call log, which is 1", 1, callLogPage.getCallLogSize()); -- } -- -- @When("^The current driver logs out on \"([^\"]*)\"$") -- public void theCurrentDriverLogsOutOn(String vehicleId) { -- On_vehicle_no_user_is_logged_in(vehicleId); -- } -- -- @And("^We open the Trillian text message page on \"([^\"]*)\"$") -- public void weOpenTheTrillianTextMessagePageOn(String vehicleId) { -- openSlartiStartPage(vehicleId); -- goToTourtripHomeFromDrivingScreen(); -- OverviewPage overviewPage = navigateToAndGetTrillianOverviewPage(); -- overviewPage.touchGoToMessagesButton(); -- MessagingPage messagingPage = factory.getMessagingPage(); -- messagingPage.waitForTitle(); -- messagingPage.goToTextMessages(); -- } -- -- @And("^No phone call is displayed in the Trillian call log on \"([^\"]*)\"$") -- public void noPhoneCallIsDisplayedInTheTrillianCallLogOn(String vehicleId) { -- openSlartiStartPage(vehicleId); -- goToTourtripHomeFromDrivingScreen(); -- OverviewPage overviewPage = navigateToAndGetTrillianOverviewPage(); -- overviewPage.touchGoToCalllogButton(); -- -- CallLogPage callLogPage = factory.getCalllogPage(); -- callLogPage.waitForTitle(); -- callLogPage.assertThatThereAreNoCallLogEntries(); -- } -- -- @Then("^No text messages or call requests are displayed on the Trillian message page on \"([^\"]*)\"$") -- public void noTextMessagesOrCallRequestsAreDisplayedOnTheTrillianMessagePageOn(String vehicleId) { -- weOpenTheTrillianTextMessagePageOn(vehicleId); -- MessagingPage messagingPage = factory.getMessagingPage(); -- messagingPage.waitForTitle(); -- messagingPage.goToTextMessages(); -- messagingPage.assertThatThereAreNoTextMessagesOrCallRequests(); -- } -- -- @Then("^The text messaging tab is displayed on the Trillian messaging page$") -- public void The_text_messaging_tab_is_displayed_on_the_Trillian_messaging_page() { -- MessagingPage messagingPage = factory.getMessagingPage(); -- messagingPage.waitForTitle(); -- messagingPage.textMessagesButtonIsClickable(); -- } -- -- @When("^We navigate to the Trillian text messages page$") -- public void weNavigateToTheTrillianTextMessagesPage() { -- OverviewPage overviewPage = navigateToAndGetTrillianOverviewPage(); -- overviewPage.touchGoToMessagesButton(); -- MessagingPage messagingPage = factory.getMessagingPage(); -- messagingPage.waitForTitle(); -- messagingPage.goToTextMessages(); -- } -- -- @After -- public void cleanup(Scenario scenario) { -- super.cleanup(scenario); -- MockInstances.getHouston().reset(); -- MockInstances.resetAllEagles(); -- } -- -- @Given("^Setup test with skip login \"([^\"]*)\"$") -- public void setupTestWithSkipLogin(String skipLoginString) throws Throwable { -- boolean doSkipLogin = skipLoginString.equalsIgnoreCase("true"); -- // the user stuff needs to be put before we open the browser -- TestHelper.setupE2ETests(); -- super.init(!doSkipLogin); -- } -- -- @And("^a signon on trip \"([^\"]*)\" with \"([^\"]*)\" is performed$") -- public void aSignonOnTripIsPerformed(String tripInstanceId, String vehicleId) { -- String url = "/from/vehicles/"; -- url = url + vehicleId + TimetableRegistrationAPI.trip.signon.RESOURCE; -- TripSignon tripSignon = new TripSignon(); -- tripSignon.withTripInstanceId(tripInstanceId); -- tripSignon.withTimestamp(new DateTime()); -- tripSignon.withType(TripSignonType.REGULAR); -- putObjectWithVehicledIdInHeader(tripSignon, url, vehicleId); -- -- TripInstance tripInstance = get(TimetableInformationAPI.tripinfo.RESOURCE + "?id=" + tripInstanceId).getBody().as(TripInstance.class); -- -- TripInitialization tripInitialization = new TripInitialization(); -- tripInitialization.setTripInstance(tripInstance); -- tripInitialization.setTripInstanceId(tripInstanceId); -- tripInitialization.setType(TripSignonType.REGULAR); -- tripInitialization.setTimestamp(tripSignon.getTimestamp()); -- -- String tripInitUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + TimetableRegistrationAPI.trip.initialization.RESOURCE; -- RestAssured.given().contentType("application/json").given(). -- body(new ExtendedObjectMapper().convertValue(tripInitialization, JsonNode.class).toString().getBytes(StandardCharsets.UTF_8)).put(tripInitUrl). -- then().assertThat().statusCode(HttpStatus.SC_OK); -- } -- -- -- @And("^a signoff on trip \"([^\"]*)\" with \"([^\"]*)\" is performed$") -- public void aSignonOffTripIsPerformed(String tripInstanceId, String vehicleId) { -- String url = "/from/vehicles/" + vehicleId + TimetableRegistrationAPI.trip.signoff.RESOURCE; -- TripSignoff tripSignoff = new TripSignoff(); -- tripSignoff.withTripInstanceId(tripInstanceId); -- tripSignoff.withTimestamp(new DateTime()); -- tripSignoff.withReason(TripSignoffReason.AT_EOT); -- -- put(tripSignoff, url); -- } -- -- @And("^a trip signoff for \"([^\"]*)\" is performed$") -- public void aTripSignoffForIsPerformed(String vehicleId) { -- String url = "/from/vehicles/" + vehicleId + TimetableRegistrationAPI.trip.signon.RESOURCE; -- Response response = get(url); -- if (response.getStatusCode() == HttpStatus.SC_NOT_FOUND) { -- return; -- } -- -- Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); -- -- TripSignon tripSignon = response.then().extract().as(TripSignon.class); -- aSignonOffTripIsPerformed(tripSignon.getTripInstanceId(), vehicleId); -- } --} -- -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/ComprehensiveFunctionalitiesUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/ComprehensiveFunctionalitiesUiTest.java -deleted file mode 100644 -index 27ad66f..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/ComprehensiveFunctionalitiesUiTest.java -+++ /dev/null -@@ -1,19 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --// ISABUFC-1367 --@RunWith(Cucumber.class) --@CucumberOptions( glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/comprehensiveFunctionalities.feature", plugin = { "pretty", "html:target/cucumber/comprehensiveFunctionalities", "json:target/cucumber.comprehensiveFunctionalities.json" }) --public class ComprehensiveFunctionalitiesUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/ConnectionsSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/ConnectionsSteps.java -deleted file mode 100644 -index 1cca5e8..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/ConnectionsSteps.java -+++ /dev/null -@@ -1,403 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.api.timetable.common.v1.TripInstance; --import ch.post.it.paisa.api.timetable.wait.v1.*; --import ch.post.it.paisa.api.timetable.wait.v1.path.TimetableWaitAPI; --import ch.post.it.paisa.slarti.test.ui.base.SeleniumFactory; --import ch.post.it.paisa.slarti.test.ui.elements.DrivingScreen; --import ch.post.it.paisa.slarti.test.ui.elements.Navigation; --import ch.post.it.paisa.slarti.test.ui.elements.Settings; --import ch.post.it.paisa.slarti.test.ui.elements.trourtrip.TourTripHome; --import ch.post.it.paisa.trillian.test.mock.TrillianTripDataGenerator; --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.pages.ConnectionPage; --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Given; --import io.cucumber.java.en.Then; --import io.cucumber.java.en.When; --import io.restassured.response.Response; --import org.apache.http.HttpStatus; --import org.joda.time.DateTime; --import org.joda.time.Minutes; --import org.joda.time.format.DateTimeFormat; --import org.joda.time.format.DateTimeFormatter; --import org.junit.Assert; --import org.openqa.selenium.WebElement; -- --import java.util.*; -- --import static ch.post.it.paisa.trillian.test.RestAssuredSupport.deleteResource; --import static ch.post.it.paisa.trillian.test.RestAssuredSupport.putResource; --import static ch.post.it.paisa.trillian.test.TestPaths.*; --import static ch.post.it.paisa.trillian.test.TrillianTestRestHelper.*; --import static ch.post.it.paisa.trillian.test.ui.TextFixtures.tripInitialization; --import static ch.post.it.paisa.trillian.test.ui.TextFixtures.tripPosition; --import static java.lang.String.valueOf; --import static org.junit.Assert.*; -- --public class ConnectionsSteps extends AbstractSteps { -- -- private static final DateTimeFormatter FORMATTER = DateTimeFormat.forPattern("yyyy.MM.dd hh:mm"); -- -- private TrillianTripDataGenerator tripGenerator; -- private WaitRecommendation waitRecommendation; -- private WaitConfirmation waitConfirmation; -- private List<WaitReport> waitReports; -- private ConnectionPage connectionPage; -- -- private DrivingScreen drivingScreen; -- private TourTripHome tourTripHome; -- -- @Given("^Wait trips are deleted$") -- public void Wait_trips_are_deleted() { -- deleteResource(WAIT_TRIPS); -- } -- -- @Given("^Trip initialization is deleted$") -- public void Trip_initialize_is_deleted() { -- deleteResource(TRIP_INITIALIZATION); -- } -- -- @Given("^Trip position is deleted$") -- public void Trip_position_is_delete() { -- deleteResource(TRIP_POSITION); -- } -- -- @Given("^A trip data generator is created$") -- public void A_trip_date_generator_is_created() { -- tripGenerator = new TrillianTripDataGenerator(); -- } -- -- @Given("^The trip data generator is cleared$") -- public void The_trip_data_generator_is_cleared() { -- tripGenerator.clear(); -- } -- -- @When("^We navigate to Trip Home module") -- public void We_navigate_to_Trip_Home_module() { -- new SeleniumFactory(seleniumHelper).navigation().touchTourTripModule(); -- } -- -- @When("^We navigate to Connections page") -- public void We_navigate_to_Connections_page() { -- Navigation navigation1 = new Navigation(seleniumHelper); -- -- navigation1.touchDrivingScreenModule(); -- drivingScreen = new DrivingScreen(seleniumHelper); -- drivingScreen.waitForDrivingScreenToActivate(); -- -- clickConnectionsIn(); -- -- BaseTestTrillian.switchToFrame("module-Trillian"); -- connectionPage = new ConnectionPage(driver, seleniumHelper); -- tourTripHome = new TourTripHome(seleniumHelper); -- } -- -- @When("^We navigate to the inbound connections page") -- public void We_navigate_to_inbound_connections_page() { -- We_navigate_to_Connections_page(); -- } -- -- private void clickConnectionsIn() { -- BaseTestTrillian.switchToFrame("module-SlartiComboModule"); -- WebElement connectionElement = seleniumHelper.getWebElement("//span[contains(@class,'icon-connections-in')]"); -- connectionElement.click(); -- } -- -- @Given("^A trip line is added to the trip data generator with departure time \"(.+)\"$") -- public void A_trip_line_is_added_to_the_trip_data_generator_with_initial_time(String dateTime, DataTable stopPointTable) { -- addTripLine(DateTime.parse(dateTime, FORMATTER), stopPointTable, false); -- } -- -- @Given("^An external trip line is added to the trip data generator with departure time \"(.+)\"$") -- public void An_external_trip_line_is_added_to_the_trip_data_generator_with_initial_time(String dateTime, DataTable stopPointTable) { -- addTripLine(DateTime.parse(dateTime, FORMATTER), stopPointTable, true); -- } -- -- @Given("^The trip instances are put to Zaphake$") -- public void The_trip_instance_are_put_to_Zaphake() { -- putTripInstanceInformationToZaphake(tripGenerator.getTripInstances()); -- } -- -- @Given("^A trip initialization with trip instance \"(.+)\" is put$") -- public void A_trip_initialization_with_trip_instance_is_put(String tripReferenceId) { -- TripInstance tripInstance = tripGenerator.getTripInstance(tripReferenceId); -- putResource(TRIP_INITIALIZATION, tripInitialization(tripInstance)); -- } -- -- @Given("^A trip position with sequence number \"(\\d+)\" and trip instance \"(.+)\" is put$") -- public void A_trip_position_with_sequence_number_and_trip_instance_is_put(int sequenceNumber, String tripReferenceId) { -- TripInstance tripInstance = tripGenerator.getTripInstance(tripReferenceId); -- putResource(TRIP_POSITION, tripPosition(sequenceNumber, tripInstance)); -- } -- -- @Given("^The following wait recommendation for fetcherTripInstanceId \"(.+)\" and fetcherStopId \"(.+)\" is put$") -- public void The_following_wait_recommendation_for_fetcherTripInstanceId_and_fetcherStopId_is_put(String fetcherTripInstanceId, String fetcherStopId, DataTable dataTable) { -- Map<InternalFeederIdentifier, Integer> internalFeederPredictedArrivalDeviation = new HashMap<>(); -- Map<ExternalFeederIdentifier, Integer> externalFeederPredictedArrivalDeviation = new HashMap<>(); -- List<Map<String, String>> rows = dataTable.asMaps(String.class, String.class); -- for (Map<String, String> row : rows) { -- int deviationOfPredictedArrivalFromPlannedDepartureTime = Integer.parseInt(row.get("deviationOfPredictedArrivalFromPlannedDepartureTime")); -- String externalTripId = row.get("externalTripId"); -- if (externalTripId == null || externalTripId.isEmpty()) { // internal feeder -- String tripInstanceId = row.get("tripInstanceId"); -- String arrivalStoppingPointId = row.get("arrivalStoppingPointId"); -- InternalFeederIdentifier internalFeederIdentifier = new InternalFeederIdentifier(); -- internalFeederIdentifier.setTripInstanceId(tripInstanceId); -- internalFeederIdentifier.setArrivalStopId(fetcherStopId); -- internalFeederIdentifier.setArrivalStoppingPointId(arrivalStoppingPointId); -- internalFeederPredictedArrivalDeviation.put(internalFeederIdentifier, deviationOfPredictedArrivalFromPlannedDepartureTime); -- } else { // external feeder -- String externalSystemId = row.get("externalSystemId"); -- ExternalFeederIdentifier externalFeederIdentifier = new ExternalFeederIdentifier(); -- externalFeederIdentifier.setExternalTripId(externalTripId); -- externalFeederIdentifier.setExternalSystemId(externalSystemId); -- externalFeederPredictedArrivalDeviation.put(externalFeederIdentifier, deviationOfPredictedArrivalFromPlannedDepartureTime); -- } -- } -- waitRecommendation = tripGenerator.buildWaitRecommendation(fetcherTripInstanceId, fetcherStopId, -- internalFeederPredictedArrivalDeviation, externalFeederPredictedArrivalDeviation); -- putWaitRecommendation(waitRecommendation); -- } -- -- @When("^We confirm currently selected wait recommendation$") -- public void We_confirm_currently_selected_wait_recommendation() { -- wait(100); -- connectionPage.confirmCurrentlySelectedWaitRecommendation(); -- waitConfirmation = getWaitConfirmation(waitRecommendation); -- } -- -- @When("^We reject currently selected wait recommendation$") -- public void We_reject_currently_selected_wait_recommendation() { -- wait(100); -- connectionPage.rejectCurrentlySelectedWaitRecommendation(); -- waitConfirmation = getWaitConfirmation(waitRecommendation); -- } -- -- @When("^Waiting wait reports of the following feeder are put$") -- public void Waiting_wait_reports_of_the_following_feeder_are_put(DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- putWaitReports(data.get("fetcherTripInstanceId"), data.get("fetcherStopId"), true); -- } -- -- @When("^Not waiting wait reports of the following feeder are put$") -- public void Not_waiting_wait_reports_of_the_following_feeder_are_put(DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- putWaitReports(data.get("fetcherTripInstanceId"), data.get("fetcherStopId"), false); -- } -- -- @When("^We select inbound connection at index \"(\\d+)\"$") -- public void We_select_inbound_connection_at_index(int index) { -- connectionPage.selectInboundConnectionByIndex(index); -- } -- -- @Then("^The wait confirmation is waiting$") -- public void The_wait_confirmation_is_waiting() { -- assertTrue(waitConfirmation.getWaiting()); -- } -- -- @Then("^The wait confirmation is not waiting$") -- public void The_wait_confirmation_is_not_waiting() { -- assertFalse(waitConfirmation.getWaiting()); -- } -- -- @Then("^The selected inbound connection status is \"(.+)\"$") -- public void The_selected_inbound_connection_status_is(String inboundConnectionStatus) { -- assertEquals(ConnectionPage.InboundConnectionStatus.valueOf(inboundConnectionStatus), connectionPage.getSelectedInboundConnectionStatus()); -- -- } -- -- @Then("^The selected connection arrival time is between the arrival of the following trip stop$") -- public void The_selected_connection_arrival_time_is_between_the_arrival_of_the_following_trip_stop(DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- final String arrivalTime = connectionPage.getSelectedConnectionArrivalTime(); -- -- DateTime predictedArrival = waitRecommendation.getInternalFeeders().get(0).getPredictedArrival(); -- DateTime plannedArrival = tripGenerator.getTripStop(data.get("tripInstanceId"), data.get("tripStopId")).getArrival(); -- int delayInMinutes = Minutes.minutesBetween(plannedArrival, predictedArrival).getMinutes(); -- assertTrue(arrivalTime.contains(valueOf(delayInMinutes))); -- } -- -- @Then("^The selected connection arrival time is ahead of the delay of the following trip stop$") -- public void The_selected_connection_arrival_time_is_ahead_of_the_delay_of_the_following_trip_stop(DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- final String arrivalTime = connectionPage.getSelectedConnectionArrivalTime(); -- DateTime plannedArrival = tripGenerator.getTripStop(data.get("tripInstanceId"), data.get("tripStopId")).getArrival(); -- DateTime predictedArrival = waitRecommendation.getInternalFeeders().get(0).getPredictedArrival(); -- int delay = Minutes.minutesBetween(plannedArrival, predictedArrival).getMinutes(); -- assertTrue(arrivalTime.contains(plannedArrival.toString("HH:mm"))); -- assertTrue(arrivalTime.contains("+" + delay)); -- } -- -- @Then("^The selected connection arrival time is in plan of the following trip stop$") -- public void The_selected_connection_arrival_time_is_in_plan_of_the_following_trip_stop(DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- final String arrivalTime = connectionPage.getSelectedConnectionArrivalTime(); -- DateTime plannedArrival = tripGenerator.getTripStop(data.get("tripInstanceId"), data.get("tripStopId")).getArrival(); -- DateTime predictedArrival = waitRecommendation.getInternalFeeders().get(0).getPredictedArrival(); -- int delay = Minutes.minutesBetween(plannedArrival, predictedArrival).getMinutes(); -- assertTrue(arrivalTime.contains(plannedArrival.toString("HH:mm"))); -- assertTrue(arrivalTime.contains(valueOf(delay))); -- } -- -- @Then("^The selected connection max wait time is in the rule$") -- public void The_selected_connection_max_wait_time_is_in_the_rule() { -- String maxWaitTime = connectionPage.getSelectedConnectionMaxWaitTime(); -- DateTime expectedMaxWaitTime = waitRecommendation.getFetcher().getDepartureTime().plusMinutes(waitRecommendation.getInternalFeeders().get(0).getWaitRule().getMaxWaitTime()); -- assertTrue(maxWaitTime.contains(expectedMaxWaitTime.toString("HH:mm"))); -- } -- -- @Then("^The recommended departure time is feeder with the latest expected arrival$") -- public void The_recommended_departure_time_is_feeder_with_the_latest_expected_arrival() { -- DateTime predictedArrival = waitRecommendation.getInternalFeeders().get(0).getPredictedArrival(); -- DateTime recommendedDepartureTime = predictedArrival.plusMinutes(waitRecommendation.getInternalFeeders().get(0).getChangeTime()); -- String recommendedDepartureTimeContent = connectionPage.getRecommendedDepartureTimeHeaderContents(); -- assertTrue("The recommended departure time '" + recommendedDepartureTimeContent + "' does not contain '" + recommendedDepartureTime.toString("HH:mm") + "'" -- , recommendedDepartureTimeContent.contains(recommendedDepartureTime.toString("HH:mm"))); -- } -- -- @Then("^The recommended departure time content contains the recommended departure time$") -- public void The_recommended_departure_time_content_contains_the_recommended_departure_time() { -- String recommendedDepartureTimeContent = connectionPage.getRecommendedDepartureTimeHeaderContents(); -- DateTime predictedArrival = waitRecommendation.getInternalFeeders().get(0).getPredictedArrival(); -- DateTime recommendedDepartureTime = predictedArrival.plusMinutes(waitRecommendation.getInternalFeeders().get(0).getChangeTime()); -- assertTrue(recommendedDepartureTimeContent.contains(recommendedDepartureTime.toString("HH:mm"))); -- } -- -- @When("^The predicted arrival of the wait recommendation is put by adjust the following$") -- public void The_predicted_arrival_of_the_wait_recommendation_is_put_by_adjust_the_following(DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- Set<String> adjustmentTypeSet = data.keySet(); -- -- DateTime predictedArrival = waitRecommendation.getInternalFeeders().get(0).getPredictedArrival(); -- -- for (String adjustmentType : adjustmentTypeSet) { -- String value = data.get(adjustmentType); -- if ("minusMinutes".equals(adjustmentType)) { -- predictedArrival = predictedArrival.minusMinutes(Integer.parseInt(value)); -- } else { -- throw new IllegalArgumentException("Unknown adjustment type found: " + adjustmentType); -- } -- } -- -- waitRecommendation.getInternalFeeders().get(0).setPredictedArrival(predictedArrival); -- putWaitRecommendation(waitRecommendation); -- } -- -- -- @Then("^The line numbers are not one of the following values$") -- public void The_line_numbers_are_not_one_of_the_following_values(DataTable dataTable) { -- List<String> values = new ArrayList<>(); -- List<List<String>> rows = dataTable.asLists(); -- for (List<String> row : rows) { -- values.add(row.get(0)); -- } -- -- final List<String> labels = connectionPage.checkForIncorectLineNumbers(); -- for (final String label : labels) { -- for (final String value : values) { -- assertNotEquals(value, label); -- } -- } -- } -- -- @Then("^The fetcher of wait request of each wait report should wait$") -- public void The_fetcher_of_wait_request_of_each_wait_report_should_wait() { -- assertWaitRequestsShouldWait(true); -- } -- -- @Then("^The fetcher of wait request of each wait report should not wait$") -- public void The_fetcher_of_wait_request_of_each_wait_report_should_not_wait() { -- assertWaitRequestsShouldWait(false); -- } -- -- @Then("^The confirmation text content is \"(.+)\"$") -- public void The_confirmation_text_content_is(String content) { -- wait(100); -- assertEquals(content, connectionPage.getConfirmationTextContent()); -- } -- -- private void addTripLine(DateTime dateTime, DataTable stopPointTable, boolean external) { -- List<Integer> stopPoints = new ArrayList<>(); -- List<String> plannedArrivalPlatforms = new ArrayList<>(); -- List<List<String>> stopPointRows = stopPointTable.asLists(); -- for (int i = 1; i < stopPointRows.size(); i++) { // skip header -- List<String> stopPointRow = stopPointRows.get(i); -- int from = Integer.parseInt(stopPointRow.get(0)); -- int to = Integer.parseInt(stopPointRow.get(1)); -- String plannedArrivalPlatform = stopPointRow.get(2); -- -- stopPoints.add(from); -- stopPoints.add(to); -- plannedArrivalPlatforms.add(plannedArrivalPlatform); -- } -- -- tripGenerator.addTripLine(dateTime, stopPoints.stream().mapToInt(i->i).toArray(), plannedArrivalPlatforms, external); -- } -- -- private void putWaitReports(String fetcherTripInstanceId, String fetcherStopId, boolean waiting) { -- waitReports = tripGenerator.buildWaitReports(fetcherTripInstanceId, fetcherStopId); -- for (final WaitReport waitReport : waitReports) { -- waitReport.setWaiting(waiting); -- putWaitReport(waitReport); -- } -- } -- -- private void assertWaitRequestsShouldWait(boolean waiting) { -- waitReports.forEach(report -> { -- WaitRequest waitRequest = getWaitRequest(report); -- assertNotNull(waitRequest); -- if (waiting) { -- assertFalse(waitRequest.getFetcherShouldWait()); -- } else { -- assertTrue(waitRequest.getFetcherShouldWait()); -- } -- }); -- } -- -- @When("^We click on the back button$") -- public void weClickOnTheBackButton() { -- connectionPage.touchHeaderBarBackButton(); -- } -- -- @And("^The line number \"([^\"]*)\" is not displayed") -- public void theLineNumberIsNotDisplayed(String lineNumber) { -- seleniumHelper.switchToFrameByXpath(Settings.XPATH_COMBOMODULE_IFRAME); -- BaseTestTrillian.getWait().until(webdriver -> !lineNumber.equals(drivingScreen.getLineText())); -- } -- -- @Then("^The line number \"([^\"]*)\" is displaying$") -- public void theLineNumberIsDisplaying(String lineNumber) { -- seleniumHelper.switchToFrameByXpath(Settings.XPATH_COMBOMODULE_IFRAME); -- Assert.assertEquals(lineNumber, drivingScreen.getLineText()); -- } -- -- @When("^We sign off from the trip$") -- public void weSignOffFromTheTrip() { -- drivingScreen.touchTourtripButton(); -- drivingScreen.waitForDrivingScreenToDeactivate(); -- if (tourTripHome.touchsignOffButtonIfExists()) { -- tourTripHome.waitForTripCancelDialogStopMoving(); -- if (tourTripHome.areTripCancelDialogReasonButtonsVisible()) { -- tourTripHome.touchTripCancelDialogReason(1); -- } -- tourTripHome.touchTripCancelDialogOkBtn(); -- } -- } -- -- @And("^All connections are deleted$") -- public void theConnectionsAreDeleted() { -- ensureNotFound(getEagle1BaseUrl() + "/data/trillian/trips"); -- } -- -- @And("The aggregated wait recommendation is {int} minutes") -- public void theAggregatedWaitRecommendationIsMinutes(Integer expectedMinutes) { -- Response response = getFromEagle1(TimetableWaitAPI.stop.current.recommendation.RESOURCE); -- Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); -- -- AggregatedWaitRecommendation aggregatedWaitRecommendation = response.then().extract().as(AggregatedWaitRecommendation.class); -- Assert.assertEquals(expectedMinutes, aggregatedWaitRecommendation.getMinutesToWait()); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/ConnectionsUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/ConnectionsUiTest.java -deleted file mode 100644 -index 5ba0efe..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/ConnectionsUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions( glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/connections.feature", plugin = { "pretty", "html:target/cucumber/connections", "json:target/cucumber.connections.json" }) --public class ConnectionsUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/DrivingScreenSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/DrivingScreenSteps.java -deleted file mode 100644 -index a2f5d39..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/DrivingScreenSteps.java -+++ /dev/null -@@ -1,187 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Given; --import io.cucumber.java.en.Then; --import io.cucumber.java.en.When; --import org.openqa.selenium.*; --import org.openqa.selenium.support.ui.Wait; --import org.openqa.selenium.support.ui.WebDriverWait; -- --import java.time.Duration; --import java.util.List; -- --import static com.jayway.awaitility.Awaitility.await; --import static io.restassured.RestAssured.given; --import static java.util.concurrent.TimeUnit.SECONDS; --import static org.openqa.selenium.By.*; -- --public class DrivingScreenSteps extends AbstractSteps { -- -- private static final By COMBO_MODULE = id("module-SlartiComboModule"); -- private static final By BLOCK_BUTTON = id("goToBlockButton"); -- private static final By CHOOSE_TRIP = id("chooseTrip"); -- private static final By START_TRIP = id("startTrip"); -- private static final By DRIVING_SCREEN_LINK_FULLSCREEN = id("DrivingScreenLinkFullscreen"); -- private static final By DRIVING_SCREEN = id("driving-screen"); -- private static final By DRIVING_SCREEN_STOPS = tagName("driving-screen-stops"); -- private static final By DISRUPTION_ICON = cssSelector(".stop-icons > .icon-exclamation-triangle"); -- private static final By LINE_INFO_DISRUPTION_ICON = cssSelector(".line-info > .icon-exclamation-triangle"); -- -- @Given("^Zaphake is restarted on each vehicle$") -- public void zaphake_is_restarted_on_each_vehicle(DataTable dataTable) { -- final List<List<String>> rows = dataTable.asLists(); -- for (final List<String> row : rows) { -- final String vehicleId = row.get(0); -- final String zaphakeUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + "/services/zaphake"; -- -- // await until zaphake service running -- await().pollInterval(1, SECONDS).atMost(20, SECONDS) -- .until(() -> RestHelper.get(zaphakeUrl + "/status").contains("\"running\":true")); -- -- RestHelper.post("{}", zaphakeUrl + "/fpd/resetData"); -- RestHelper.post("{}", zaphakeUrl + "/fpd/stop"); -- RestHelper.post("{}", zaphakeUrl + "/fpd/start"); -- } -- } -- -- @When("^We go to trip selection$") -- public void we_go_to_trip_selection() { -- switchToComboModule(); -- clickOnElementWhenItIsDisplayed(BLOCK_BUTTON); -- switchToDefault(); -- } -- -- @When("^We choose and start the (\\d+). trip$") -- public void we_choose_and_start_the_n_trip(int n) { -- switchToComboModule(); -- clickOnElementWhenItIsDisplayed(id("proposalItem-" + (n - 1))); -- clickOnElementWhenItIsDisplayed(CHOOSE_TRIP); -- clickOnElementWhenItIsDisplayed(START_TRIP); -- switchToDefault(); -- } -- -- @When("^We go to driving screen from tourtrip home$") -- public void we_go_to_driving_screen_from_tourtrip_home() { -- clickOnElementWhenItIsDisplayed(DRIVING_SCREEN_LINK_FULLSCREEN); -- } -- -- @When("^We go to the driving screen$") -- public void We_go_to_the_driving_sceen() { -- switchToDefault(); -- clickOnElementWhenItIsDisplayed(DRIVING_SCREEN_LINK_FULLSCREEN); -- we_are_on_the_driving_screen(); -- } -- -- @Then("^We are on the driving screen$") -- public void we_are_on_the_driving_screen() { -- switchToComboModule(); -- elementIsDisplayed(DRIVING_SCREEN); -- switchToDefault(); -- } -- @And("A disruption icon is displayed on line info") -- public void aDisruptionIconIsDisplayedOnLineInfo() { -- switchToComboModule(); -- waiting().until(webDriver -> getLineInfoDisruptionIcon().isDisplayed()); -- switchToDefault(); -- } -- -- @Then("^A disruption icon is displayed on (\\d+). stop$") -- public void a_disruption_icon_is_displayed_on_n_stop(int n) { -- switchToComboModule(); -- waiting().until(webDriver -> getDisruptionIcon(n).isDisplayed()); -- switchToDefault(); -- } -- -- @When("^We click on the disruption icon for the (\\d+). stop$") -- public void we_click_on_the_disruption_icon_for_the_n_stop(int n) { -- switchToComboModule(); -- waiting().until(webDriver -> getDisruptionIcon(n)).click(); -- switchToDefault(); -- } -- -- @When("^The vehicle with id \"([^\"]+)\" goes to the first stop$") -- public void the_vehicle_with_id_is_stationary(String vehicleId) { -- final String base = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId); -- given().contentType("application/json") -- .body("{" + -- "\"timestamp\": \"2017-02-07T13:30:00.841Z\"," + -- "\"current\": {" + -- "\"sequenceNumber\": 1," + -- "\"tripStopId\": {" + -- "\"stopId\": \"8507765\"," + -- "\"stoppingPointId\": \"1\"," + -- "\"tripId\": \"MOCK-180506-1\"" + -- "}" + -- "}," + -- "\"next\": {" + -- "\"sequenceNumber\": 2," + -- "\"tripStopId\": {" + -- "\"stopId\": \"8571651\"," + -- "\"stoppingPointId\": \"2\"," + -- "\"tripId\": \"MOCK-180506-1\"" + -- "}" + -- "}," + -- "\"warning\": \"Slarti: This is only for demonstration of the pearlcord\"" + -- "}") -- .put(base + "/logloc/v1/trips/current/position") -- .then().log().all(); -- } -- -- private static void elementIsDisplayed(By by) { -- waiting().until(webDriver -> driver.findElement(by).isDisplayed()); -- } -- -- private static void clickOnElementWhenItIsDisplayed(By by) { -- elementIsDisplayed(by); -- driver.findElement(by).click(); -- } -- -- private static void switchToComboModule() { -- driver.switchTo().frame(driver.findElement(COMBO_MODULE)); -- } -- -- private static void switchToDefault() { -- driver.switchTo().defaultContent(); -- } -- -- private static Wait<WebDriver> waiting() { -- return new WebDriverWait(driver, Duration.ofSeconds(30)) -- .ignoring(StaleElementReferenceException.class) -- .ignoring(NoSuchElementException.class); -- } -- -- private static WebElement getDisruptionIcon(int n) { -- final List<WebElement> stops = driver.findElements(DRIVING_SCREEN_STOPS); -- final WebElement stop = stops.get(n - 1); -- return stop.findElement(DISRUPTION_ICON); -- } -- -- private static WebElement getLineInfoDisruptionIcon() { -- return driver.findElement(LINE_INFO_DISRUPTION_ICON); -- } -- -- @And("^We hit the call emergency button on the driving screen$") -- public void weHitTheCallEmergencyButtonOnDrivingScreen() { -- BaseTestTrillian.switchToFrame("module-SlartiComboModule"); -- seleniumHelper.touchByWebElement(driver.findElement(By.xpath("//*[@id='btn-callEmergency']"))); -- } -- -- @And("^We hit the call confirm button on dialog$") -- public void weHitTheCallConfirmButtonOnDialog() { -- clickOnElementWhenItIsDisplayed(By.id("callEmergencyDialog-ok")); -- } -- -- @And("^A trip stop is displayed on the driving screen$") -- public void aTripStopIsDisplayedOnDrivingScreen() { -- switchToComboModule(); -- elementIsDisplayed(DRIVING_SCREEN_STOPS); -- switchToDefault(); -- } --} -- -- -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/DrivingScreenUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/DrivingScreenUiTest.java -deleted file mode 100644 -index 8dacf41..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/DrivingScreenUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions( glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/drivingScreen.feature", plugin = { "pretty", "html:target/cucumber/drivingScreen", "json:target/cucumber.drivingScreen.json" }) --public class DrivingScreenUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/InboundConnectionSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/InboundConnectionSteps.java -deleted file mode 100644 -index 0629149..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/InboundConnectionSteps.java -+++ /dev/null -@@ -1,361 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.api.timetable.situation.v1.path.TimetableSituationAPI; --import ch.post.it.paisa.api.timetable.wait.v1.ExternalFeederIdentifier; --import ch.post.it.paisa.api.timetable.wait.v1.InternalFeederIdentifier; --import ch.post.it.paisa.api.timetable.wait.v1.WaitConfirmation; --import ch.post.it.paisa.api.timetable.wait.v1.path.TimetableWaitAPI; --import ch.post.it.paisa.trillian.test.RestAssuredSupport; --import ch.post.it.paisa.trillian.test.SeleniumContext; --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.Given; --import io.cucumber.java.en.Then; --import io.cucumber.java.en.When; --import org.junit.Assert; --import org.openqa.selenium.By; --import org.openqa.selenium.TimeoutException; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.ui.ExpectedConditions; -- --import java.lang.reflect.InvocationTargetException; --import java.lang.reflect.Method; --import java.util.List; --import java.util.Map; -- --import static ch.post.it.paisa.trillian.test.RestAssuredSupport.deleteResource; --import static ch.post.it.paisa.trillian.test.TestPaths.*; -- --public class InboundConnectionSteps extends AbstractSteps { -- -- @Given("^Wait confirmation is deleted$") -- public void Wait_confirmation_is_deleted(DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- String fetcherTripInstanceId = data.get("fetcherTripInstanceId"); -- String fetcherStopId = data.get("fetcherStopId"); -- String departureTime = data.get("departureTime"); -- -- String url = WAIT_CONFIRMATION -- .replace("{fetcherTripInstanceId}", fetcherTripInstanceId) -- .replace("{fetcherStopId}", fetcherStopId) -- .replace("{departureTime}", departureTime); -- deleteResource(url); -- ensureNotFound(url); -- } -- -- @Given("^The inbound connections are deleted$") -- public void theInboundConnectionsAreDeleted(DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- String fetcherTripInstanceId = data.get("fetcherTripInstanceId"); -- String fetcherStopId = data.get("fetcherStopId"); -- String departureTime = data.get("departureTime"); -- -- String url = SELECTED_INBOUND_CONNECTION -- .replace("{fetcherTripInstanceId}", fetcherTripInstanceId) -- .replace("{fetcherStopId}", fetcherStopId) -- .replace("{departureTime}", departureTime); -- deleteResource(url); -- ensureNotFound(url); -- -- String connectionsUrl = getEagle1BaseUrl() + "/data/trillian" + TimetableSituationAPI.connections.BASED.trips.feederTripInstanceId$.stops.feederStopId$.arrivals.arrivalTime$.connections_.RESOURCE -- .replace("{feederTripInstanceId}", fetcherTripInstanceId) -- .replace("{feederStopId}", fetcherStopId) -- .replace("{arrivalTime}", departureTime); -- deleteResource(connectionsUrl); -- ensureNotFound(connectionsUrl); -- } -- -- @Then("^We see the following inbound connections$") -- public void We_see_the_following_inbound_connections(DataTable dataTable) { -- List<List<String>> raw = dataTable.asLists(); -- List<List<String>> rows = raw.subList(1, raw.size()); -- -- WebElement ulElement = BaseTestTrillian.getWait().until(ExpectedConditions.presenceOfElementLocated(By.id("inboundConnectionsList"))); -- SeleniumContext.writeBrowserScreenshot("connection"); -- int inboundConnectionIndex = 0; -- for (List<String> row : rows) { -- WebElement liElement = ulElement.findElement(By.xpath("li[" + (inboundConnectionIndex + 1) + "]")); -- assertInboundConnectionListElement("inbound connection at index " + inboundConnectionIndex, liElement, row); -- inboundConnectionIndex++; -- } -- } -- -- @Then("^The following inbound connection is automatically selected$") -- public void The_following_inbound_connection_is_automatically_selected(DataTable dataTable) { -- List<List<String>> raw = dataTable.asLists(); -- List<List<String>> rows = raw.subList(1 /* ignore the header */, raw.size()); -- Assert.assertEquals("There should be only one selected inbound connection.", 1, rows.size()); -- -- WebElement ulElement = BaseTestTrillian.getWait().until(ExpectedConditions.presenceOfElementLocated(By.id("inboundConnectionsList"))); -- SeleniumContext.writeBrowserScreenshot("connection"); -- WebElement selectedLiElement = ulElement.findElement(By.xpath("li[contains(@class,'selected')]")); -- assertInboundConnectionListElement("the selected inbound connection", selectedLiElement, rows.get(0)); -- } -- -- @Then("^No inbound connection is selected$") -- public void No_inbound_connection_is_selected() { -- try { -- BaseTestTrillian.getWait().until(webDriver -> { -- WebElement ulElement = BaseTestTrillian.getWait().until(ExpectedConditions.presenceOfElementLocated(By.id("inboundConnectionsList"))); -- List<WebElement> selectedLiElements = ulElement.findElements(By.xpath("li[contains(@class,'selected')]")); -- int selectedElementCount = selectedLiElements.size(); -- return selectedElementCount == 0; -- }); -- } catch (TimeoutException e) { -- WebElement ulElement = BaseTestTrillian.getWait().until(ExpectedConditions.presenceOfElementLocated(By.id("inboundConnectionsList"))); -- List<WebElement> selectedLiElements = ulElement.findElements(By.xpath("li[contains(@class,'selected')]")); -- int selectedElementCount = selectedLiElements.size(); -- Assert.assertEquals(selectedElementCount + " inbound connections are still selected.", 0, selectedElementCount); -- } -- } -- -- private void assertInboundConnectionListElement(String inboundConnectionTitle, WebElement liElement, List<String> expectedRow) { -- -- // status -- WebElement statusElement = findElementWithoutTimeout(By.className("status"), liElement); -- WebElement statusIcon = findElementWithoutTimeout(By.tagName("span"), statusElement); -- String statusIconClassName = statusIcon.getAttribute("class"); -- String status = null; -- if (statusIconClassName.contains("icon-check-circle")) { -- status = "fine"; -- } else if (statusIconClassName.contains("icon-bolt")) { -- status = "wait"; -- } else if (statusIconClassName.contains("icon-close")) { -- status = "broken"; -- } else { -- Assert.fail("Unknown status found: " + statusIconClassName); -- } -- -- Assert.assertEquals("The category of " + inboundConnectionTitle + " is wrong.", expectedRow.get(0), getElementTextByClassName("category", liElement)); -- Assert.assertEquals("The line number of " + inboundConnectionTitle + " is wrong.", expectedRow.get(1), getElementTextByClassName("line-number", liElement)); -- Assert.assertEquals("The planned arrival platform of " + inboundConnectionTitle + " is wrong.", expectedRow.get(2), getElementTextByClassName("planned-arrival-platform", liElement)); -- Assert.assertEquals("The arrival time of " + inboundConnectionTitle + " is wrong.", expectedRow.get(3), getElementTextByClassName("arrival-time", liElement)); -- Assert.assertEquals("The status of " + inboundConnectionTitle + " is wrong.", expectedRow.get(4), status); -- Assert.assertEquals("The minutes to wait of " + inboundConnectionTitle + " is wrong.", expectedRow.get(5), getElementTextByClassName("minutes-to-wait", liElement)); -- } -- -- @When("^We select the inbound connection with line number \"(.+)\"$") -- public void We_select_the_inbound_connection_with_line_number(String lineNumber) { -- seleniumHelper.touchByXpath("//div[@id='inbound-connections']/ul/li//span[contains(@class,'line-number') and text()='" + lineNumber + "']"); -- } -- -- @When("^We select the inbound connection with arrival time \"(.+)\"$") -- public void We_select_the_inbound_connection_with_arrival_time(String arrivalTime) { -- seleniumHelper.touchByXpath("//div[@id='inbound-connections']/ul/li//span[contains(@class,'arrival-time') and text()='" + arrivalTime + "']"); -- } -- -- @Then("^The summary of the selected inbound connection shows") -- public void The_summary_of_the_selected_inbound_connection_shows(DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- String expectedCategory = data.get("category"); -- String expectedLineNumber = data.get("lineNumber"); -- String expectedArrivalTime = data.get("arrivalTime"); -- String expectedDelayInMinutes = data.get("delayInMinutes"); -- String expectedChangeTime = data.get("changeTime"); -- String expectedMinutesToWait = data.get("minutesToWait"); -- String expectedCallButtonVisible = data.get("callButtonVisible"); -- -- WebElement panelElement = BaseTestTrillian.getWait().until(ExpectedConditions.presenceOfElementLocated(By.id("summary-selected-connection-panel"))); -- -- String category = getElementTextByClassName("category", panelElement); -- Assert.assertEquals("The category of the selected inbound connection is wrong.", expectedCategory, category); -- -- String lineNumber = getElementTextByClassName("line-number", panelElement); -- Assert.assertEquals("The line number of the selected inbound connection is wrong.", expectedLineNumber, lineNumber); -- -- String arrivalTime = getElementTextByClassName("arrival-time", panelElement); -- Assert.assertEquals("The arrival time of the selected inbound connection is wrong.", expectedArrivalTime, arrivalTime); -- -- String delayInMinutes = getElementTextByClassName("delay-in-minutes", panelElement); -- Assert.assertEquals("The delay in minutes of the selected inbound connection is wrong.", expectedDelayInMinutes, delayInMinutes); -- -- String changeTime = getElementTextByClassName("change-time", panelElement); -- Assert.assertEquals("The change time of the selected inbound connection is wrong.", expectedChangeTime, changeTime); -- -- String minutesToWait = getElementTextByClassName("minutes-to-wait", panelElement); -- Assert.assertEquals("The minutes to wait of the selected inbound connection is wrong.", expectedMinutesToWait, minutesToWait); -- -- WebElement callButtonElement = findElementWithoutTimeout(By.id("callButton"), panelElement); -- Assert.assertEquals("The call button visibility of the selected inbound connection is wrong.", "yes".equals(expectedCallButtonVisible), callButtonElement.isDisplayed()); -- } -- -- @Then("^The summary of the selected inbound connection panel is not visible") -- public void The_summary_selected_inbound_connection_panel_not_not_visible() { -- WebElement footerElement = BaseTestTrillian.getWait().until(ExpectedConditions.presenceOfElementLocated(By.id("inbound-connections-footer"))); -- int count = findElementsWithoutTimeout(By.id("summary-selected-connection-panel"), footerElement).size(); -- Assert.assertEquals("The summary selected inbound connection panel still exists.", 0, count); -- } -- -- @Then("^The header bar title is \"(.+)\"$") -- public void The_header_bar_title_is(String expectedHeaderBarTitle) { -- getWait().until(webdriver -> expectedHeaderBarTitle.equals(seleniumHelper.getWebElementById("headerbarTitle").getText())); -- } -- -- @Then("^The departure time of the trip stop is \"(.+)\" and \"(.*)\"$") -- public void The_departure_time_of_the_trip_stop_is(String expectedTripStopDepartureTime, String expectedTripStopMinutesToWait) { -- String tripStopDepartureTime = seleniumHelper.getWebElementById("tripStopDepartureTime").getText(); -- Assert.assertEquals("Departure time of the trip stop is wrong.", expectedTripStopDepartureTime, tripStopDepartureTime); -- -- String tripStopMinutesToWait = seleniumHelper.getWebElementById("tripStopMinutesToWait").getText(); -- Assert.assertEquals("Minutes to wait of the trip stop is wrong.", expectedTripStopMinutesToWait, tripStopMinutesToWait); -- } -- -- @Then("^The wait confirmation of departure time \"(.+)\" at stop \"(.+)\" on trip \"(.+)\" is$") -- public void The_wait_confirmation_of_departure_time_at_stop_on_trip_is(String departureTime, String fetcherStopId, String fetcherTripInstanceId, DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- final String url = getEagle1BaseUrl() + TimetableWaitAPI.trips.fetcherTripInstanceId$.stops.fetcherStopId$.departures.departureTime$.confirmation.RESOURCE; -- WaitConfirmation waitConfirmation = RestAssuredSupport.get(url, fetcherTripInstanceId, fetcherStopId, departureTime).extract().body().as(WaitConfirmation.class); -- Assert.assertEquals("The waiting is wrong.", Boolean.parseBoolean(data.get("waiting")), waitConfirmation.getWaiting()); -- } -- -- @Then("^The internal feeders waited for of wait confirmation of departure time \"(.+)\" at stop \"(.+)\" on trip \"(.+)\" are$") -- public void The_internal_feeders_waited_for_of_wait_confirmation_of_departure_time_at_stop_on_trip_are(String departureTime, String fetcherStopId, String fetcherTripInstanceId, DataTable dataTable) { -- assertWaitConfirmationInternalFeederIdentifiers(true, departureTime, fetcherStopId, fetcherTripInstanceId, dataTable); -- } -- -- @Then("^The internal feeders not waited for of wait confirmation of departure time \"(.+)\" at stop \"(.+)\" on trip \"(.+)\" are$") -- public void The_internal_feeders_not_waited_for_of_wait_confirmation_of_departure_time_at_stop_on_trip_are(String departureTime, String fetcherStopId, String fetcherTripInstanceId, DataTable dataTable) { -- assertWaitConfirmationInternalFeederIdentifiers(false, departureTime, fetcherStopId, fetcherTripInstanceId, dataTable); -- } -- -- @Then("^There are no internal feeders waited for in wait confirmation of departure time \"(.+)\" at stop \"(.+)\" on trip \"(.+)\"$") -- public void There_are_no_internal_feeders_waited_for_in_wait_confirmation_of_departure_time_at_stop_on_trip(String departureTime, String fetcherStopId, String fetcherTripInstanceId) { -- assertWaitConfirmationFeederIdentifiersEmpty(InternalFeederIdentifier.class, true, departureTime, fetcherStopId, fetcherTripInstanceId); -- } -- -- @Then("^There are no internal feeders not waited for in wait confirmation of departure time \"(.+)\" at stop \"(.+)\" on trip \"(.+)\"$") -- public void There_are_no_internal_feeders_not_waited_for_in_wait_confirmation_of_departure_time_at_stop_on_trip(String departureTime, String fetcherStopId, String fetcherTripInstanceId) { -- assertWaitConfirmationFeederIdentifiersEmpty(InternalFeederIdentifier.class, false, departureTime, fetcherStopId, fetcherTripInstanceId); -- } -- -- @Then("^The external feeders waited for of wait confirmation of departure time \"(.+)\" at stop \"(.+)\" on trip \"(.+)\" are$") -- public void The_external_feeders_waited_for_of_wait_confirmation_of_departure_time_at_stop_on_trip_are(String departureTime, String fetcherStopId, String fetcherTripInstanceId, DataTable dataTable) { -- assertWaitConfirmationExternalFeederIdentifiers(true, departureTime, fetcherStopId, fetcherTripInstanceId, dataTable); -- } -- -- @Then("^The external feeders not waited for of wait confirmation of departure time \"(.+)\" at stop \"(.+)\" on trip \"(.+)\" are$") -- public void The_external_feeders_not_waited_for_of_wait_confirmation_of_departure_time_at_stop_on_trip_are(String departureTime, String fetcherStopId, String fetcherTripInstanceId, DataTable dataTable) { -- assertWaitConfirmationExternalFeederIdentifiers(false, departureTime, fetcherStopId, fetcherTripInstanceId, dataTable); -- } -- -- @Then("^There are no external feeders waited for in wait confirmation of departure time \"(.+)\" at stop \"(.+)\" on trip \"(.+)\"$") -- public void There_are_no_external_feeders_waited_for_in_wait_confirmation_of_departure_time_at_stop_on_trip(String departureTime, String fetcherStopId, String fetcherTripInstanceId) { -- assertWaitConfirmationFeederIdentifiersEmpty(ExternalFeederIdentifier.class, true, departureTime, fetcherStopId, fetcherTripInstanceId); -- } -- -- @Then("^There are no external feeders not waited for in wait confirmation of departure time \"(.+)\" at stop \"(.+)\" on trip \"(.+)\"$") -- public void There_are_no_external_feeders_not_waited_for_in_wait_confirmation_of_departure_time_at_stop_on_trip(String departureTime, String fetcherStopId, String fetcherTripInstanceId) { -- assertWaitConfirmationFeederIdentifiersEmpty(ExternalFeederIdentifier.class, false, departureTime, fetcherStopId, fetcherTripInstanceId); -- } -- -- private void assertWaitConfirmationInternalFeederIdentifiers(boolean waited, String departureTime, String fetcherStopId, String fetcherTripInstanceId, DataTable dataTable) { -- String feedersTitle = "internal feeders" + (!waited ? " not" : "") + " waited for"; -- List<InternalFeederIdentifier> internalFeedersWaitedFor = getWaitConfirmationFeederIdentifiers(InternalFeederIdentifier.class, waited, departureTime, fetcherStopId, fetcherTripInstanceId); -- if (internalFeedersWaitedFor != null) { -- List<List<String>> rows = dataTable.asLists(String.class); -- -- StringBuilder internalFeedersWaitedForLogMessage = new StringBuilder(); -- if (internalFeedersWaitedFor.size() > 0) { -- internalFeedersWaitedForLogMessage.append("The current internal feeders waited for are:"); -- for (int i = 0; i < internalFeedersWaitedFor.size(); i++) { -- InternalFeederIdentifier internalFeederIdentifier = internalFeedersWaitedFor.get(i); -- internalFeedersWaitedForLogMessage -- .append("\n") -- .append(i + 1).append(".)") -- .append(" tripInstanceId: ").append(internalFeederIdentifier.getTripInstanceId()) -- .append(" arrivalStopId: ").append(internalFeederIdentifier.getArrivalStopId()) -- .append(" arrivalStoppingPointId: ").append(internalFeederIdentifier.getArrivalStoppingPointId()); -- } -- } else { -- internalFeedersWaitedForLogMessage.append("Currently, there is no internal feeder waited for"); -- } -- -- Assert.assertEquals("The number of " + feedersTitle + " is wrong. " + internalFeedersWaitedForLogMessage.toString() + "\n", rows.size() - 1, internalFeedersWaitedFor.size()); -- -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- int internalFeederIndex = i - 1; -- InternalFeederIdentifier internalFeederWaitedFor = internalFeedersWaitedFor.get(internalFeederIndex); -- -- Assert.assertEquals("The trip instance Id of the " + feedersTitle + " at index " + internalFeederIndex + " is wrong.", row.get(0), internalFeederWaitedFor.getTripInstanceId()); -- Assert.assertEquals("The arrival stop Id of the " + feedersTitle + " at index " + internalFeederIndex + " is wrong.", row.get(1), internalFeederWaitedFor.getArrivalStopId()); -- Assert.assertEquals("The arrival stopping point Id of the " + feedersTitle + " at index " + internalFeederIndex + " is wrong.", row.get(2), internalFeederWaitedFor.getArrivalStoppingPointId()); -- } -- } else { -- Assert.fail("The " + feedersTitle + " are undefined."); -- } -- } -- -- private void assertWaitConfirmationExternalFeederIdentifiers(boolean waited, String departureTime, String fetcherStopId, String fetcherTripInstanceId, DataTable dataTable) { -- String feedersTitle = "external feeders" + (!waited ? " not" : "") + " waited for"; -- List<ExternalFeederIdentifier> externalFeedersWaitedFor = getWaitConfirmationFeederIdentifiers(ExternalFeederIdentifier.class, waited, departureTime, fetcherStopId, fetcherTripInstanceId); -- if (externalFeedersWaitedFor != null) { -- List<List<String>> rows = dataTable.asLists(String.class); -- Assert.assertEquals("The number of " + feedersTitle + " is wrong.", rows.size() - 1, externalFeedersWaitedFor.size()); -- -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- int externalFeederIndex = i - 1; -- ExternalFeederIdentifier externalFeederWaitedFor = externalFeedersWaitedFor.get(externalFeederIndex); -- -- Assert.assertEquals("The external system Id of the " + feedersTitle + " at index " + externalFeederIndex + " is wrong.", row.get(0), externalFeederWaitedFor.getExternalSystemId()); -- Assert.assertEquals("The external trip Id of the " + feedersTitle + " at index " + externalFeederIndex + " is wrong.", row.get(1), externalFeederWaitedFor.getExternalTripId()); -- } -- } else { -- Assert.fail("The " + feedersTitle + " are undefined."); -- } -- } -- -- private <T> void assertWaitConfirmationFeederIdentifiersEmpty(Class<T> feederIdentifierClass, boolean waited, String departureTime, String fetcherStopId, String fetcherTripInstanceId) { -- assertFeederIdentifierClass(feederIdentifierClass); -- List<T> feederIdentifiers = getWaitConfirmationFeederIdentifiers(feederIdentifierClass, waited, departureTime, fetcherStopId, fetcherTripInstanceId); -- if (feederIdentifiers != null) { -- String feedersTitle = (feederIdentifierClass == ExternalFeederIdentifier.class ? "external" : "internal") + " feeders" + (!waited ? " not" : "") + " waited for"; -- Assert.assertEquals("The number of " + feedersTitle + " is wrong.", 0, feederIdentifiers.size()); -- } -- } -- -- private <T> void assertFeederIdentifierClass(Class<T> feederIdentifierClass) { -- if (feederIdentifierClass != InternalFeederIdentifier.class && feederIdentifierClass != ExternalFeederIdentifier.class) { -- Assert.fail("Unknown feeder identifier class " + feederIdentifierClass.getName()); -- } -- } -- -- private <T> List<T> getWaitConfirmationFeederIdentifiers(Class<T> feederIdentifierClass, boolean waited, String departureTime, String fetcherStopId, String fetcherTripInstanceId) { -- assertFeederIdentifierClass(feederIdentifierClass); -- -- final String url = getEagle1BaseUrl() + TimetableWaitAPI.trips.fetcherTripInstanceId$.stops.fetcherStopId$.departures.departureTime$.confirmation.RESOURCE; -- WaitConfirmation waitConfirmation = RestAssuredSupport.get(url, fetcherTripInstanceId, fetcherStopId, departureTime).extract().body().as(WaitConfirmation.class); -- String getFeedersMethodName = "get" + (feederIdentifierClass == ExternalFeederIdentifier.class ? "External" : "Internal") + "Feeders" + (!waited ? "Not" : "") + "WaitedFor"; -- try { -- Method getFeedersMethod = waitConfirmation.getClass().getMethod(getFeedersMethodName); -- @SuppressWarnings("unchecked") -- List<T> feederIdentifiers = (List<T>) getFeedersMethod.invoke(waitConfirmation); -- return feederIdentifiers; -- } catch (NoSuchMethodException e) { -- Assert.fail("No " + getFeedersMethodName + " method in WaitConfirmation class."); -- } catch (IllegalAccessException | InvocationTargetException e) { -- Assert.fail("Could not invoke " + getFeedersMethodName + " method in WaitConfirmation object."); -- } -- -- return null; -- } -- -- private static String getElementTextByClassName(String className, WebElement parentElement) { -- List<WebElement> webElements = findElementsWithoutTimeout(By.className(className), parentElement); -- if (webElements.size() > 0) { -- return webElements.get(0).getText(); -- } else { -- return ""; -- } -- } -- -- private static List<WebElement> findElementsWithoutTimeout(By by, WebElement parentElement) { -- return seleniumHelper.withoutTimeout(() -> parentElement.findElements(by)); -- } -- -- private static WebElement findElementWithoutTimeout(By by, WebElement parentElement) { -- return seleniumHelper.withoutTimeout(() -> parentElement.findElement(by)); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/OverviewSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/OverviewSteps.java -deleted file mode 100644 -index 4e48ae4..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/OverviewSteps.java -+++ /dev/null -@@ -1,37 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNavigation; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Then; --import io.cucumber.java.en.When; --import org.junit.Assert; --import org.openqa.selenium.By; --import org.openqa.selenium.support.ui.ExpectedConditions; -- --public class OverviewSteps extends AbstractSteps { -- -- @When("^We open the Trillian phonebook overview$") -- public void weOpenTheTrillianPhonebookOverview() { -- final SlartiNavigation slartiNavigation = new SlartiNavigation(driver, seleniumHelper); -- slartiNavigation.touchTrillianModule(); -- BaseTestTrillian.switchToFrame("module-Trillian"); -- } -- -- @Then("^We click on the call icon of entry with number \"([^\"]*)\"$") -- public void initiateACallFromFavouriteWithNumber(String phonenumber) { -- BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(By.id("favouritesEntry_icon_" + phonenumber))).click(); -- } -- -- @And("^The entry containing phone number \"([^\"]*)\" with name \"([^\"]*)\" is displayed$") -- public void theEntryContainingPhoneNumberIsDisplayed(String phonenumber, String name) { -- BaseTestTrillian.getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("favouritesEntry_" + phonenumber))); -- Assert.assertEquals(name, driver.findElement(By.id("favouritesEntry_name_" + name)).getText()); -- } -- -- @And("^The phone number \"([^\"]*)\" is not displayed$") -- public void thePhoneNumberIsNotDisplayed(String phonenumber) { -- Assert.assertEquals(0, driver.findElements(By.id("favouritesEntry_" + phonenumber)).size()); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/OverviewUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/OverviewUiTest.java -deleted file mode 100644 -index 0ad8998..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/OverviewUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions( glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/overview.feature", plugin = { "pretty", "html:target/cucumber/overview", "json:target/cucumber.overview.json" }) --public class OverviewUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookFavouriteSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookFavouriteSteps.java -deleted file mode 100644 -index 5fd2e7e..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookFavouriteSteps.java -+++ /dev/null -@@ -1,184 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.communication.phonebook.v1.PhonebookEntryType; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.ContractorFavourites; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.FavouriteContact; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.FavouriteContactsList; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.path.PAISAControlcenterPhonebookAPI; --import ch.post.it.paisa.trillian.process.phonebook.PhonebookEntry; --import ch.post.it.paisa.trillian.process.phonebook.favourites.FavouritePhonebookEntryList; --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import com.jayway.awaitility.Duration; --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Then; --import io.cucumber.java.en.When; --import io.restassured.RestAssured; --import io.restassured.response.Response; --import org.apache.http.HttpStatus; --import org.joda.time.DateTime; --import org.junit.Assert; --import org.openqa.selenium.By; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.ui.ExpectedConditions; -- --import java.util.List; --import java.util.Map; --import java.util.TreeMap; --import java.util.concurrent.TimeUnit; -- --import static ch.post.it.paisa.trillian.test.TestPaths.TRILLIAN_1_SERVICE_BASE_URL; --import static ch.post.it.paisa.trillian.test.TestPaths.getHoustonBaseUrl; --import static com.jayway.awaitility.Awaitility.given; -- --public class PhonebookFavouriteSteps extends AbstractSteps { -- -- -- @And("^A favourite list with ID \"([^\"]*)\", hasControlCenterCallback \"([^\"]*)\", and the following favourite contact has been PUT to Houston$") -- public void aFavouriteListWithIDTimestampHasControlCenterCallbackAndTheFollowingFavouriteContactHasBeenPUTToHouston(String listId, String hasControlCenterCallback, DataTable dataTable) { -- FavouriteContactsList favouriteContactsList = new FavouriteContactsList(); -- favouriteContactsList.setTimestamp(new DateTime()); -- favouriteContactsList.setHasControlCenterCallback(hasControlCenterCallback.equalsIgnoreCase("true")); -- favouriteContactsList.setDescription("dummy"); -- -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String planningAreaId = row.get(0); -- String bookId = row.get(1); -- String contactId = row.get(2); -- String position = row.get(3); -- -- FavouriteContact favouriteContact = new FavouriteContact() -- .withPlanningAreaId(Integer.parseInt(planningAreaId)).withBookId(bookId).withContactId(contactId).withPosition(Integer.parseInt(position)); -- favouriteContactsList.getContacts().add(favouriteContact); -- } -- -- final String listUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.favourites.lists.listId$.RESOURCE -- .replace("{listId}", listId); -- RestHelper.put(favouriteContactsList, listUrl); -- } -- -- -- @And("^A link from contractor id \"([^\"]*)\" to favourites list \"([^\"]*)\" is put to Houston$") -- public void aLinkFromContractorIdToFavouritesListIsPutToHouston(String contractorId, String listId) { -- ContractorFavourites contractorFavourites = new ContractorFavourites().withListId(listId); -- final String contractorUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.favourites.contractors.contractorId$.RESOURCE -- .replace("{contractorId}", contractorId); -- RestHelper.put(contractorFavourites, contractorUrl); -- } -- -- @Then("^The favourite contacts in the Eagle storage are$") -- public void theFavouriteContactsInTheEagleStorageAre(DataTable dataTable) { -- Map<Integer, PhonebookEntry> expectedPhonebookEntries = new TreeMap<>(); -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String type = row.get(0); -- String description = row.get(1); -- String phoneNumber = row.get(2); -- int position = Integer.parseInt(row.get(3)); -- expectedPhonebookEntries.put(position, new PhonebookEntry().withType(PhonebookEntryType.valueOf(type)).withDescription(description).withPhoneNumber(phoneNumber)); -- } -- given().await().atMost(new Duration(20L, TimeUnit.SECONDS)).until(() -> { -- String url = TRILLIAN_1_SERVICE_BASE_URL + "/phonebook/contractor/favourites"; -- Response response = RestAssured.get(url); -- Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); -- -- FavouritePhonebookEntryList favouritePhonebookEntryList = response.getBody().as(FavouritePhonebookEntryList.class); -- Map<Integer, PhonebookEntry> actualPhonebookEntries = new TreeMap<>(); -- -- if (favouritePhonebookEntryList.getFavouritePhonebookEntries() != null) { -- favouritePhonebookEntryList.getFavouritePhonebookEntries().forEach(favouritePhonebookEntry -> actualPhonebookEntries.put(favouritePhonebookEntry.getFavouriteContact().getPosition(), favouritePhonebookEntry.getPhonebookEntry())); -- } -- -- Assert.assertEquals(expectedPhonebookEntries.size(), actualPhonebookEntries.size()); -- expectedPhonebookEntries.keySet().forEach(integer -> Assert.assertEquals(expectedPhonebookEntries.get(integer), actualPhonebookEntries.get(integer))); -- }); -- } -- -- @Then("^The favourite contacts on the MMI are$") -- public void theFavouriteContactsOnTheMMIAre(DataTable dataTable) { -- Map<Integer, PhonebookEntry> expectedPhonebookEntries = new TreeMap<>(); -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String type = row.get(0); -- String description = row.get(1); -- int position = Integer.parseInt(row.get(2)); -- PhonebookEntryType phonebookEntryType = type.equals("") ? null : PhonebookEntryType.valueOf(type); -- expectedPhonebookEntries.put(position, new PhonebookEntry().withType(phonebookEntryType).withDescription(description).withPhoneNumber("dummy")); -- } -- -- given().await().atMost(Duration.TEN_SECONDS).until(() -> { -- Map<Integer, PhonebookEntry> actualPhonebookEntries = getActualFavouriteContactsPhonebookEntries(); -- if (expectedPhonebookEntries.size() != actualPhonebookEntries.size()) { -- return false; -- } -- expectedPhonebookEntries.keySet().forEach(integer -> Assert.assertEquals(expectedPhonebookEntries.get(integer), actualPhonebookEntries.get(integer))); -- return true; -- }); -- } -- -- private Map<Integer, PhonebookEntry> getActualFavouriteContactsPhonebookEntries() { -- Map<Integer, PhonebookEntry> webElementPhonebookEntries = new TreeMap<>(); -- for (int i = 1; i <= 6; i++) { -- String favouriteId = "favouriteContacts" + i; -- WebElement favouriteContact = driver.findElement(By.id(favouriteId)); -- if (favouriteContact.getAttribute("disabled") == null) { -- WebElement icon = favouriteContact.findElement(By.tagName("span")); -- WebElement description = favouriteContact.findElement(By.tagName("p")); -- webElementPhonebookEntries.put(i, new PhonebookEntry().withType(getTypeByIcon(icon.getAttribute("class"))).withDescription(description.getText()).withPhoneNumber("dummy")); -- } -- } -- return webElementPhonebookEntries; -- } -- -- private PhonebookEntryType getTypeByIcon(String iconClass) { -- Assert.assertNotNull(iconClass); -- switch (iconClass) { -- case "icon-bus": -- return PhonebookEntryType.VEHICLE; -- case "icon-driver": -- return PhonebookEntryType.DRIVER; -- case "icon-phone-sos": -- return PhonebookEntryType.EMERGENCY; -- case "icon-controll-center": -- return PhonebookEntryType.CONTROLCENTER; -- case "icon-globe": -- return PhonebookEntryType.PARTNER; -- case "icon-briefcase": -- return PhonebookEntryType.OPERATION; -- case "icon-group": -- return PhonebookEntryType.OTHERS; -- default: -- return null; -- } -- } -- -- @And("We click the favourite contact at position {string}") -- public void weClickTheFavouriteContactAtPosition(String index) { -- BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(By.id("favouriteContacts" + index))).click(); -- } -- -- @When("We open the phonebook favourites") -- public void weOpenThePhonebookFavourites() { -- seleniumHelper.switchToRoot(); -- seleniumHelper.touchByWebElement(seleniumHelper.getWebElementById("DrivingScreenLinkFullscreen")); -- BaseTestTrillian.switchToFrame("module-SlartiComboModule"); -- driver.findElement(By.id("driving-screen")).isDisplayed(); -- BaseTestTrillian.waitAndTouchByWebElement("btn-phonebook"); -- BaseTestTrillian.switchToFrame("module-Trillian"); -- } -- -- @When("We reopen the phonebook favourites") -- public void weReopenThePhonebookFavourites() { -- seleniumHelper.touchByWebElement(seleniumHelper.getWebElementById("headerbarBackButton")); -- BaseTestTrillian.switchToFrame("module-SlartiComboModule"); -- driver.findElement(By.id("driving-screen")).isDisplayed(); -- BaseTestTrillian.waitAndTouchByWebElement("btn-phonebook"); -- BaseTestTrillian.switchToFrame("module-Trillian"); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookFavouriteUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookFavouriteUiTest.java -deleted file mode 100644 -index f9bb875..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookFavouriteUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions(glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/phonebook-favourites.feature", plugin = {"pretty", "html:target/cucumber/phonebook-favourites", "json:target/cucumber.phonebook-favourites.json"}) --public class PhonebookFavouriteUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookNsyncSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookNsyncSteps.java -deleted file mode 100644 -index 0afe9cf..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookNsyncSteps.java -+++ /dev/null -@@ -1,353 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.*; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.path.PAISAControlcenterPhonebookAPI; --import ch.post.it.paisa.api.vehicle.profile.v1.Affiliation; --import ch.post.it.paisa.api.vehicle.profile.v1.path.VehicleProfileAPI; --import ch.post.it.paisa.api.vehicle.status.v3.PlanningArea; --import ch.post.it.paisa.api.vehicle.status.v3.path.VehicleStatusAPI; --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import com.fasterxml.jackson.databind.JsonNode; --import com.jayway.awaitility.Duration; --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Given; --import io.cucumber.java.en.Then; --import io.cucumber.java.en.When; --import io.restassured.RestAssured; --import io.restassured.response.Response; --import org.apache.http.HttpStatus; --import org.springframework.util.StringUtils; -- --import java.util.List; --import java.util.concurrent.TimeUnit; -- --import static ch.post.it.paisa.trillian.test.TestPaths.*; --import static com.jayway.awaitility.Awaitility.given; -- --public class PhonebookNsyncSteps extends AbstractSteps { -- -- @And("^The following phonebooks are not present on the eagle and houston$") -- public void theFollowingPhonebooksAreNotPresentOnTheEagleAndHouston(DataTable dataTable) { -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String planningareaId = row.get(0); -- delete(getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.RESOURCE, planningareaId); -- delete(getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.RESOURCE, planningareaId); -- } -- } -- -- @Then("^A phonebook with ID \"([^\"]*)\", name \"([^\"]*)\", planning area \"([^\"]*)\", version \"([^\"]*)\" is present on the Eagle$") -- public void aPhonebookWithIDNamePlanningAreaVersionIsPresentOnTheEagle(String phonebookId, String phonebookName, String planningAreaId, String version) { -- // TODO: ISABUFC-2190 make Nsync integration tests pass repeatedly -- // we should be able to reduce this to 5s or so? Shouldn't take that long? -- // TODO: SDCISA-697 SocketTimeout upon NSync registration -- given().await().atMost(new Duration(32L, TimeUnit.SECONDS)).until(() -> { -- String url = getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE; -- Response response = RestAssured.get(url, planningAreaId, phonebookId); -- -- int statusCode = response.getStatusCode(); -- if (statusCode != HttpStatus.SC_OK) { -- return false; -- } -- -- BookInfo bookInfo = response.getBody().as(BookInfo.class); -- return bookInfo.getName().equals(phonebookName) && bookInfo.getVersion().contains(version); -- }); -- } -- -- @And("^A phonebook with ID \"([^\"]*)\", planning area \"([^\"]*)\" is NOT present on the Eagle$") -- public void aPhonebookWithIDPlanningAreaIsNOTPresentOnTheEagle(String phonebookId, String planningAreaId) { -- ensureNotFound(getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE, planningAreaId, phonebookId); -- } -- -- @Given("^An affiliation resource has been PUT for each vehicle, with the following planning areas$") -- public void An_affiliation_resource_has_been_put_for_each_vehicle_with_the_following_planning_areas(DataTable dataTable) { -- Affiliation affiliation = new Affiliation(); -- affiliation.setFunctionalLocationId("dummy"); -- affiliation.setRegionId("dummy"); -- affiliation.setMainOperationGroup("dummy"); -- -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String vehicleId = row.get(0); -- int planningAreaId = Integer.parseInt(row.get(1)); -- -- affiliation.setPlanningAreaId(planningAreaId); -- -- String houstonAffiliationUrl = getHoustonBaseUrl() + VEHICLE_PROFILE_AFFILIATION_PATH.replace("{vehicleId}", vehicleId); -- RestHelper.put(affiliation, houstonAffiliationUrl); -- -- // the affiliation is synced to the vehicles daily, see in Prak, we "sync" to the vehicle right now -- String eagleAffiliationUrl = getEagle1BaseUrl() + VehicleProfileAPI.affiliation.RESOURCE; -- RestHelper.put(affiliation, eagleAffiliationUrl); -- -- // Affiliation never ever overrides current planning area id, so we have to PUT it explicitly -- PlanningArea planningarea = new PlanningArea(); -- planningarea.setPlanningAreaId(affiliation.getPlanningAreaId()); -- String eagleCurrentPlanningarea = getEagle1BaseUrl() + VehicleStatusAPI.current.planningarea.RESOURCE; -- RestHelper.put(planningarea, eagleCurrentPlanningarea); -- } -- } -- -- @And("^The sync parameters are set as follows on the houston$") -- public void theSyncParametersAreSetAsFollowsOnTheHouston(DataTable dataTable) { -- List<List<String>> rows = dataTable.asLists(String.class); -- -- SyncSpeed syncSpeed = new SyncSpeed(); -- -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String resource = row.get(0); -- Integer repetitionIntervalSeconds = Integer.parseInt(row.get(1)); -- Integer collectionWindowSize = StringUtils.isEmpty(row.get(2)) ? null : Integer.parseInt(row.get(2)); -- -- Timings timings = new Timings().withRepetitionIntervalSeconds(repetitionIntervalSeconds); -- -- if (collectionWindowSize != null) { -- timings.setCollectionWindowSizeSeconds(collectionWindowSize); -- } -- -- switch (resource) { -- case "books": -- syncSpeed.setBooks(timings); -- break; -- case "vehicleContacts": -- syncSpeed.setVehicleContacts(timings); -- break; -- case "vehicles": -- syncSpeed.setVehicles(timings); -- break; -- case "drivers": -- syncSpeed.setDrivers(timings); -- break; -- } -- } -- -- put(syncSpeed, PAISAControlcenterPhonebookAPI.sync.parameter.RESOURCE); -- } -- -- @Then("^The sync parameters on the eagle are$") -- public void theSyncParametersOnTheEagleAre(final DataTable dataTable) { -- given().await().atMost(new Duration(30L, TimeUnit.SECONDS)).until(() -> { -- Response response = RestAssured.get(getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.sync.parameter.RESOURCE); -- -- int statusCode = response.getStatusCode(); -- if (statusCode != HttpStatus.SC_OK) { -- return false; -- } -- -- SyncSpeed syncSpeed = response.getBody().as(SyncSpeed.class); -- boolean verifyResult = false; -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String resource = row.get(0); -- Integer repetitionIntervalSeconds = Integer.parseInt(row.get(1)); -- Integer collectionWindowSize = StringUtils.isEmpty(row.get(2)) ? null : Integer.parseInt(row.get(2)); -- -- switch (resource) { -- case "books": -- verifyResult = syncSpeed.getBooks().getRepetitionIntervalSeconds().equals(repetitionIntervalSeconds); -- if (verifyResult && collectionWindowSize != null) { -- verifyResult = syncSpeed.getBooks().getCollectionWindowSizeSeconds().equals(collectionWindowSize); -- } -- break; -- case "vehicleContacts": -- verifyResult = syncSpeed.getVehicleContacts().getRepetitionIntervalSeconds().equals(repetitionIntervalSeconds); -- if (verifyResult && collectionWindowSize != null) { -- verifyResult = syncSpeed.getVehicleContacts().getCollectionWindowSizeSeconds().equals(collectionWindowSize); -- } -- break; -- case "vehicles": -- verifyResult = syncSpeed.getVehicles().getRepetitionIntervalSeconds().equals(repetitionIntervalSeconds); -- if (verifyResult && collectionWindowSize != null) { -- verifyResult = syncSpeed.getVehicles().getCollectionWindowSizeSeconds().equals(collectionWindowSize); -- } -- break; -- case "drivers": -- verifyResult = syncSpeed.getDrivers().getRepetitionIntervalSeconds().equals(repetitionIntervalSeconds); -- if (verifyResult && collectionWindowSize != null) { -- verifyResult = syncSpeed.getDrivers().getCollectionWindowSizeSeconds().equals(collectionWindowSize); -- } -- break; -- } -- } -- -- return verifyResult; -- }); -- } -- -- @And("^The nsync registrations are deleted$") -- public void theNsyncRegistrationsAreDeleted() { -- String basePath = getEagle1BaseUrl() + "/nsync/v1/syncs/"; -- JsonNode jsonNode = RestAssured.get(basePath).getBody().as(JsonNode.class); -- -- for( JsonNode registration : jsonNode.get("syncs") ) { -- RestAssured.delete(basePath + registration.asText()); -- } -- -- // give client / server a bit time -- try { -- Thread.sleep(5000); -- } catch (InterruptedException ignored) { -- } -- } -- -- @And("^A vehicle contact with vehicle id \"([^\"]*)\", planning area \"([^\"]*)\", and the following entries have been PUT to Houston$") -- public void aVehicleContactWithVehicleIdPlanningAreaAndTheFollowingEntriesHaveBeenPUTToHouston(String vehicleId, String planningAreaId, DataTable dataTable) { -- VehicleContact contact = new VehicleContact(); -- contact.setVehicleId(vehicleId); -- -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String personalNumber = row.get(0); -- String tripInstanceId = row.get(1); -- -- contact.setPersonalNumber(personalNumber); -- contact.setTripInstanceId(tripInstanceId); -- } -- -- RestHelper.put(contact, getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.RESOURCE + "/" + -- planningAreaId + -- "/vehicles/" + -- vehicleId); -- } -- -- @And("^A vehicle contact with vehicle id \"([^\"]*)\", planning area \"([^\"]*)\", personal number \"([^\"]*)\" and trip instance id \"([^\"]*)\" is present on the Eagle$") -- public void aVehicleContactWithVehicleIdPlanningAreaPersonalNumberAndTripInstanceIdIsPresentOnTheEagle(String vehicleId, String planningAreaId, String personalNumber, String tripinstanceId) { -- given().await().atMost(new Duration(10L, TimeUnit.SECONDS)).until(() -> { -- String url = getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.vehicles.vehicleId$.RESOURCE; -- Response response = RestAssured.get(url, planningAreaId, vehicleId); -- -- int statusCode = response.getStatusCode(); -- if (statusCode != HttpStatus.SC_OK) { -- return false; -- } -- -- VehicleContact vehicleContact = response.getBody().as(VehicleContact.class); -- return vehicleContact.getVehicleId().equals(vehicleId) && -- vehicleContact.getPersonalNumber().equals(personalNumber) && -- vehicleContact.getTripInstanceId().equals(tripinstanceId); -- }); -- } -- -- @And("^A vehicle contact with vehicle id \"([^\"]*)\", planning area \"([^\"]*)\" is NOT present on the Eagle$") -- public void aVehicleContactWithVehicleIdPlanningAreaIsNOTPresentOnTheEagle(String vehicleId, String planningAreaId){ -- ensureNotFound(getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.vehicles.vehicleId$.RESOURCE, planningAreaId, vehicleId); -- } -- -- @And("^The following vehicle contacts are not present on the eagle and houston$") -- public void theFollowingVehicleContactsAreNotPresentOnTheEagleAndHouston(DataTable dataTable) { -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String vehicleId = row.get(0); -- String planningareaId = row.get(1); -- delete(getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.vehicles.vehicleId$.RESOURCE, planningareaId, vehicleId); -- delete(getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.vehicles.vehicleId$.RESOURCE, planningareaId, vehicleId); -- } -- } -- -- @When("^A driver with personal number \"([^\"]*)\", phone number \"([^\"]*)\" and name \"([^\"]*)\" is PUT to Houston$") -- public void aDriverWithPersonalNumberPhoneNumberAndNameIsPUTToHouston(String personalNumber, String phoneNumber, String name) { -- Driver driver = new Driver(); -- driver.setPersonalNumber(personalNumber); -- driver.setName(name); -- driver.setPhoneNumber(phoneNumber); -- -- put(driver, PAISAControlcenterPhonebookAPI.drivers.personalNumber$.RESOURCE, personalNumber); -- } -- -- @And("^A vehicle with vehicle id \"([^\"]*)\", licence plate number \"([^\"]*)\" and phone number \"([^\"]*)\" is PUT to Houston$") -- public void aVehicleWithVehicleIdLicencePlateNumberAndPhoneNumberIsPUTToHouston(String vehicleId, String licencePlateNumber, String phoneNumber) { -- Vehicle vehicle = new Vehicle(); -- vehicle.setLicencePlateNumber(licencePlateNumber); -- vehicle.setPhoneNumber(phoneNumber); -- vehicle.setVehicleId(vehicleId); -- -- put(vehicle, PAISAControlcenterPhonebookAPI.vehicles.vehicleId$.RESOURCE, vehicleId); -- } -- -- @Then("^A driver with personal number \"([^\"]*)\", phone number \"([^\"]*)\" and name \"([^\"]*)\" is present on the Eagle$") -- public void aDriverWithPersonalNumberPhoneNumberAndNameIsPresentOnTheEagle(String personalNumber, String phoneNumber, String name) { -- given().await().atMost(new Duration(5L, TimeUnit.SECONDS)).until(() -> { -- String url = getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.drivers.personalNumber$.RESOURCE; -- Response response = RestAssured.get(url, personalNumber); -- -- int statusCode = response.getStatusCode(); -- if (statusCode != HttpStatus.SC_OK) { -- return false; -- } -- -- Driver driver = response.getBody().as(Driver.class); -- return driver.getName().equals(name) && -- driver.getPersonalNumber().equals(personalNumber) && -- driver.getPhoneNumber().equals(phoneNumber); -- }); -- } -- -- @And("^A vehicle with vehicle id \"([^\"]*)\", licence plate number \"([^\"]*)\" and phone number \"([^\"]*)\" is present on the Eagle$") -- public void aVehicleWithVehicleIdLicencePlateNumberAndPhoneNumberIsPresentOnTheEagle(String vehicleId, String licencePlateNumber, String phoneNumber) { -- given().await().atMost(new Duration(5L, TimeUnit.SECONDS)).until(() -> { -- String url = getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.vehicles.vehicleId$.RESOURCE; -- Response response = RestAssured.get(url, vehicleId); -- -- int statusCode = response.getStatusCode(); -- if (statusCode != HttpStatus.SC_OK) { -- return false; -- } -- -- Vehicle vehicle = response.getBody().as(Vehicle.class); -- return vehicle.getVehicleId().equals(vehicleId) && -- vehicle.getLicencePlateNumber().equals(licencePlateNumber) && -- vehicle.getPhoneNumber().equals(phoneNumber); -- }); -- } -- -- @And("^The following vehicles are not present on the eagle and houston$") -- public void theFollowingVehiclesAreNotPresentOnTheEagleAndHouston(DataTable dataTable) { -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String vehicleId = row.get(0); -- delete(getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.vehicles.vehicleId$.RESOURCE, vehicleId); -- delete(getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.vehicles.vehicleId$.RESOURCE, vehicleId); -- } -- } -- -- @And("^The following drivers are not present on the eagle and houston$") -- public void theFollowingDriversAreNotPresentOnTheEagleAndHouston(DataTable dataTable) { -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String personalNumber = row.get(0); -- delete(getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.drivers.personalNumber$.RESOURCE, personalNumber); -- delete(getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.drivers.personalNumber$.RESOURCE, personalNumber); -- } -- } -- -- @When("^A driver with personal number \"([^\"]*)\" is DELETED on Houston$") -- public void aDriverWithPersonalNumberIsDELETEDOnHouston(String personalNumber) { -- delete(getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.drivers.personalNumber$.RESOURCE, personalNumber); -- } -- -- @And("^A vehicle with vehicle id \"([^\"]*)\" is DELETED on Houston$") -- public void aVehicleWithVehicleIdIsDELETEDOnHouston(String vehicleId) { -- delete(getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.vehicles.vehicleId$.RESOURCE, vehicleId); -- } -- -- @Then("^A driver with personal number \"([^\"]*)\" is NOT present on Eagle$") -- public void aDriverWithPersonalNumberIsNOTPresentOnEagle(String personalNumber) { -- ensureNotFound(getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.drivers.personalNumber$.RESOURCE, personalNumber); -- } -- -- @And("^A vehicle with vehicle id \"([^\"]*)\" is NOT present on Eagle$") -- public void aVehicleWithVehicleIdIsNOTPresentOnEagle(String vehicleId) { -- ensureNotFound(getEagle1BaseUrl() + PAISAControlcenterPhonebookAPI.vehicles.vehicleId$.RESOURCE, vehicleId); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookNsyncUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookNsyncUiTest.java -deleted file mode 100644 -index 3af9d77..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookNsyncUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions(glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/phonebook-nsync.feature", plugin = {"pretty", "html:target/cucumber/phonebook-nsync", "json:target/cucumber.phonebook-nsync.json"}) --public class PhonebookNsyncUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookSelectionUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookSelectionUiTest.java -deleted file mode 100644 -index abed485..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookSelectionUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions(glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/phonebookSelection.feature", plugin = {"pretty", "html:target/cucumber/phonebookSelection", "json:target/cucumber.phonebookSelection.json"}) --public class PhonebookSelectionUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookSteps.java -deleted file mode 100644 -index f0810bf..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookSteps.java -+++ /dev/null -@@ -1,624 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.communication.modem.v1.Info; --import ch.post.it.paisa.api.communication.modem.v1.path.CommunicationModemAPI; --import ch.post.it.paisa.api.communication.v1.CallInfo; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.BookInfo; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.Contact; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.ContactType; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.Driver; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.path.PAISAControlcenterPhonebookAPI; --import ch.post.it.paisa.api.timetable.common.v1.TripInstance; --import ch.post.it.paisa.api.timetable.common.v1.TripInstanceTimetableType; --import ch.post.it.paisa.api.timetable.common.v1.TripStop; --import ch.post.it.paisa.api.timetable.registration.v1.TripInitialization; --import ch.post.it.paisa.api.timetable.registration.v1.path.TimetableRegistrationAPI; --import ch.post.it.paisa.api.vehicle.messaging.v1.path.PAISAVehicleMessagingAPI; --import ch.post.it.paisa.api.vehicle.profile.v1.Affiliation; --import ch.post.it.paisa.api.vehicle.profile.v1.path.VehicleProfileAPI; --import ch.post.it.paisa.api.vehicle.status.v3.PlanningArea; --import ch.post.it.paisa.api.vehicle.status.v3.path.VehicleStatusAPI; --import ch.post.it.paisa.trillian.test.TrillianTestRestHelper; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.ExpectedPhonebookData; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNavigation; --import ch.post.it.paisa.trillian.test.ui.mock.MockInstances; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import ch.post.it.paisa.trillian.test.ui.pages.PhonebookPage; --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Given; --import io.cucumber.java.en.Then; --import io.cucumber.java.en.When; --import io.restassured.RestAssured; --import io.restassured.response.Response; --import org.joda.time.DateTime; --import org.joda.time.LocalDate; --import org.junit.Assert; --import org.openqa.selenium.By; --import org.openqa.selenium.StaleElementReferenceException; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.ui.ExpectedConditions; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; --import org.springframework.util.StringUtils; -- --import javax.annotation.Nullable; --import java.security.MessageDigest; --import java.security.NoSuchAlgorithmException; --import java.util.ArrayList; --import java.util.List; -- --import static ch.post.it.paisa.trillian.test.TestPaths.VEHICLE_PROFILE_AFFILIATION_PATH; --import static ch.post.it.paisa.trillian.test.TestPaths.getHoustonBaseUrl; --import static com.jayway.awaitility.Awaitility.await; --import static com.jayway.awaitility.Awaitility.given; --import static com.jayway.awaitility.Duration.TEN_SECONDS; --import static com.jayway.awaitility.Duration.TWO_SECONDS; --import static java.util.concurrent.TimeUnit.MILLISECONDS; --import static java.util.concurrent.TimeUnit.SECONDS; --import static junit.framework.TestCase.assertFalse; --import static junit.framework.TestCase.assertTrue; -- --public class PhonebookSteps extends AbstractPhonebookSteps { -- private static final Logger LOG = LoggerFactory.getLogger(PhonebookSteps.class); -- -- -- @Given("^An affiliation resource has been PUT to Houston for each vehicle, with the following planning areas and the current planning area is set$") -- public void An_affiliation_resource_has_been_put_to_houston_for_each_vehicle_with_the_following_planning_areas_and_the_current_planning_area_is_set(DataTable dataTable) { -- Affiliation affiliation = new Affiliation(); -- affiliation.setFunctionalLocationId("dummy"); -- affiliation.setRegionId("dummy"); -- affiliation.setMainOperationGroup("dummy"); -- -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String vehicleId = row.get(0); -- int affiliatedPlanningAreaId = Integer.parseInt(row.get(1)); -- int currentPlanningAreaId = affiliatedPlanningAreaId; -- -- if (row.size() >= 3) { -- currentPlanningAreaId = Integer.parseInt(row.get(2)); -- } -- if (row.size() >= 4) { -- affiliation.setContractorId(row.get(3)); -- } -- affiliation.setPlanningAreaId(affiliatedPlanningAreaId); -- -- final String houstonUrl = getHoustonBaseUrl() + VEHICLE_PROFILE_AFFILIATION_PATH -- .replace("{vehicleId}", vehicleId); -- -- RestHelper.put(affiliation, houstonUrl); -- -- // TODO: somehow doesn't end up on the eagle, why is this? Maybe normal ... only synced once in a while? -- // TODO: also change step description if we continue to put to both eagle and houston -- String eagleUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + VehicleProfileAPI.affiliation.RESOURCE; -- RestHelper.put(affiliation, eagleUrl); -- -- // also set the current planning area -- RestHelper.put(new PlanningArea().withPlanningAreaId(currentPlanningAreaId), TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + VehicleStatusAPI.current.planningarea.RESOURCE); -- } -- } -- -- @Given("^The following phone numbers have been set for the vehicles$") -- public void The_following_phone_numbers_have_been_set_for_the_vehicles(DataTable dataTable) { -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String vehicleId = row.get(0); -- String cnum = row.get(1); -- We_set_the_phone_number_of_to(vehicleId, cnum); -- } -- } -- -- @Given("^A phonebook with ID \"(.+)\", name \"(.+)\", planning area \"(.+)\", version \"(.+)\", and the following entries has been PUT to Houston$") -- public void A_phonebook_with_ID_name_planning_area_and_the_following_entries_has_been_PUT_to_Houston(String phonebookId, -- String phonebookKeyName, -- String planningAreaId, -- double version, -- DataTable dataTable) throws NoSuchAlgorithmException { -- MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); -- BookInfo bookInfo = new BookInfo(); -- bookInfo.setName(phonebookKeyName); -- bookInfo.setVersion(String.valueOf(version)); -- final String bookInfoUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE -- .replace("{planningAreaId}", planningAreaId) -- .replace("{bookId}", phonebookId); -- RestHelper.put(bookInfo, bookInfoUrl); -- -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- -- String type = row.get(0); -- String name = row.get(1); -- String phoneNumber = row.get(2); -- -- // Optional fields -- String contactId = null; -- if (row.size() >= 4) { -- contactId = row.get(3); -- } -- -- if (type.equals("VEHICLE")) { -- throw new IllegalArgumentException(type); -- } else { -- ContactType contactType = ContactType.valueOf(type); -- Contact contact = new Contact(); -- contact.setDescription(name); -- contact.setPhoneNumber(phoneNumber); -- contact.setType(contactType); -- -- if (StringUtils.isEmpty(contactId)) { -- // id not set, generate one (phonebookEntry.getId() doesn't seem to be set on prod right now and it is also not a required field). -- contactId = TrillianTestRestHelper.generateContactId(contact.getDescription(), contact.getPhoneNumber(), messageDigest); -- } -- -- final String contactUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.contacts.contactId$.RESOURCE -- .replace("{planningAreaId}", planningAreaId) -- .replace("{bookId}", phonebookId) -- .replace("{contactId}", contactId); -- RestHelper.put(contact, contactUrl); -- -- if (contactType == ContactType.DRIVER) { -- Driver driver = new Driver(); -- driver.setName(name); -- driver.setPersonalNumber(contactId); -- driver.setPhoneNumber(phoneNumber); -- -- final String driverUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.drivers.personalNumber$.RESOURCE -- .replace("{personalNumber}", driver.getPersonalNumber()); -- RestHelper.put(driver, driverUrl); -- } -- } -- } -- } -- -- @When("^We navigate to the phonebook selection page$") -- public void We_navigate_to_the_phonebook_selection_page() { -- final SlartiNavigation slartiNavigation = new SlartiNavigation(driver, seleniumHelper); -- slartiNavigation.touchTrillianSideMenuByXpathStringSelector("shortcutmenu-Communication", "shortcutmenu-PhonebookSelection"); -- BaseTestTrillian.switchToFrame("module-Trillian"); -- WebElement element = BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(By.id("menu_phonebook_selection"))); -- element.click(); -- } -- -- @Then("^The phonebook \"(.+)\" is visible in planning area (\\d+) and displayed as \"(.+)\"") -- public void The_phonebook_is_visible_in_planning_area_and_displayed_as(String phonebookKeyName, Integer planningAreaId, String expectedDisplayState) { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- boolean testPassed = false; -- for (int retry = 0; retry < PHONE_BOOK_SELECTION_RETRY_COUNTER; retry++) { -- try { -- // Lookup phonebook -- WebElement phonebookButton = getPhonebook(phonebookKeyName, planningAreaId); -- Assert.assertNotNull("Phonebook '" + phonebookKeyName + "' not found in Planningarea " + planningAreaId, phonebookButton); -- // Compare checkbox status -- try { -- phonebookButton.findElement(By.className("selected".equals(expectedDisplayState) ? "icon-check-square-o" : "icon-square-o")); -- testPassed = true; -- } catch (org.openqa.selenium.NoSuchElementException e) { -- LOG.warn("Phonebook " + phonebookKeyName + " should be in state '" + expectedDisplayState + "'"); -- testPassed = false; -- } -- } catch (org.openqa.selenium.NoSuchElementException ignore) { -- LOG.warn("The phonebook " + phonebookKeyName + " could not be found!"); -- testPassed = false; -- } -- if (testPassed) { -- break; -- } -- LOG.info("Retrying..."); -- try { -- BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(By.id("menu_phonebook_summary"))).click(); -- Thread.sleep(PHONE_BOOK_SELECTION_RETRY_SLEEP_TIME); -- BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(By.id("menu_phonebook_selection"))).click(); -- } catch (InterruptedException ignore) { -- } -- } -- Assert.assertTrue("The phonebook " + phonebookKeyName + " could not be found with state: " + expectedDisplayState, testPassed); -- } -- -- @When("^We click the phonebook \"(.+)\"$") -- public void We_click_the_phonebook(String phonebookKeyName) { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- seleniumHelper.touchByXpath("//*[@id='phonebookSelection']/button/span[contains(text(),'" + phonebookKeyName + "')]/.."); -- } -- -- @When("^We navigate to the Trillian phonebook page$") -- public void We_navigate_to_the_Trillian_phonebook_page() { -- OverviewPage overviewPage = navigateToAndGetTrillianOverviewPage(); -- overviewPage.touchGoToPhonebookButton(); -- PhonebookPage phonebookPage = factory.getPhonebookPage(); -- phonebookPage.waitForTitle(); -- } -- -- -- @When("^We set the phone number of \"([^\"]*)\" to \"([^\"]*)\"$") -- public void We_set_the_phone_number_of_to(String vehicleId, String cnum) { -- // Set the number inside the info object so that the -- // ModemApiController can change the contact -- RestHelper.put(new Info().withPhoneNumber(cnum).withTimestamp(DateTime.now()), -- TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + CommunicationModemAPI.info.RESOURCE); -- } -- -- @When("^We delete all phonebooks of all planning areas from Houston$") -- public void weDeleteAllPhonebooksOfAllPlanningAreasFromHouston() { -- List<String> planningAreaIdsControlcenter = getIds(getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.RESOURCE); -- for (String planningAreaId : planningAreaIdsControlcenter) { -- List<String> bookIds = getIds(getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.RESOURCE, planningAreaId); -- for (String phonebooksId : bookIds) { -- delete(getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.RESOURCE, planningAreaId, phonebooksId); -- delete(getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE, planningAreaId, phonebooksId); -- } -- } -- } -- -- @When("^The phonebook with ID \"([^\"]*)\" in planning area id \"([^\"]*)\" is deleted on the houston$") -- public void thePhonebookWithIDIsDeletedOnTheHouston(String id, String planningAreaId) { -- final String url = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.RESOURCE -- .replace("{planningAreaId}", planningAreaId) -- .replace("{bookId}", id); -- RestHelper.del(url); -- waitForHoustonAction(); -- } -- -- @And("^delete all phonebooks from Houston$") -- public void deleteAllPhonebooksFromHouston() { -- final String url = getHoustonBaseUrl() + "/communication/phonebook/"; -- RestHelper.del(url); -- } -- -- @And("^We open the Trillian phonebook page on \"([^\"]*)\"$") -- public void weOpenTheTrillianPhonebookPageOn(String vehicleId) { -- CommonSteps.openSlartiStartPage(vehicleId); -- OverviewPage overviewPage = navigateToAndGetTrillianOverviewPage(); -- overviewPage.touchGoToPhonebookButton(); -- PhonebookPage phonebookPage = factory.getPhonebookPage(); -- phonebookPage.waitForTitle(); -- } -- -- @Then("^We wait for a long time to be able to see manually in what state we are$") -- public void weWaitForALongTimeToBeAbleToSeeManuallyInWhatStateWeAre() throws Throwable { -- Thread.sleep(5 * 60 * 1000); -- } -- -- -- @Then("^No phonebooks are present on \"([^\"]*)\"$") -- public void noPhonebooksArePresentOn(String vehicleId) { -- String baseUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId); -- List<String> planningAreaIdsControlcenter = getIds(baseUrl + PAISAControlcenterPhonebookAPI.planningareas.RESOURCE); -- for (String planningAreaId : planningAreaIdsControlcenter) { -- List<String> booksIdsControlcenter = getIds(baseUrl + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.RESOURCE, planningAreaId); -- for (String bookId : booksIdsControlcenter) { -- await().with().pollInterval(RETRY_SLEEP_TIME, MILLISECONDS).atMost(60, SECONDS) -- .until(() -> getIds(baseUrl + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.contacts.RESOURCE, planningAreaId, bookId).isEmpty()); -- } -- } -- } -- -- @Then("^The following entries are \"(.+)\" on the phone entries page$") -- public void theFollowingEntriesAreDisplayedOnThePhoneEntriesPage(String displayed, DataTable dataTable) { -- boolean expectDisplayed; -- switch (displayed) { -- case "DISPLAYED": -- expectDisplayed = true; -- break; -- case "NOT DISPLAYED": -- expectDisplayed = false; -- break; -- default: -- throw new RuntimeException("Unknown display status"); -- } -- List<String> checkResult = new ArrayList<>(); -- List<ExpectedPhonebookData> entryDataList = getExpectedDataFromTable(dataTable); -- await().with().pollInterval(RETRY_SLEEP_TIME, MILLISECONDS).atMost(30, SECONDS).until(() -> { -- boolean entryPassed = true; -- checkResult.clear(); -- -- List<ch.post.it.paisa.trillian.test.ui.PhonebookEntry> entryOnUiList; -- try { -- entryOnUiList = getPhonebookEntries(); -- } catch (StaleElementReferenceException ignore) { -- return false; -- } -- -- LOG.info("Looking for {} entries and expect them to be displayed {}", entryOnUiList.size(), expectDisplayed); -- -- for (ExpectedPhonebookData entryData : entryDataList) { -- LOG.info("Looking for: {}", entryData.toString()); -- boolean recordFound = false; -- for (ch.post.it.paisa.trillian.test.ui.PhonebookEntry entryOnUi : entryOnUiList) { -- LOG.info("--Found Type: {}, Name: {}, TelephoneNumber: {}, LineNumber: {}, ShiftNumber: {}, TripStopName: {}, Departure: {}, DirectionText: {}, VehicleId: {}, LicencePlate: {}", -- entryOnUi.getType(), -- entryOnUi.getName(), -- entryOnUi.getTelephoneNumber(), -- entryOnUi.getLineNumber(), -- entryOnUi.getShiftNumber(), -- entryOnUi.getTripStopName(), -- entryOnUi.getDeparture(), -- entryOnUi.getDirectionText(), -- entryOnUi.getVehicleId(), -- entryOnUi.getLicencePlate()); --// if (expectedData.entryType.isPresent() && !expectedData.entryType.get().equals(phonebookEntry.getType())) { --// break; --// } -- if (entryData.entryName.isPresent() && !entryData.entryName.get().equals(entryOnUi.getName())) { -- continue; -- } -- if (entryData.entryTelephoneNumber.isPresent() && !entryData.entryTelephoneNumber.get().equals(entryOnUi.getTelephoneNumber())) { -- continue; -- } -- if (entryData.entryLineNumber.isPresent() && !entryData.entryLineNumber.get().equals(entryOnUi.getLineNumber())) { -- continue; -- } -- if (entryData.entryShiftNumber.isPresent() && !entryData.entryShiftNumber.get().equals(entryOnUi.getShiftNumber())) { -- continue; -- } -- if (entryData.entryTripStopName.isPresent() && !entryData.entryTripStopName.get().equals(entryOnUi.getTripStopName())) { -- continue; -- } -- if (entryData.entryDeparture.isPresent() && !new DateTime(entryData.entryDeparture.get()).toString("HH:mm").equals(entryOnUi.getDeparture())) { -- continue; -- } -- if (entryData.entryDirectionText.isPresent() && !entryData.entryDirectionText.get().equals(entryOnUi.getDirectionText())) { -- continue; -- } -- if (entryData.entryVehicleId.isPresent() && !entryData.entryVehicleId.get().equals(entryOnUi.getVehicleId())) { -- continue; -- } -- if (entryData.entryLicencePlate.isPresent() && !entryData.entryLicencePlate.get().equals(entryOnUi.getLicencePlate())) { -- continue; -- } -- recordFound = true; -- break; -- } -- if (expectDisplayed) { -- if (recordFound) { -- LOG.info("Expected entry {} found", entryData); -- } else { -- LOG.error("Expected entry {} NOT found", entryData); -- checkResult.add(entryData.toString()); -- entryPassed = false; -- break; -- } -- } else { -- if (recordFound) { -- LOG.error("Unexpected entry {} found, this is bad", entryData); -- checkResult.add(entryData.toString()); -- entryPassed = false; -- break; -- } else { -- LOG.info("Unexpected entry {} NOT found, this is good", entryData); -- } -- } -- } -- -- LOG.info("entry passed {}", entryPassed); -- return entryPassed; -- }); -- -- if (expectDisplayed) { -- Assert.assertEquals("One or more expected phonebook entries do not match after a couple of retries", 0, checkResult.size()); -- } else { -- Assert.assertEquals("One or more unexpected phonebook entries still match after a couple of retries", 0, checkResult.size()); -- } -- -- } -- -- @When("^A trip initialization in planning area (\\d+) for \"([^\"]*)\" is put$") -- public void aTripInitializationInPlanningAreaIsPut(Integer planningArea, String vehicleId) { -- String TRIP_ID = "TRIP-1"; -- TripInstance tripInstance = new TripInstance() -- .withId(TRIP_ID) -- .withBlockNumber("611") -- .withLineNumber("123456") -- .withTimetableType(TripInstanceTimetableType.PLANNED) -- .withOperatingDay(LocalDate.now()) -- .withPlanningAreaNumber(planningArea); -- -- List<TripStop> tripStops = new ArrayList<>(); -- TripStop tripStop = new TripStop() -- .withStopId("8577860") -- .withStoppingPointId("1") -- .withName("Schwarzenburg, Bahnhof"); -- -- tripStops.add(tripStop); -- tripInstance.withTripStops(tripStops); -- -- TripInitialization tripInitialization = new TripInitialization(); -- tripInitialization.setTimestamp(DateTime.now()); -- tripInitialization.setTripInstanceId(TRIP_ID); -- tripInitialization.setTripInstance(tripInstance); -- String url = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + TimetableRegistrationAPI.trip.initialization.RESOURCE; -- RestHelper.put(tripInitialization, url); -- } -- -- @Given("^\"([^\"]*)\" logs in on \"([^\"]*)\" and selects \"([^\"]*)\" in planning area (\\d+)$") -- public void logsInAndSelectsBookInPlanningArea(String fullName, String vehicleId, @Nullable String phonebookKeyName, @Nullable Integer planningAreaId) { -- login(fullName.split(" ")[0], fullName.split(" ")[1], vehicleId); -- openTheSlartiStartPageOnVehicle(vehicleId, false); -- if (phonebookKeyName != null) { -- We_navigate_to_the_phonebook_selection_page(); -- -- We_click_the_phonebook(phonebookKeyName); -- -- The_phonebook_is_visible_in_planning_area_and_displayed_as(phonebookKeyName, planningAreaId, "selected"); -- } -- } -- -- @Given("^\"([^\"]*)\" logs in on \"([^\"]*)\" and does not select any phonebooks at all$") -- public void logsInOnAndSelectsInPlanningArea(String fullName, String vehicleId) { -- logsInAndSelectsBookInPlanningArea(fullName, vehicleId, null, null); -- } -- -- @Then("^No entries at all are present the phone entries page$") -- public void noEntriesAtAllArePresentThePhoneEntriesPage() { -- WebElement phonebookEntriesElement = seleniumHelper.getWebElementById("phonebookEntries"); -- Assert.assertTrue(phonebookEntriesElement.findElements(By.tagName("li")).isEmpty()); -- } -- -- @Given("^A phonebook with ID \"([^\"]*)\", name \"([^\"]*)\", planning area \"([^\"]*)\", that contains (\\d+) entries has been PUT to Houston$") -- public void aPhonebookWithIDNamePlanningAreaContainsEntriesHasBeenPUTToHouston(String phonebookId, String phonebookKeyName, String planningAreaId, int entries) throws NoSuchAlgorithmException { -- -- -- MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); -- BookInfo bookInfo = new BookInfo(); -- bookInfo.setName(phonebookKeyName); -- bookInfo.setVersion("1"); -- final String bookInfoUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE -- .replace("{planningAreaId}", planningAreaId) -- .replace("{bookId}", phonebookId); -- RestHelper.put(bookInfo, bookInfoUrl); -- -- -- for (int i = 1; i <= entries; i++) { -- Contact contact = new Contact(); -- contact.setType(ContactType.DRIVER); -- contact.setPhoneNumber(String.format("+41 99 %03d %02d %02d", i, (i + 1) % 100, (i + 2) % 100)); -- contact.setDescription(String.format("Vorname%d Nachname%d", i % 10, i / 10)); -- String contactId = TrillianTestRestHelper.generateContactId(contact.getDescription(), contact.getPhoneNumber(), messageDigest); -- -- final String contactUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.contacts.contactId$.RESOURCE -- .replace("{planningAreaId}", planningAreaId) -- .replace("{bookId}", phonebookId) -- .replace("{contactId}", contactId); -- RestHelper.put(contact, contactUrl); -- } -- } -- -- -- @When("^We enter text \"([^\"]*)\" into search field$") -- public void weEntryTextIntoSearchField(String text) { -- PhonebookPage phonebookPage = factory.getPhonebookPage(); -- phonebookPage.enterSearchText(text); -- } -- -- @Then("^(\\d+) entries displayed$") -- public void phoneEntriesDisplayed(int expectedNumberOfEntries) { -- PhonebookPage phonebookPage = factory.getPhonebookPage(); -- given().await().atMost(TWO_SECONDS).until(() -> Assert.assertEquals(expectedNumberOfEntries, phonebookPage.getPhonebookEntriesSize())); -- } -- -- @When("^We click the clear button$") -- public void weClickClearButton() { -- driver.findElement(By.cssSelector("#clearSearchTextButton")).click(); -- } -- -- @And("^We click the search button$") -- public void clickTheSearchButton() { -- driver.findElement(By.cssSelector("#searchButton")).click(); -- } -- -- @And("^unselect all phonebooks in planning area \"([^\"]*)\" on vehicle \"([^\"]*)\"$") -- public void unselectAllPhonebooksInPlanningAreaOnVehicle(String planningAreaId, String vehicleId) { -- String eagleBaseUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId); -- final String urlBooks = eagleBaseUrl + "/data/trillian/books/selection/planningareas/{planningAreaId}/books".replace("{planningAreaId}", planningAreaId); -- -- Response response = RestAssured.when().get(urlBooks); -- if (response.getStatusCode() == 200) { -- List<String> jsonResponse = response.jsonPath().getList("books"); -- for (String bookId : jsonResponse) { -- final String url = eagleBaseUrl + "/data/trillian/books/selection/planningareas/{planningAreaId}/books/{bookId}" -- .replace("{planningAreaId}", planningAreaId) -- .replace("{bookId}", bookId); -- RestHelper.del(url); -- } -- } -- } -- -- @And("^A book with ID \"([^\"]*)\", name \"([^\"]*)\", planning area \"([^\"]*)\", version \"([^\"]*)\", and the following contacts have been PUT to Houston$") -- public void aBookWithIDNamePlanningAreaVersionAndTheFollowingContactsHasBeenPUTToHouston(String bookId, String bookName, String planningAreaId, String version, DataTable dataTable) throws Throwable { -- -- BookInfo bookInfo = new BookInfo(); -- bookInfo.setVersion(version); -- bookInfo.setName(bookName); -- -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String type = row.get(0); -- String description = row.get(1); -- String phoneNumber = row.get(2); -- String contactId = row.get(3); -- Contact contact = new Contact() -- .withDescription(description).withPhoneNumber(phoneNumber); -- contact.setType(ContactType.valueOf(type)); -- final String contactUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.contacts.contactId$.RESOURCE -- .replace("{planningAreaId}", planningAreaId) -- .replace("{bookId}", bookId) -- .replace("{contactId}", contactId); -- RestHelper.put(contact, contactUrl); -- } -- -- final String infoUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE -- .replace("{planningAreaId}", planningAreaId) -- .replace("{bookId}", bookId); -- -- //add info later -- RestHelper.put(bookInfo, infoUrl); -- -- } -- -- @And("^The call notification mocking is initialized$") -- public void theCallControlDialHangupMockingIsInitialized() { -- MockInstances.getEagle1().forPut(PAISAVehicleMessagingAPI.notifications.uuid$.notification.RESOURCE); -- } -- -- @And("^A PUT to \"([^\"]*)\" with type \"([^\"]*)\" and with planning area (\\d+) is observed$") -- public void aPUTToWithTypeAndWithPlanningAreaIsObserved(String url, String type, Integer planningAreaId) { -- // not the most elegant way -- // if we update to a new WireMock version we can use this here https://github.com/tomakehurst/wiremock/blob/master/src/main/java/com/github/tomakehurst/wiremock/matching/RequestMatcherExtension.java -- given().await().atMost(TEN_SECONDS).until(() -> Assert.assertTrue(MockInstances.getEagle1().verifyForPut(url, -- "\"type\":\"" + type + "\"", "\"planningAreaId\":" + planningAreaId))); -- } -- -- @And("^We click dial pad button$") -- public void We_click_dial_pad_button() { -- -- //FIXME: It seems the webElement is moved before clicked. WebDriverException: unknown error: Element is not clickable at point (416, 155). Other element would receive the click: <div class="touch-background" linti-tap="dialog.overlayTouch()"></div> -- try { -- Thread.sleep(1000); -- } catch (InterruptedException e) { -- e.printStackTrace(); -- } -- -- factory.getOverviewPage().touchDialPadButton(); -- } -- -- @And("^We click close dial pad button$") -- public void We_click_close_dial_pad_button() { -- -- //FIXME: It seems the webElement is moved before clicked. WebDriverException: unknown error: Element is not clickable at point (716, 590). Other element would receive the click: <div class="touch-background" linti-tap="dialog.overlayTouch()"></div> -- try { -- Thread.sleep(1000); -- } catch (InterruptedException e) { -- e.printStackTrace(); -- } -- -- factory.getOverviewPage().touchDialPadCloseButton(); -- } -- -- @Given("^The active call is put$") -- public void The_active_call_is_put() { -- CallInfo activeCall = new CallInfo(); -- TrillianTestRestHelper.putActiveCall(activeCall); -- assertTrue(TrillianTestRestHelper.isCallStatusActive()); -- } -- -- @Given("^The active call is deleted$") -- public void The_active_call_is_deleted() { -- TrillianTestRestHelper.deleteActiveCallOnAllVehicles(); -- given().await().atMost(TEN_SECONDS).until(() -> assertFalse(TrillianTestRestHelper.isCallStatusActive())); -- } -- -- @And("^No entry with number \"([^\"]*)\" shows in the call history$") -- public void noEntryWithNumberShowsInTheCallHistory(String phonenumber) { -- List<WebElement> callLogList = driver.findElements(By.xpath("//*[@id='callLogEntry']/li")); -- -- for(WebElement callLog:callLogList) { -- Assert.assertNotEquals(phonenumber, callLog.findElement(By.id("callLogPhoneNumber")).getText()); -- } -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookTripInfoSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookTripInfoSteps.java -deleted file mode 100644 -index ccef038..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookTripInfoSteps.java -+++ /dev/null -@@ -1,106 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.communication.modem.v1.CallState; --import ch.post.it.paisa.api.communication.modem.v1.Direction; --import ch.post.it.paisa.api.communication.modem.v1.State; --import ch.post.it.paisa.api.communication.modem.v1.path.CommunicationModemAPI; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.path.PAISAControlcenterPhonebookAPI; --import ch.post.it.paisa.api.shared.navigation.v1.Coordinate; --import ch.post.it.paisa.api.timetable.common.v1.TripInstance; --import ch.post.it.paisa.api.timetable.common.v1.TripInstanceTimetableType; --import ch.post.it.paisa.api.timetable.common.v1.TripStop; --import ch.post.it.paisa.api.timetable.information.v1.path.TimetableInformationAPI; --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.mock.MockInstances; --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.And; --import io.cucumber.java.en.When; --import org.apache.http.HttpStatus; --import org.joda.time.DateTime; --import org.joda.time.LocalDate; -- --import java.util.ArrayList; --import java.util.List; -- --import static ch.post.it.paisa.trillian.test.RestAssuredSupport.deleteResource; --import static ch.post.it.paisa.trillian.test.TestPaths.getHoustonBaseUrl; -- --public class PhonebookTripInfoSteps extends AbstractSteps { -- -- -- @And("^The timetable information API provides the following trip infos for phonebook entry on houston$") -- public void theTimetableInformationAPIProvidesTheFollowingTripInfosOnHouston(DataTable dataTable) { -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String tripInstanceId = row.get(0); -- String lineNumber = row.get(1); -- String shiftNumber = row.get(2); -- String tripStopName = row.get(3); -- String departure = row.get(4); -- String directionText = row.get(5); -- // Note: basically the planningAreaId is Integer but the timetable API still uses double ... -- int planningAreaId = Integer.parseInt(row.get(6)); -- -- TripInstance tripInstance = new TripInstance(); -- tripInstance.withId(tripInstanceId); -- tripInstance.withBlockNumber("661"); -- tripInstance.withLineNumber(lineNumber); -- tripInstance.withTimetableType(TripInstanceTimetableType.PLANNED); -- tripInstance.withCategory("Bus"); -- tripInstance.withDirectionId("1"); -- tripInstance.withSystemLineNumber("757"); -- tripInstance.withPlanningAreaNumber(planningAreaId); -- tripInstance.withTripNumber("61119"); -- tripInstance.withOperatingDay(LocalDate.now()); -- tripInstance.withCourseNumber("4"); -- tripInstance.withTripType("1"); -- tripInstance.withLineVariant("1"); -- tripInstance.withServiceType("1"); -- -- List<TripStop> tripStops = new ArrayList<>(); -- TripStop tripStop = new TripStop(); -- tripStop.withStopId("8577860"); -- tripStop.withStoppingPointId("1"); -- tripStop.withName(tripStopName); -- tripStop.withCoordinates(new Coordinate().withLongitude(7.342955).withLatitude(46.819003).withElevation(792.0)); -- -- tripStop.withDeparture(new DateTime(departure)); -- tripStop.withAlighting(false); -- tripStop.withDirectionText(directionText); -- tripStop.withDistanceToNextStop(427.0); -- tripStop.withEnterRadius(10.0); -- tripStop.withLeaveRadius(10.0); -- tripStop.withShortName("627SCBG"); -- tripStop.withShiftNumber(shiftNumber); -- tripStops.add(tripStop); -- tripInstance.withTripStops(tripStops); -- -- //Houston -- MockInstances.getHouston().forGet(TimetableInformationAPI.tripinfo.RESOURCE, HttpStatus.SC_OK, tripInstance, "id", tripInstanceId); -- } -- -- } -- -- @And("^We delete all drivers from Houston$") -- public void weDeleteAllDriversFromHouston() { -- delete(getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.drivers.RESOURCE); -- } -- -- @And("^We delete all drivers from \"([^\"]*)\"$") -- public void weDeleteAllDriversFrom(String vehicleId) { -- String baseUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId); -- deleteResource(baseUrl + PAISAControlcenterPhonebookAPI.drivers.RESOURCE); -- } -- -- @When("^An incoming call state from \"([^\"]*)\" is put to \"([^\"]*)\"$") -- public void aIncomingCallStateFromIsPutTo(String phonenumber, String vehicleId) { -- CallState call = new CallState() -- .withDirection(Direction.INCOMING) -- .withPhoneNumber(phonenumber) -- .withState(State.ACTIVE) -- .withTimestamp(new DateTime()); -- RestHelper.put(call, TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + CommunicationModemAPI.call.state.RESOURCE); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookTripInfoUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookTripInfoUiTest.java -deleted file mode 100644 -index 1dde658..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookTripInfoUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions(glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/phonebook-tripinfo.feature", plugin = {"pretty", "html:target/cucumber/phonebook-tripinfo", "json:target/cucumber.phonebook-tripinfo.json"}) --public class PhonebookTripInfoUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookUiTest.java -deleted file mode 100644 -index e523bb9..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PhonebookUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions( glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/phonebook.feature", plugin = { "pretty", "html:target/cucumber/phonebook", "json:target/cucumber.phonebook.json" }) --public class PhonebookUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PlanningareaRelatedPhonebookSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PlanningareaRelatedPhonebookSteps.java -deleted file mode 100644 -index 63548d8..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PlanningareaRelatedPhonebookSteps.java -+++ /dev/null -@@ -1,132 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Then; --import org.junit.Assert; --import org.openqa.selenium.By; --import org.openqa.selenium.StaleElementReferenceException; --import org.openqa.selenium.WebElement; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; -- --import java.util.HashMap; --import java.util.List; --import java.util.Map; -- --public class PlanningareaRelatedPhonebookSteps extends AbstractPhonebookSteps { -- private static final String PLANUNGSBEREICH = "Planungsbereich "; -- private static final String ACTIVE_VEHICLES = "Aktive Fahrzeuge"; -- private static final Logger LOG = LoggerFactory.getLogger(PlanningareaRelatedPhonebookSteps.class); -- -- @Then("^the following phonebooks are present in planning area (\\d+)$") -- public void theFollowingPhonebooksArePresentInPlanningArea(Integer areaId, DataTable dataTable) { -- -- boolean testPassed = false; -- for (int retry = 0; retry < PHONE_BOOK_SELECTION_RETRY_COUNTER; retry++) { -- try { -- Map<String, Boolean> phonebookList = getPhoneBookSelectionList(areaId); -- List<List<String>> rows = dataTable.asLists(String.class); -- int passedItemCount = 0; -- for (int i = 1; i < rows.size(); i++) { -- boolean phoneBookFound; -- -- List<String> row = rows.get(i); -- //String type = row.get(0); -- String name = row.get(1); -- -- Boolean selected = null; -- if (row.size() > 2) { -- selected = row.get(2).equalsIgnoreCase("true"); -- } -- -- // Compare selection and booleanValue -- String phoneBookKey = getPhoneBookName(name, areaId).toLowerCase(); -- phoneBookFound = phonebookList.containsKey(phoneBookKey); -- -- if (phoneBookFound && selected == null) { -- // not need to see if it is selected, we are happy -- passedItemCount++; -- continue; -- } -- -- if (!phoneBookFound || !selected.equals(phonebookList.get(phoneBookKey))) { -- LOG.info("not pass, retry! "); -- navigateToOverviewAndThenToPhonebookSelection(); -- continue; -- } -- passedItemCount++; -- } -- if (passedItemCount == rows.size() - 1) { -- testPassed = true; -- break; -- } -- } catch (StaleElementReferenceException exception) { -- LOG.warn("StaleElementReferenceException, something changed? Retrying ...", exception); -- } -- } -- Assert.assertTrue("Could not find phonebook even after a couple of retries " + -- "(or the selection is not as expected)", testPassed); -- } -- -- @And("^the following phonebooks are NOT present in planning area (\\d+)$") -- public void theFollowingPhonebooksAreNOTPresentInPlanningArea(Integer areaId, DataTable dataTable) { -- boolean testPassed = false; -- for (int retry = 0; retry < PHONE_BOOK_SELECTION_RETRY_COUNTER; retry++) { -- try { -- Map<String, Boolean> phonebookList = getPhoneBookSelectionList(areaId); -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- boolean phoneBookFound = false; -- List<String> row = rows.get(i); -- // String type = row.get(0); -- String name = row.get(1); -- if (phonebookList.containsKey(getPhoneBookName(name, areaId).toLowerCase())) { -- phoneBookFound = true; -- } -- if (phoneBookFound) { -- navigateToOverviewAndThenToPhonebookSelection(); -- } -- Assert.assertFalse("The phonebook is displayed in list '" + name + "'", phoneBookFound); -- } -- testPassed = true; -- break; -- } catch (StaleElementReferenceException exception) { -- LOG.warn("StaleElementReferenceException, something changed? ", exception); -- } -- -- } -- Assert.assertTrue("Phonebook still exist even after a couple of retries", testPassed); -- } -- -- -- /** -- * Returns the list of phonebooks that are currently available in a planning area, also includes VEHICLE books -- */ -- private Map<String, Boolean> getPhoneBookSelectionList(Integer planningAreaId) { -- HashMap<String, HashMap<String, Boolean>> groupedSelection = new HashMap<>(); -- String headerText = ""; -- for (WebElement planningAreaWebElement : getPhoneBookSelectionDiv().findElements(By.xpath(".//h1 | .//button"))) { -- if ("h1".equals(planningAreaWebElement.getTagName())) { -- //a planning area text found, start a new group -- headerText = planningAreaWebElement.getText(); -- groupedSelection.put(headerText, new HashMap<>()); -- } else if ("button".equals(planningAreaWebElement.getTagName())) { -- //is a button -- String nameText = planningAreaWebElement.findElement(By.className("checkboxText")).getText(); -- boolean selected = planningAreaWebElement.getAttribute("class").contains("active"); -- groupedSelection.get(headerText).put(nameText.toLowerCase(), selected); -- } -- } -- -- HashMap<String, Boolean> result = new HashMap<>(); -- if (groupedSelection.containsKey(PLANUNGSBEREICH + planningAreaId)) { -- result.putAll(groupedSelection.get(PLANUNGSBEREICH + planningAreaId)); -- } -- if (groupedSelection.containsKey(ACTIVE_VEHICLES)) { -- result.putAll(groupedSelection.get(ACTIVE_VEHICLES)); -- } -- return result; -- } -- --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PlanningareaRelatedPhonebookUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PlanningareaRelatedPhonebookUiTest.java -deleted file mode 100644 -index e6b9f17..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/PlanningareaRelatedPhonebookUiTest.java -+++ /dev/null -@@ -1,10 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --@RunWith(Cucumber.class) --@CucumberOptions( glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/phonebookPlanningarea.feature", plugin = { "pretty", "html:target/cucumber/phonebookPlanningarea", "json:target/cucumber.phonebookPlanningarea.json" }) --public class PlanningareaRelatedPhonebookUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TestHelper.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TestHelper.java -deleted file mode 100644 -index 058a011..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TestHelper.java -+++ /dev/null -@@ -1,315 +0,0 @@ -- --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.controlcenter.inquiry.v1.Contact; --import ch.post.it.paisa.api.user.credentials.v1.CardType; --import ch.post.it.paisa.api.user.credentials.v1.PersonalCard; --import ch.post.it.paisa.api.user.credentials.v1.path.UserCredentialsAPI; --import ch.post.it.paisa.api.user.identification.v1.ReaderDetectCard; --import ch.post.it.paisa.api.user.identification.v1.path.UserIdentificationAPI; --import ch.post.it.paisa.api.user.information.v1.*; --import ch.post.it.paisa.api.user.information.v1.path.UserInformationAPI; --import ch.post.it.paisa.api.vehicle.profile.v1.Identification; --import ch.post.it.paisa.api.vehicle.v1.VehicleIdentity; --import ch.post.it.paisa.api.vehicle.v1.path.VehicleAPI; --import org.joda.time.DateTime; -- --import java.util.*; -- --import static ch.post.it.paisa.trillian.test.TestPaths.*; -- --public class TestHelper { -- -- private static final List<Map<String, Object>> USERS = new LinkedList<>(); -- -- static { -- -- final String pin = "11111"; -- final String pinHash = "d17f25ecfbcc7857f7bebea469308be0b2580943e96d13a3ad98a13675c4bfc2"; -- final String unit = "IT122"; -- final UserType userType = UserType.TECH; -- final List<String> roles = Arrays.asList("user", "driver", "technician"); -- -- // Firstname1 Lastname1 -- { -- UserCredential userCredential = new UserCredential(); -- userCredential.setPinHash(pinHash); -- userCredential.setType(CredentialType.STANDARD); -- -- UserIdentity userIdentity = new UserIdentity(); -- userIdentity.setGivenName("Firstname1"); -- userIdentity.setSurname("Lastname1"); -- userIdentity.setRoles(roles); -- userIdentity.setUserType(userType); -- userIdentity.setUnit(unit); -- -- Map<String, Object> user = new HashMap<>(); -- String personalNumber = "11111111"; -- String legicId = personalNumber; -- user.put("pin", pin); -- user.put("personalNumber", personalNumber); -- user.put("legicId", legicId); -- user.put("userCredential", userCredential); -- user.put("userIdentity", userIdentity); -- USERS.add(user); -- } -- -- // Firstname2 Lastname2 -- { -- UserCredential userCredential = new UserCredential(); -- userCredential.setPinHash(pinHash); -- userCredential.setType(CredentialType.STANDARD); -- -- UserIdentity userIdentity = new UserIdentity(); -- userIdentity.setGivenName("Firstname2"); -- userIdentity.setSurname("Lastname2"); -- userIdentity.setRoles(roles); -- userIdentity.setUserType(userType); -- userIdentity.setUnit(unit); -- -- Map<String, Object> user = new HashMap<>(); -- String personalNumber = "11111112"; -- String legicId = personalNumber; -- user.put("pin", pin); -- user.put("personalNumber", personalNumber); -- user.put("legicId", legicId); -- user.put("userCredential", userCredential); -- user.put("userIdentity", userIdentity); -- USERS.add(user); -- } -- -- // Firstname3 Lastname3 -- { -- UserCredential userCredential = new UserCredential(); -- userCredential.setPinHash(pinHash); -- userCredential.setType(CredentialType.STANDARD); -- -- UserIdentity userIdentity = new UserIdentity(); -- userIdentity.setGivenName("Firstname3"); -- userIdentity.setSurname("Lastname3"); -- userIdentity.setRoles(roles); -- userIdentity.setUserType(userType); -- userIdentity.setUnit(unit); -- -- Map<String, Object> user = new HashMap<>(); -- String personalNumber = "11111113"; -- String legicId = personalNumber; -- user.put("pin", pin); -- user.put("personalNumber", personalNumber); -- user.put("legicId", legicId); -- user.put("userCredential", userCredential); -- user.put("userIdentity", userIdentity); -- USERS.add(user); -- } -- } -- -- // ISABUFC-1310 -- public static String getEagleBaseUrlFromVehicleId(String vehicleId) { -- String eagleBaseUrl; -- switch (vehicleId) { -- case "vehicle_1": -- eagleBaseUrl = getEagle1BaseUrl(); -- break; -- case "vehicle_2": -- eagleBaseUrl = getEagle2BaseUrl(); -- break; -- case "vehicle_3": -- eagleBaseUrl = getEagle3BaseUrl(); -- break; -- default: -- eagleBaseUrl = getEagle1BaseUrl(); -- } -- -- return eagleBaseUrl; -- } -- -- public static String getUserCardIdByFullName(String givenName, String surname) { -- for (Map<String, Object> user : USERS) { -- UserIdentity userIdentity = (UserIdentity) user.get("userIdentity"); -- if (userIdentity.getGivenName().equals(givenName) && userIdentity.getSurname().equals(surname)) { -- return (String) user.get("legicId"); -- } -- } -- throw new IllegalArgumentException("Could not find user " + givenName + " " + surname); -- } -- -- public static String getUserPinByFullName(String givenName, String surname) { -- for (Map<String, Object> user : USERS) { -- UserIdentity userIdentity = (UserIdentity) user.get("userIdentity"); -- if (userIdentity.getGivenName().equals(givenName) && userIdentity.getSurname().equals(surname)) { -- return (String) user.get("pin"); -- } -- } -- throw new IllegalArgumentException("Could not find user " + givenName + " " + surname); -- } -- -- private static void putUserInformation() { -- putCredentials(); -- putIdentities(); -- putPersonalCards(); -- putLanguages(); -- } -- -- // ISABUFC-1310: Set vehicleIds in setup of integration tests on trillian -- private static void putVehicleIds() { -- putVehicleId("1", "vehicle_1"); -- putVehicleId("2", "vehicle_2"); -- putVehicleId("3", "vehicle_3"); -- } -- -- // ISABUFC-1310: Add vehicle identification to vehicles in setup of integration tests on trillian -- private static void putVehicleIdentifications() { -- putVehicleIdentification("dummy", "vehicle_1", "dummy", -- "BE 001", "dummy", "dummy", 0); -- putVehicleIdentification("dummy", "vehicle_2", "dummy", -- "BE 002", "dummy", "dummy", 0); -- putVehicleIdentification("dummy", "vehicle_3", "dummy", -- "BE 003", "dummy", "dummy", 0); -- } -- -- -- private static void putVehicleContacts() { -- Contact contact = new Contact(); -- contact.setPhoneNumber("+41 999 88 77 66"); -- -- putVehicleContact(contact, "vehicle_1"); -- putVehicleContact(contact, "vehicle_2"); -- putVehicleContact(contact, "vehicle_3"); -- } -- -- public static void putVehicleContact(Contact contact, String vehicleId) { -- // TODO: basically we should put it on the eagle the same wat Trillian does, then we also test if the sync to houston works. -- String url = getHoustonBaseUrl() -- + VEHICLE_CONTACT_PATH -- .replace("{vehicleId}", vehicleId); -- RestHelper.put(contact, url); -- } -- -- // ISABUFC-1310: Set vehicleIds in setup of integration tests on trillian -- public static void putVehicleId(String eagleInstanceNumber, String vehicleId) { -- -- VehicleIdentity vehicleIdentity = new VehicleIdentity(); -- vehicleIdentity.setVehicleId(vehicleId); -- -- String eagleBaseUrl; -- switch (eagleInstanceNumber) { -- case "1": -- eagleBaseUrl = getEagle1BaseUrl(); -- break; -- case "2": -- eagleBaseUrl = getEagle2BaseUrl(); -- break; -- case "3": -- eagleBaseUrl = getEagle3BaseUrl(); -- break; -- default: -- throw new IllegalArgumentException("Unknown Eagle instance number " + eagleInstanceNumber); -- } -- -- String url = eagleBaseUrl + VehicleAPI.identity.RESOURCE; -- RestHelper.put(vehicleIdentity, url); -- } -- -- // ISABUFC-1310: Add vehicle identification to vehicles in setup of integration tests on trillian -- public static void putVehicleIdentification(String description, -- String extVehicleId, -- String category, -- String licencePlate, -- String brand, -- String model, -- int design) { -- -- Identification identification = new Identification(); -- identification.setDescription(description); -- identification.setExtVehicleId(extVehicleId); -- identification.setCategory(category); -- identification.setLicencePlate(licencePlate); -- identification.setBrand(brand); -- identification.setModel(model); -- identification.setDesign(design); -- -- String url = getHoustonBaseUrl() -- + VEHICLE_PROFILE_IDENTIFICATION_PATH -- .replace("{vehicleId}", extVehicleId); -- RestHelper.put(identification, url); -- } -- -- // ISABUFC-1309 -- private static void putCredentials() { -- -- final String CREDENTIALS_PATH = "/users/{personalNumber}" + UserInformationAPI.credentials.RESOURCE; -- -- // ISABUFC-1310 -- for (Map<String, Object> user : USERS) { -- String personalNumber = (String) user.get("personalNumber"); -- UserCredential userCredential = (UserCredential) user.get("userCredential"); -- -- final String credentialsUrl = getHoustonBaseUrl() + CREDENTIALS_PATH -- .replace("{personalNumber}", personalNumber); -- RestHelper.put(userCredential, credentialsUrl); -- } -- } -- -- private static void putIdentities() { -- final String IDENTITY_PATH = "/users/{personalNumber}" + UserInformationAPI.identity.RESOURCE; -- for (Map<String, Object> user : USERS) { -- String personalNumber = (String) user.get("personalNumber"); -- UserIdentity userIdentity = (UserIdentity) user.get("userIdentity"); -- -- final String identityUrl = getHoustonBaseUrl() + IDENTITY_PATH -- .replace("{personalNumber}", personalNumber); -- RestHelper.put(userIdentity, identityUrl); -- } -- } -- -- // ISABUFC-1310 -- private static void putPersonalCards() { -- for (Map<String, Object> user : USERS) { -- String personalNumber = (String) user.get("personalNumber"); -- String legicId = (String) user.get("legicId"); -- -- PersonalCard personalCard = new PersonalCard(); -- personalCard.setPersonalNumber(personalNumber); -- personalCard.setCardType(CardType.TECH); -- -- final String personalCardUrl = getHoustonBaseUrl() -- + UserCredentialsAPI.personal.cards.legicId$.card.RESOURCE -- .replace("{legicId}", legicId); -- RestHelper.put(personalCard, personalCardUrl); -- } -- } -- -- private static void putLanguages() { -- final String LANGUAGE_PATH = "/users/{personalNumber}" + UserInformationAPI.language.RESOURCE; -- for (Map<String, Object> user : USERS) { -- String personalNumber = (String) user.get("personalNumber"); -- UserLanguage userLanguage = new UserLanguage().withLanguageCode(UILang.DE); -- -- final String languageUrl = getHoustonBaseUrl() + LANGUAGE_PATH -- .replace("{personalNumber}", personalNumber); -- RestHelper.put(userLanguage, languageUrl); -- } -- } -- -- static void setupE2ETests() { -- putVehicleContacts(); -- putUserInformation(); -- putVehicleIds(); -- putVehicleIdentifications(); -- } -- -- public static void setupLegacyTests() { -- putVehicleContact(new Contact().withPhoneNumber("+41 999 88 77 66"), "vehicle_1"); -- putUserInformation(); -- putVehicleId("1", "vehicle_1"); -- putVehicleIdentification("dummy", "vehicle_1", "dummy", -- "BE 001", "dummy", "dummy", 0); -- } -- -- public static void badgeWithLegicId(String legicId, String vehicleId) { -- String url = getEagleBaseUrlFromVehicleId(vehicleId) + UserIdentificationAPI.card.RESOURCE; -- ReaderDetectCard card = new ReaderDetectCard().withLegicId(legicId).withTimestamp(new DateTime()); -- RestHelper.put(card, url); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TextMessageSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TextMessageSteps.java -deleted file mode 100644 -index 9f7cf2e..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TextMessageSteps.java -+++ /dev/null -@@ -1,264 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.communication.messaging.v1.TextMessage; --import ch.post.it.paisa.api.communication.messaging.v1.TextMessageAcknowledgeLegacy; --import ch.post.it.paisa.api.communication.messaging.v1.path.CommunicationMessagingAPI; --import ch.post.it.paisa.api.vehicle.messaging.v1.path.PAISAVehicleMessagingAPI; --import ch.post.it.paisa.slarti.test.ui.elements.NotificationCenter; --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNotification; --import ch.post.it.paisa.trillian.test.ui.pages.MessagingPage; --import com.fasterxml.jackson.databind.ObjectMapper; --import com.fasterxml.jackson.datatype.joda.JodaModule; --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Given; --import io.cucumber.java.en.Then; --import io.cucumber.java.en.When; --import org.joda.time.DateTime; --import org.junit.Assert; --import org.openqa.selenium.By; --import org.openqa.selenium.TimeoutException; --import org.openqa.selenium.WebElement; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; -- --import java.io.IOException; --import java.util.List; --import java.util.Map; -- --import static ch.post.it.paisa.trillian.test.TestPaths.getHoustonBaseUrl; -- -- --// ISABUFC-1310 --public class TextMessageSteps extends AbstractSteps { -- -- private final static Logger LOG = LoggerFactory.getLogger(TextMessageSteps.class); -- -- private static final String KEYBOARD_XPATH = "//keyboard"; -- -- @And("^All control center messages on \"([^\"]*)\" are deleted$") -- public void All_control_center_message_on_vehicle_are_deleted(String vehicleId) { -- String eagleBaseUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId); -- String textMessageUrl = eagleBaseUrl + CommunicationMessagingAPI.text.message.RESOURCE; -- RestHelper.del(textMessageUrl); -- } -- -- @And("^All vehicle messages on \"([^\"]*)\" are deleted$") -- public void All_vehicle_messages_on_vehicle_are_delete(String vehicleId) { -- String eagleBaseUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId); -- String textMessagesUrl = eagleBaseUrl + PAISAVehicleMessagingAPI.text.messages.RESOURCE; -- RestHelper.del(textMessagesUrl); -- } -- -- @When("^We PUT a text message resource via Houston to \"(.+)\" with the following parameters$") -- public void We_PUT_a_text_message_resource_via_Houston_to_vehicle_with_the_following_parameters(String vehicleId, DataTable dataTable) { -- putControlCenterMessageToVehicle(vehicleId, dataTable); -- -- } -- -- @Then("^A text message is displayed with text \"(.+)\", time \"(.+)\"$") -- public void A_text_message_is_displayed_with_text_time(String text, String date) { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- MessagingPage messagingPage = factory.getMessagingPage(); -- seleniumHelper.waitUntil(webDriver -> messagingPage.isMessagePresent(date, text)); -- } -- -- @Then("^An acknowledgment resource is present on Houston from \"(.+)\" with the following parameters$") -- public void An_acknowledgment_resource_is_present_on_Houston_from_vehicle_with_the_following_parameters(String vehicleId, DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- String expectedTextMessageUuid = data.get("textMessageUuid"); -- String expectedType = data.get("type"); -- -- final String url = getHoustonBaseUrl() + "/from/vehicles/" + vehicleId + CommunicationMessagingAPI.text.acknowledge.messageUuid$.RESOURCE -- .replace("{messageUuid}", expectedTextMessageUuid); -- -- // THIS MAY FAIL -- final ObjectMapper mapper = new ObjectMapper(); -- mapper.registerModule(new JodaModule()); -- -- try { -- // wait to make sure that the resource has been updated -- seleniumHelper.waitUntil(webDriver -> { -- String textMessageAcknowledgeString = RestHelper.get(url); -- -- try { -- TextMessageAcknowledgeLegacy textMessageAcknowledge = mapper.readValue(textMessageAcknowledgeString, TextMessageAcknowledgeLegacy.class); -- return expectedTextMessageUuid.equals(textMessageAcknowledge.getTextMessageUuid()) && expectedType.equals(textMessageAcknowledge.getType().toString()); -- } catch (final IOException exception) { -- LOG.debug("Cannot parse TextMessageAcknowledge from string: \"" + textMessageAcknowledgeString + "\""); -- return false; -- } -- }); -- } catch (TimeoutException e) { -- // get the text message acknowledge again to print out to the log -- String textMessageAcknowledgeString = RestHelper.get(url); -- try { -- TextMessageAcknowledgeLegacy textMessageAcknowledge = mapper.readValue(textMessageAcknowledgeString, TextMessageAcknowledgeLegacy.class); -- Assert.assertEquals("The text message's UUID is \"" + textMessageAcknowledge.getTextMessageUuid() + "\", which is not \"" + expectedTextMessageUuid + "\"", expectedTextMessageUuid, textMessageAcknowledge.getTextMessageUuid()); -- Assert.assertEquals("The text message's type is \"" + textMessageAcknowledge.getType() + "\", which is not \"" + expectedType + "\"", expectedType, textMessageAcknowledge.getType().toString()); -- } catch (final IOException exception) { -- String errMsg = "Cannot parse TextMessageAcknowledge from string: \"" + textMessageAcknowledgeString + "\""; -- LOG.debug(errMsg); -- Assert.fail(errMsg); -- } -- } -- } -- -- @And("^A text message has been sent to \"([^\"]*)\" and is displayed on the Trillian message page$") -- public void aTextMessageHasBeenSentToAndIsDisplayedOnTheTrillianMessagePage(String vehicleId, DataTable dataTable) { -- We_PUT_a_text_message_resource_via_Houston_to_vehicle_with_the_following_parameters(vehicleId, dataTable); -- -- Map<String, String> textMessageAsMap = dataTable.asMap(String.class, String.class); -- new CommonSteps().aNotificationWithMessageAndAcceptButtonOnVehicleIsDisplayed(textMessageAsMap.get("uuid"), textMessageAsMap.get("text"), "Anzeigen", vehicleId); -- } -- -- @Then("^No notification message is displayed$") -- public void noNotificationMessageIsDisplayed() { -- SlartiNotification notification = factory.getNotification(); -- if (notification.isNotificationContainerVisible()) { -- notification.waitNotificationWithTimeout(); -- } -- } -- -- @When("^We click on the message text box$") -- public void We_click_on_the_message_text_box() { -- BaseTestTrillian.waitAndClickById("message"); -- } -- -- @Then("^The keyboard is shown$") -- public void The_keyboard_is_shown() { -- seleniumHelper.switchToRoot(); -- Assert.assertTrue("The keyboard is not shown.", seleniumHelper.waitUntilTheWebElementDisplayedByXpath(KEYBOARD_XPATH)); -- } -- -- @When("^We enter \"(.+)\" on the message text box$") -- public void We_enter_text_on_the_message_text_box(String text) { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- BaseTestTrillian.waitAndSendKeysById("message", text); -- } -- -- @And("^We click on the send message button$") -- public void We_click_on_the_send_message_button() { -- seleniumHelper.getWebElementById("send-message-button").click(); -- Assert.assertFalse("The keyboard is not hidden.", seleniumHelper.waitUntilTheWebElementDisplayedByXpath(KEYBOARD_XPATH)); -- } -- -- @Then("^The last sent message on the conversation panel is \"(.+)\"$") -- public void The_last_sent_message_on_the_conversation_panel_is(String expectedText) { -- List<WebElement> vehicleMessageElements = seleniumHelper.getWebElements(createLastMessageXPath("sent")); -- Assert.assertEquals("There is not any sent message on the conversation panel.", 1, vehicleMessageElements.size()); -- -- String text = vehicleMessageElements.get(0).findElement(By.xpath("span[contains(@class,'text')]")).getText(); -- Assert.assertEquals("The last sent message is wrong.", expectedText, text); -- } -- -- @Then("^The last received message on the conversation panel is \"(.+)\"$") -- public void The_last_received_message_on_the_conversation_panel_is(String expectedText) { -- -- // wait for the messages sorting to be finished -- try { -- Thread.sleep(500); -- } catch (InterruptedException ignore) { -- } -- -- List<WebElement> receivedMessageElements = seleniumHelper.getWebElements(createLastMessageXPath("received")); -- Assert.assertEquals("There is not any received message on the conversation panel.", 1, receivedMessageElements.size()); -- -- String text = MessagingPage.getTextFromMessageElement(receivedMessageElements.get(0)); -- Assert.assertEquals("The last received message is wrong", expectedText, text); -- } -- -- @Then("^The conversation panel shows the following messages$") -- public void The_conversation_panel_shows_the_following_messages(DataTable dataTable) { -- List<List<String>> rows = dataTable.asLists(String.class); -- -- // wait for the messages sorting to be finished -- try { -- Thread.sleep(500); -- } catch (InterruptedException ignore) { -- } -- -- List<WebElement> messageElements = seleniumHelper.getWebElements("//div[@class='conversation-container']/div[contains(@class,'message')]"); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String expectedText = row.get(0); -- String expectedDirection = row.get(1); -- -- WebElement messageElement = messageElements.get(i - 1); -- String text = MessagingPage.getTextFromMessageElement(messageElement); -- Assert.assertEquals("The text at message " + i + " is wrong.", expectedText, text); -- Assert.assertTrue("The direction of message '" + text + "' is wrong, expect '" + expectedDirection + "'", messageElement.getAttribute("class").contains(expectedDirection)); -- } -- } -- -- @Then("^The conversation panel shows no messages$") -- public void The_conversation_panel_shows_no_messages() { -- List<WebElement> sentMessageElements = seleniumHelper.getWebElements(createMessagesXPath("sent")); -- List<WebElement> receivedMessageElements = seleniumHelper.getWebElements(createMessagesXPath("received")); -- Assert.assertEquals("The conversation panel still contains messages.", 0, sentMessageElements.size() + receivedMessageElements.size()); -- } -- -- @Given("^The following control center message is put to vehicle \"(.+)\"$") -- public void The_following_control_center_message_is_put_to_vehicle(String vehicleId, DataTable dataTable) { -- putControlCenterMessageToVehicle(vehicleId, dataTable); -- } -- -- @Given("^The following vehicle message is put from vehicle \"(.+)\"$") -- public void The_following_vehicle_message_is_put(String vehicleId, DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- -- String uuid = data.get("uuid"); -- String timestampParam = data.get("timestamp"); -- DateTime timestamp = timestampParam != null ? DateTime.parse(timestampParam) : DateTime.now(); -- -- ch.post.it.paisa.api.vehicle.messaging.v1.TextMessage textMessage = new ch.post.it.paisa.api.vehicle.messaging.v1.TextMessage(); -- textMessage.setUuid(uuid); -- textMessage.setTimestamp(timestamp); -- textMessage.setText(data.get("text")); -- -- final String baseUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId); -- final String textMessageUrl = baseUrl + PAISAVehicleMessagingAPI.text.messages.uuid$.message.RESOURCE.replace("{uuid}", uuid); -- RestHelper.put(textMessage, textMessageUrl); -- } -- -- @And("^There are no notifications in the notification center$") -- public void There_are_no_notifications_in_the_notification_center() throws Exception { -- NotificationCenter notificationCenter = factory.notificationCenter(); -- notificationCenter.open(); -- WebElement notificationCenterWebElement = driver.findElement(By.xpath(NotificationCenter.XPATH_NOTIFICATION_CENTER)); -- seleniumHelper.waitUntil(webDriver -> notificationCenterWebElement.getSize().height == 828); // max height -- Assert.assertEquals("There are still notifications in the notification center", 0, notificationCenter.getNotificationElementsVisibleCount()); -- notificationCenter.touchCloseButton(); -- seleniumHelper.waitUntil(webDriver -> notificationCenterWebElement.getSize().height == 70); // min height -- } -- -- private void putControlCenterMessageToVehicle(String vehicleId, DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- -- String timestampParam = data.get("timestamp"); -- DateTime timestamp = timestampParam != null ? DateTime.parse(timestampParam) : DateTime.now(); -- -- TextMessage textMessage = new TextMessage(); -- textMessage.setUuid(data.get("uuid")); -- textMessage.setTimestamp(timestamp); -- textMessage.setAcknowledge(Boolean.valueOf(data.get("acknowledge"))); -- textMessage.setSenderVehicleId(data.get("senderVehicleId")); -- textMessage.setRecipientVehicleId(data.get("recipientVehicleId")); -- textMessage.setText(data.get("text")); -- final String url = getHoustonBaseUrl() + "/to/vehicles/" + vehicleId + CommunicationMessagingAPI.text.message.messageUuid$.RESOURCE -- .replace("{messageUuid}", textMessage.getUuid()); -- -- RestHelper.put(textMessage, url); -- } -- -- private String createMessagesXPath(String direction) { -- return "//div[@class='conversation-container']/div[contains(@class,'message') and contains(@class,'" + direction + "')]"; -- } -- -- private String createLastMessageXPath(String direction) { -- return createMessagesXPath(direction) + "[last()]"; -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TextMessageUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TextMessageUiTest.java -deleted file mode 100644 -index e728afd..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TextMessageUiTest.java -+++ /dev/null -@@ -1,11 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --// ISABUFC-1310 --@RunWith(Cucumber.class) --@CucumberOptions( glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/textMessage.feature", plugin = { "pretty", "html:target/cucumber/textMessage", "json:target/cucumber.textMessage.json" }) --public class TextMessageUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TimetableNotificationSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TimetableNotificationSteps.java -deleted file mode 100644 -index e1835d6..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TimetableNotificationSteps.java -+++ /dev/null -@@ -1,352 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.notifications.v1.NotificationsAPIPaths; --import ch.post.it.paisa.api.shared.navigation.v1.Coordinate; --import ch.post.it.paisa.api.timetable.common.v1.TripInstance; --import ch.post.it.paisa.api.timetable.common.v1.TripInstanceTimetableType; --import ch.post.it.paisa.api.timetable.common.v1.TripStop; --import ch.post.it.paisa.api.timetable.notification.v1.Notification; --import ch.post.it.paisa.api.timetable.notification.v1.NotificationType; --import ch.post.it.paisa.api.timetable.notification.v1.Period; --import ch.post.it.paisa.api.timetable.notification.v1.RelationType; --import ch.post.it.paisa.api.timetable.notification.v1.path.TimetableNotificationAPI; --import ch.post.it.paisa.api.timetable.registration.v1.path.TimetableRegistrationAPI; --import ch.post.it.paisa.api.vehicle.status.v3.PlanningArea; --import ch.post.it.paisa.api.vehicle.status.v3.path.VehicleStatusAPI; --import ch.post.it.paisa.slarti.test.ui.elements.NotificationCenter; --import ch.post.it.paisa.trillian.test.TestPaths; --import ch.post.it.paisa.trillian.test.TrillianTestRestHelper; --import ch.post.it.paisa.trillian.test.ui.AbstractSteps; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNotification; --import ch.post.it.paisa.trillian.test.ui.pages.MessagingPage; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import io.cucumber.datatable.DataTable; --import io.cucumber.java.en.And; --import io.cucumber.java.en.Given; --import io.cucumber.java.en.Then; --import io.cucumber.java.en.When; --import io.restassured.RestAssured; --import io.restassured.path.json.JsonPath; --import io.restassured.response.Response; --import org.apache.http.HttpStatus; --import org.joda.time.DateTime; --import org.joda.time.DateTimeZone; --import org.joda.time.LocalDate; --import org.junit.Assert; -- --import java.util.ArrayList; --import java.util.Arrays; --import java.util.List; --import java.util.Map; -- --import static ch.post.it.paisa.trillian.test.RestAssuredSupport.putResource; --import static ch.post.it.paisa.trillian.test.TestPaths.getHoustonBaseUrl; --import static ch.post.it.paisa.trillian.test.ui.TextFixtures.tripInitialization; -- -- --// ISABUFC-1310 --public class TimetableNotificationSteps extends AbstractSteps { -- -- private final DateTimeZone TIME_ZONE = DateTimeZone.forID("UTC"); -- -- @When("We PUT to Houston a timetable notification resource with ID {string}, planning area {string}, and the following parameters:") -- public void wePUTToHoustonATimetableNotificationResourceWithIDPlanningAreaAndTheFollowingParameters(String notificationId, String planningAreaId, DataTable dataTable) { -- putTimetableNotification(notificationId, planningAreaId, dataTable); -- } -- -- @When("^We PUT to Houston a timetable notification resource with ID \"([^\"]*)\", planning area \"([^\"]*)\" with the parameters below and also login right after:$") -- public void wePUTToHoustonATimetableNotificationResourceWithIDPlanningAreaWithTheParametersBelowAndAlsoLoginRightAfter(String notificationId, String planningAreaId, DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- String vehicleId = data.get("vehicleId"); -- String givenName = data.get("givenName"); -- String surname = data.get("surname"); -- -- putTimetableNotification(notificationId, planningAreaId, dataTable); -- -- login(givenName, surname, vehicleId); -- -- // houston took action verification -- String houstonNotificationUrl = getHoustonBaseUrl() + "/to/vehicles/" + vehicleId + TimetableNotificationAPI.planningareas.COLLECTION + planningAreaId + "/notifications/" + notificationId; -- verifyExpectedNotification(houstonNotificationUrl, data); -- -- // eagle sync verification -- String eagleNotificationUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + TimetableNotificationAPI.planningareas.COLLECTION + planningAreaId + "/notifications/" + notificationId; -- verifyExpectedNotification(eagleNotificationUrl, data); -- } -- -- @Then("^A timetable notification is displayed with the following parameters:$") -- public void A_timetable_notification_is_displayed_with_the_following_parameters(DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- String expectedTitle = data.get("title"); -- String expectedMessage = data.get("message"); -- String expectedDate = data.get("date"); -- String expectedIcon = data.get("icon"); -- -- MessagingPage messagingPage = factory.getMessagingPage(); -- messagingPage.assertNotification(expectedTitle, expectedMessage, expectedDate, expectedIcon); -- } -- -- @Then("^NO timetable notification is displayed$") -- public void NO_timetable_notification_is_displayed() { -- MessagingPage messagingPage = factory.getMessagingPage(); -- messagingPage.assertThatThereAreNoNotifications(); -- } -- -- @And("^There is no notification \"([^\"]*)\" in the notification center on vehicle \"([^\"]*)\"$") -- public void thereIsNoNotificationInTheNotificationCenterOnVehicle(String notificationId, String vehicleId) { -- ensureNotFound(TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + "/" + NotificationsAPIPaths.Channels.ChannelName.NotificationId.PATH, "messages", notificationId); -- -- seleniumHelper.switchToRoot(); -- final NotificationCenter notificationCenter = factory.notificationCenter(); -- Assert.assertFalse(notificationCenter.isNotificationVisible(notificationId)); -- } -- -- @When("^We DELETE from Houston the timetable notification resource with ID \"(.*)\" and planning area \"(.*)\"$") -- public void We_DELETE_from_Houston_the_timetable_notification_resource_with_ID_and_planning_area(String notificationId, String planningAreaId) { -- -- String url = getHoustonBaseUrl() + TimetableNotificationAPI.planningareas.planningAreaId$.notifications.notificationId$.RESOURCE -- .replace("{planningAreaId}", planningAreaId) -- .replace("{notificationId}", notificationId); -- -- RestHelper.del(url); -- } -- -- @And("^We navigate to the Trillian notification messages page$") -- public void weNavigateToTheTrillianNotificationMessagesPage() { -- OverviewPage overviewPage = navigateToAndGetTrillianOverviewPage(); -- overviewPage.touchGoToMessagesButton(); -- MessagingPage messagingPage = factory.getMessagingPage(); -- messagingPage.waitForTitle(); -- messagingPage.goToAllNotifications(); -- } -- -- @Then("The notification tab is displayed on the Trillian messaging page") -- public void theNotificationTabIsDisplayedOnTheTrillianMessagingPage() { -- MessagingPage messagingPage = factory.getMessagingPage(); -- messagingPage.waitForTitle(); -- messagingPage.goToAllNotifications(); -- } -- -- -- @Given("^The current planning area is set to (\\d+) on the following vehicles$") -- public void theCurrentPlanningAreaIsSetToOnTheFollowingVehicles(Integer planningAreaId, List<String> vehicles) { -- PlanningArea planningArea = new PlanningArea(); -- planningArea.setPlanningAreaId(planningAreaId); -- -- for (String vehicle : vehicles) { -- String url = TestHelper.getEagleBaseUrlFromVehicleId(vehicle) + VehicleStatusAPI.current.planningarea.RESOURCE; -- RestHelper.put(planningArea, url); -- } -- } -- -- @And("All timetable notification are removed") -- public void allTimetableNotificationAreRemoved() { -- String dPlanningAreas = getHoustonBaseUrl() + TimetableNotificationAPI.planningareas.RESOURCE; -- List<String> planningAreas = TrillianTestRestHelper.getIdsOfItemsInCollection(dPlanningAreas); -- planningAreas.forEach(planningAreaId -> { -- System.out.println("processing planning area id: " + planningAreaId); -- -- List<String> notifications = TrillianTestRestHelper.getIdsOfItemsInCollection(getHoustonBaseUrl() + TimetableNotificationAPI.planningareas.planningAreaId$.notifications.RESOURCE, planningAreaId); -- notifications.forEach(notificationId -> { -- System.out.println("processing notification id: " + notificationId); -- -- String url = getHoustonBaseUrl() + TimetableNotificationAPI.planningareas.planningAreaId$.notifications.notificationId$.RESOURCE -- .replace("{planningAreaId}", planningAreaId) -- .replace("{notificationId}", notificationId); -- System.out.println("timetable notification to delete: " + url); -- RestHelper.del(url); -- }); -- }); -- } -- -- @And("All timetable notification are deleted from houston and all vehicles") -- public void allTimetableNotificationAreDeletedFromHoustonAndAllVehicles() { -- RestHelper.del(getHoustonBaseUrl() + TimetableNotificationAPI.planningareas.RESOURCE); -- RestHelper.del(TestHelper.getEagleBaseUrlFromVehicleId("vehicle_1") + TimetableNotificationAPI.planningareas.RESOURCE); -- RestHelper.del(TestHelper.getEagleBaseUrlFromVehicleId("vehicle_2") + TimetableNotificationAPI.planningareas.RESOURCE); -- RestHelper.del(TestHelper.getEagleBaseUrlFromVehicleId("vehicle_3") + TimetableNotificationAPI.planningareas.RESOURCE); -- } -- -- @And("All timetable notification read are deleted") -- public void allTimetableNotificationReadAreDeleted() { -- RestHelper.del(getHoustonBaseUrl() + "/users/{personalNumber}" + TimetableNotificationAPI.read.planningareas.RESOURCE, "11111111"); -- RestHelper.del(TestHelper.getEagleBaseUrlFromVehicleId("vehicle_1") + "/users/{personalNumber}" + TimetableNotificationAPI.read.planningareas.RESOURCE, "11111111"); -- } -- -- private void putTimetableNotification(String notificationId, String planningAreaId, DataTable dataTable) { -- Map<String, String> data = dataTable.asMap(String.class, String.class); -- -- Notification notification = new Notification(); -- DateTime timestamp = new DateTime(data.get("timestamp"), TIME_ZONE); -- DateTime updateTime = new DateTime(data.get("updateTime"), TIME_ZONE); -- notification.setTimestamp(timestamp); -- notification.setStopIds(new ArrayList<>()); -- final String stopIds = data.get("stopIds"); -- final String insideBrackets = stopIds.substring(1, stopIds.length() - 1); -- if (!insideBrackets.trim().isEmpty()) { -- notification.getStopIds().addAll(Arrays.asList(insideBrackets.split("[, ]"))); -- } -- notification.setSystemLineNumbers(new ArrayList<>()); -- final String systemLineNumbers = data.get("systemLineNumbers"); -- final String insideSystemLineNumbersBrackets = systemLineNumbers.substring(1, systemLineNumbers.length() - 1); -- if (!insideSystemLineNumbersBrackets.trim().isEmpty()) { -- notification.getSystemLineNumbers().addAll(Arrays.asList(insideSystemLineNumbersBrackets.split("[, ]"))); -- } -- notification.setRelationType(RelationType.fromValue(data.get("relationType"))); -- notification.setNotificationType(NotificationType.fromValue(data.get("notificationType"))); -- notification.setTitle(data.get("title")); -- notification.setMessage(data.get("message")); -- notification.setEndMessage(Boolean.valueOf(data.get("endMessage"))); -- notification.setUpdateTime(updateTime); -- -- final String activePeriodStart = data.get("activePeriodStart"); -- final String activePeriodLength = data.get("activePeriodLength"); -- if (activePeriodStart != null && activePeriodLength != null) { -- DateTime start = new DateTime().plusSeconds(Integer.parseInt(activePeriodStart)); -- DateTime end = start.plusSeconds(Integer.parseInt(activePeriodLength)); -- -- notification.setActivePeriods(List.of(new Period().withStart(start).withEnd(end))); -- } -- -- String url = getHoustonBaseUrl() + TimetableNotificationAPI.planningareas.planningAreaId$.notifications.notificationId$.RESOURCE -- .replace("{planningAreaId}", planningAreaId) -- .replace("{notificationId}", notificationId); -- -- RestHelper.put(notification, url); -- } -- -- private void verifyExpectedNotification(String url, Map<String, String> data) { -- boolean testPassed = false; -- // the data has to be synced from the houston to the eagle, might take a short while -- for (int retry = 0; retry < RETRY_COUNTER; retry++) { -- Response response = RestAssured.get(url); -- if (response.getStatusCode() != HttpStatus.SC_OK) { -- try { -- Thread.sleep(RETRY_SLEEP_TIME); -- } catch (InterruptedException ignore) { -- } -- continue; -- } -- JsonPath notificationJson = response.then().extract().jsonPath(); -- -- DateTime timestamp = new DateTime(data.get("timestamp"), TIME_ZONE); -- DateTime updateTime = new DateTime(data.get("updateTime"), TIME_ZONE); -- Assert.assertEquals(timestamp, DateTime.parse(notificationJson.get("timestamp"))); -- final List<String> stopIdList = new ArrayList<>(); -- final String stopIds = data.get("stopIds"); -- final String insideBrackets = stopIds.substring(1, stopIds.length() - 1); -- if (!insideBrackets.trim().isEmpty()) { -- stopIdList.addAll(Arrays.asList(insideBrackets.split("[, ]"))); -- } -- Assert.assertEquals(stopIdList, notificationJson.get("stopIds")); -- final List<String> systemLineNumberList = new ArrayList<>(); -- final String systemLineNumbers = data.get("systemLineNumbers"); -- final String insideSystemLineNumbersBrackets = systemLineNumbers.substring(1, systemLineNumbers.length() - 1); -- if (!insideSystemLineNumbersBrackets.trim().isEmpty()) { -- systemLineNumberList.addAll(Arrays.asList(insideSystemLineNumbersBrackets.split("[, ]"))); -- } -- Assert.assertEquals(systemLineNumberList, notificationJson.get("systemLineNumbers")); -- Assert.assertEquals(data.get("relationType"), notificationJson.get("relationType")); -- Assert.assertEquals(data.get("notificationType"), notificationJson.get("notificationType")); -- Assert.assertEquals(data.get("title"), notificationJson.get("title")); -- Assert.assertEquals(data.get("message"), notificationJson.get("message")); -- Assert.assertEquals(Boolean.valueOf(data.get("endMessage")), notificationJson.get("endMessage")); -- Assert.assertEquals(updateTime, DateTime.parse(notificationJson.get("updateTime"))); -- -- testPassed = true; -- break; -- } -- Assert.assertTrue("Could not find notification info in:'" + url + "' even after a couple of retries", testPassed); -- } -- -- @And("We instruct Zaphake to propose trips for vehicle {string} that start around {int} minutes from now") -- public void weInstructZaphakeToProposeTripsForVehicleThatStartAroundMinutesFromNow(String vehicleId, int minutes) { -- final String zaphakeFPDUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + "/services/zaphake/fpd/"; -- -- RestHelper.post(minutes, zaphakeFPDUrl + "setDepartureTimes"); -- RestHelper.post("{}", zaphakeFPDUrl + "stop"); -- RestHelper.post("{}", zaphakeFPDUrl + "start"); -- } -- -- @And("The vehicles goes on trip with following the trip instance") -- public void theVehiclesGoesOnTripWithFollowingTheTripInstance(DataTable dataTable) { -- List<List<String>> rows = dataTable.asLists(String.class); -- for (int i = 1; i < rows.size(); i++) { -- List<String> row = rows.get(i); -- String vehicleId = row.get(0); -- // Note: basically the planningAreaId is Integer but the timetable API still uses double ... -- int planningAreaId = Integer.parseInt(row.get(1)); -- String systemLineNumber = row.get(2); -- String tripInstanceId = "trip_" + vehicleId; -- String lineNumber = "65431"; -- String shiftNumber = "180501"; -- String tripStopName = "chwarzenburg, Bahnhof"; -- String departure = "2017-09-05T17:17:00+01:00"; -- String directionText = "Riggisberg"; -- -- TripInstance tripInstance = new TripInstance(); -- tripInstance.withId(tripInstanceId); -- tripInstance.withBlockNumber("661"); -- tripInstance.withLineNumber(lineNumber); -- tripInstance.withTimetableType(TripInstanceTimetableType.PLANNED); -- tripInstance.withCategory("Bus"); -- tripInstance.withDirectionId("1"); -- tripInstance.withSystemLineNumber(systemLineNumber); -- tripInstance.withPlanningAreaNumber(planningAreaId); -- tripInstance.withTripNumber("61119"); -- tripInstance.withOperatingDay(LocalDate.now()); -- tripInstance.withCourseNumber("4"); -- tripInstance.withTripType("1"); -- tripInstance.withLineVariant("1"); -- tripInstance.withServiceType("1"); -- -- List<TripStop> tripStops = new ArrayList<>(); -- final String stopIds = row.get(3); -- final String insideBrackets = stopIds.substring(1, stopIds.length() - 1); -- if (!insideBrackets.trim().isEmpty()) { -- for (final String stopId : insideBrackets.split("[, ]")) { -- TripStop tripStop = new TripStop(); -- tripStop.withStopId(stopId); -- tripStop.withStoppingPointId("1"); -- tripStop.withName(tripStopName); -- tripStop.withCoordinates(new Coordinate().withLongitude(7.342955).withLatitude(46.819003).withElevation(792.0)); -- -- tripStop.withDeparture(new DateTime(departure)); -- tripStop.withAlighting(false); -- tripStop.withDirectionText(directionText); -- tripStop.withDistanceToNextStop(427.0); -- tripStop.withEnterRadius(10.0); -- tripStop.withLeaveRadius(10.0); -- tripStop.withShortName("627SCBG"); -- tripStop.withShiftNumber(shiftNumber); -- tripStops.add(tripStop); -- } -- } -- tripInstance.withTripStops(tripStops); -- -- putResource(TestHelper.getEagleBaseUrlFromVehicleId(vehicleId) + TimetableRegistrationAPI.trip.initialization.RESOURCE, tripInitialization(tripInstance)); -- } -- } -- -- @Then("A notification is displayed with message {string} and detail message {string}") -- public void aNotificationIsDisplayedWithMessageAndDetailMessage(String title, String message) { -- // notification was put -- ensurePresent(TestPaths.getEagle1BaseUrl() + "/" + NotificationsAPIPaths.Channels.ChannelName.NotificationId.PATH, "messages", "timetable_notification"); -- -- final SlartiNotification slartiNotification = factory.getNotification(); -- slartiNotification.assertNotificationTitleEqualTo(title); -- slartiNotification.assertNotificationDetailEqualTo(message); -- } -- -- @When("We wait for {long} seconds") -- public void weWaitForSeconds(long seconds) throws Throwable { -- Thread.sleep( seconds * 1000); -- } -- -- @Then("No notification popup is displayed") -- public void noNotificationPopupIsDisplayed() { -- final SlartiNotification slartiNotification = factory.getNotification(); -- slartiNotification.assertNotVisible(); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TimetableNotificationUiTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TimetableNotificationUiTest.java -deleted file mode 100644 -index 866254c..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/e2e/TimetableNotificationUiTest.java -+++ /dev/null -@@ -1,11 +0,0 @@ --package ch.post.it.paisa.trillian.test.e2e; -- --import io.cucumber.junit.Cucumber; --import io.cucumber.junit.CucumberOptions; --import org.junit.runner.RunWith; -- --// ISABUFC-1310 --@RunWith(Cucumber.class) --@CucumberOptions( glue = {"ch.post.it.paisa.trillian.test"}, features = "classpath:features/timetableNotification.feature", plugin = { "pretty", "html:target/cucumber/timetableNotification", "json:target/cucumber.timetableNotification.json" }) --public class TimetableNotificationUiTest { --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/mock/TrillianTripDataGenerator.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/mock/TrillianTripDataGenerator.java -deleted file mode 100644 -index a337b2b..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/mock/TrillianTripDataGenerator.java -+++ /dev/null -@@ -1,434 +0,0 @@ --package ch.post.it.paisa.trillian.test.mock; -- --import ch.post.it.paisa.api.shared.navigation.v1.Coordinate; --import ch.post.it.paisa.api.timetable.common.v1.TripInstance; --import ch.post.it.paisa.api.timetable.common.v1.TripInstanceTimetableType; --import ch.post.it.paisa.api.timetable.common.v1.TripStop; --import ch.post.it.paisa.api.timetable.wait.v1.*; --import org.joda.time.DateTime; -- --import java.util.*; -- -- --/** -- * Trip Data Generator -- * <p> -- * <p> -- * A class that generates trip lines and their intersections on a grid-based -- * system. Trip lines are defined by their trip stops, which are points in a 2d -- * grid. Each trip stop is represented by x and y coordinates and will be named -- * based on its coordinates. For example a point created by x=1 and y=1 will be named -- * Stop (1, 1) and will have an id of "11". -- * <p> -- * Trip stops are only created when trip lines are defined. When adding trip lines -- * <p> -- * <p> -- * <p> -- * For example the trip line defined by the following input (array of integers): -- * <p> -- * int[] tripLineDefinition = new int[] { -- * 1,1, // first trip stop x:1, y:1 -- * 2,1 // second trip stop x:2, y:1 -- * 2,2 // third trip stop x:2, y:2 -- * } -- * <p> -- * will generate the following trip line: -- * <p> -- * y/x |0 |1 |2 |3 -- * ___________________ -- * 0 | | | | -- * 1 | |x1 |x2 | -- * 2 | | |x3 | -- * 3 | | | | -- * <p> -- * Trip Line "11-22": x1 -> x2 -> x3 -- * <p> -- * The line will be called "11-22" (from point 1,1 to point 2,2) -- * and will have 3 trip stops, which will be 11, 21 and 22. -- * -- * @author martindobrev -- */ --public class TrillianTripDataGenerator { -- -- -- /** -- * Stores the available trip references -- * <p> -- * Since we also need TripReference objects, these will also be -- * generated when calculating the lines -- */ -- private final Map<String, TripInstance> availableTripInstances; -- -- -- /** -- * Stores the available trip lines -- * <p> -- * Trip lines are represented by their stops, which are -- * saved in a list. The list ordering corresponds to the logical -- * ordering of the stops in the line. The first stop is the route start -- * and the last stop is the route end -- */ -- private final Map<String, List<TripStop>> availableLines; -- -- -- private final List<String> externalLines; -- -- -- /** -- * Initializes an empty data generator (no trip stops or lines) -- * You have to fill in the data yourself -- */ -- public TrillianTripDataGenerator() { -- availableTripInstances = new HashMap<>(); -- availableLines = new HashMap<>(); -- externalLines = new LinkedList<>(); -- } -- -- /** -- * Creates a {@link TripInstance} and keeps it internally -- * <p> -- * Trip lines are specified by their stop points, -- * which are specified by two integer values that represent their x and y coordinates. -- * So a whole trip line can be defined by an array of integers that will represent -- * the x and y coordinates of the points in the line. -- * <p> -- * For example the following input will generate a trip line with 3 trip stops. -- * <p> -- * int[] tripLineDefinition = new int[] { -- * 1,1, // first trip stop x:1, y:1 -- * 2,1 // second trip stop x:2, y:1 -- * 2,2 // third trip stop x:2, y:2 -- * } -- * -- * -- * @param departureTime the departure time of the trip, used to set reasonable arrival times of the {@link TripStop}s added to the trip -- * @param stopPoints x and y coordinates of the {@link TripStop}s to be added to the trip, alternating -- * @param plannedArrivalPlatforms the planned arrival platforms of the {@link TripStop}s, the size should be half of parameter stopPoints -- * @param external set to true if this is an external line -- */ -- public void addTripLine(DateTime departureTime, int[] stopPoints, List<String> plannedArrivalPlatforms, boolean external) { -- if (stopPoints.length % 2 != 0) { -- throw new IllegalArgumentException("All stops shall be in the form x, y"); -- } -- -- if (stopPoints.length < 4) { -- throw new IllegalArgumentException("A line shall contain at least 2 points"); -- } -- -- final int coordinatesLength = stopPoints.length; -- final String initialStop = stopPoints[0] + "" + stopPoints[1]; -- final String lastStop = stopPoints[coordinatesLength - 2] + "" + stopPoints[coordinatesLength - 1]; -- final String tripId = initialStop + "-" + lastStop; -- -- if (external) { -- externalLines.add(tripId); -- } -- -- final TripInstance tripInstance = new TripInstance(); -- tripInstance.setBlockNumber("test-block-" + tripId); -- tripInstance.setDirectionId(lastStop); -- tripInstance.setId(tripId); -- tripInstance.setLineNumber(initialStop + " -> " + lastStop); -- tripInstance.setTimetableType(TripInstanceTimetableType.PLANNED); -- tripInstance.setCategory("Bus"); -- tripInstance.setOperatingDay(departureTime.toLocalDate()); -- final List<TripStop> stops = new ArrayList<>(); -- for (int i = 0; i < stopPoints.length - 1; i += 2) { -- final int x = stopPoints[i]; -- final int y = stopPoints[i + 1]; -- final String plannedArrivalPlatform = plannedArrivalPlatforms.get(i/2); -- final Coordinate c = new Coordinate(); -- c.setElevation(100d); -- c.setLatitude((double) x); -- c.setLongitude((double) y); -- -- final TripStop ts = new TripStop(); -- ts.setArrival(departureTime.plusMinutes(i)); -- ts.setDeparture(ts.getArrival().plusMinutes(1)); -- ts.setDistanceToNextStop(1000d); -- ts.setStopId(x + "" + y); -- ts.setStoppingPointId("1"); -- ts.setName("Stop (" + x + ", " + y + ")"); -- ts.setDirectionText(lastStop); -- ts.setCoordinates(c); -- ts.setPlannedArrivalPlatform(plannedArrivalPlatform); -- -- stops.add(ts); -- tripInstance.getTripStops().add(ts); -- } -- -- availableLines.put(tripId, stops); -- availableTripInstances.put(tripId, tripInstance); -- -- } -- -- -- /** -- * Returns a WaitRecommendation object for a stop line of trip line -- * <p> -- * Intersecting trip lines in the data generator will always generate -- * a wait recommendation in case the stop of the current trip line -- * is arrived before the intersecting line. This simulates a wait recommendation -- * for the another line with the given deviation of internal and external feeders. -- * -- */ -- public WaitRecommendation buildWaitRecommendation(final String fetcherTripInstanceId, final String fetcherStopId, -- Map<InternalFeederIdentifier, Integer> internalFeederPredictedArrivalDeviation, -- Map<ExternalFeederIdentifier, Integer> externalFeederPredictedArrivalDeviation) { -- -- final TripStop fetcherTripStop = findTripStop(getTripInstance(fetcherTripInstanceId), fetcherStopId); -- -- DateTime fetcherTripStopDeparture = fetcherTripStop.getDeparture(); -- List<InternalFeeder> internalFeeders = getInternalFeeders(fetcherTripInstanceId, fetcherStopId); -- List<ExternalFeeder> externalFeeders = getExternalFeeders(fetcherTripInstanceId, fetcherStopId); -- -- // set deviation to the predicted arrival of the internal feeders -- internalFeederPredictedArrivalDeviation.forEach((k, deviation) -> { -- Optional<InternalFeeder> internalFeederOptional = internalFeeders.stream().filter(v -> { -- InternalFeederIdentifier id = v.getId(); -- return k.getTripInstanceId().equals(id.getTripInstanceId()) && -- k.getArrivalStopId().equals(id.getArrivalStopId()) && -- k.getArrivalStoppingPointId().equals(id.getArrivalStoppingPointId()); -- }).findFirst(); -- if (internalFeederOptional.isPresent()) { -- InternalFeeder internalFeeder = internalFeederOptional.get(); -- DateTime predictedArrival = fetcherTripStopDeparture.plusMinutes(deviation); -- internalFeeder.setPredictedArrival(predictedArrival); -- } -- }); -- -- // set deviation to the predicted arrival of the external feeders -- externalFeederPredictedArrivalDeviation.forEach((k, deviation) -> { -- Optional<ExternalFeeder> externalFeederOptional = externalFeeders.stream().filter(v -> { -- ExternalFeederIdentifier id = v.getId(); -- return k.getExternalTripId().equals(id.getExternalTripId()) -- && k.getExternalSystemId().equals(id.getExternalSystemId()); -- }).findFirst(); -- if (externalFeederOptional.isPresent()) { -- ExternalFeeder externalFeeder = externalFeederOptional.get(); -- DateTime predictedArrival = fetcherTripStopDeparture.plusMinutes(deviation); -- externalFeeder.setPredictedArrival(predictedArrival); -- } -- }); -- -- return new WaitRecommendation() -- .withFetcher(new FetcherIdentifier() -- .withDepartureTime(fetcherTripStopDeparture) -- .withDepartureStoppingPointId(fetcherTripStop.getStoppingPointId()) -- .withDepartureStopId(fetcherTripStop.getStopId()) -- .withTripInstanceId(fetcherTripInstanceId)) -- .withTimestamp(DateTime.now()) -- .withWait(true) -- .withInternalFeeders(internalFeeders) -- .withExternalFeeders(externalFeeders); -- } -- -- public TripInstance getTripInstance(String tripReferenceId) { -- return availableTripInstances.get(tripReferenceId); -- } -- -- /** -- * Extracts a TripStop from a tripInstance (both specified by ids) -- * -- */ -- public TripStop getTripStop(String tripInstanceId, String tripStopId) { -- final TripInstance tripInstance = getTripInstance(tripInstanceId); -- -- if (tripInstanceContainsStopId(tripInstance, tripStopId)) { -- return tripInstance.getTripStops().stream().filter(tripStop -> tripStopId.equals(tripStop.getStopId())).findFirst().get(); -- } -- return null; -- } -- -- -- /** -- * Extracts trip references that contain the stop specified by its id -- * -- */ -- private List<TripInstance> getTripInstances(final String stopId) { -- final List<TripInstance> tripReferences = new ArrayList<>(); -- -- for (final TripInstance tr : availableTripInstances.values()) { -- if (availableLines.containsKey(tr.getId())) { -- tripReferences.add(tr); -- } -- } -- return tripReferences; -- } -- -- /** -- * Checks if the specified trip instance contains a stop with the provided id -- * -- */ -- private boolean tripInstanceContainsStopId(final TripInstance tripInstance, final String stopId) { -- if (tripInstance != null && stopId != null && tripInstance.getTripStops() != null) { -- return tripInstance.getTripStops().stream().anyMatch(tripStop -> stopId.equals(tripStop.getStopId())); -- } -- return false; -- } -- -- -- -- -- /** -- * Generates internal feeders list for the stop id based on the trip id -- * -- * @param fetcherTripInstanceId unique trip line id -- * @param fetcherStopId unique trip stop id -- * @return internal feeders list for the specified stop in the specified trip -- */ -- private List<InternalFeeder> getInternalFeeders(final String fetcherTripInstanceId, final String fetcherStopId) { -- final List<InternalFeeder> feeders = new ArrayList<>(); -- -- for (final TripInstance tripInstance : getTripInstances(fetcherStopId)) { -- boolean isInternalFeeder = !fetcherTripInstanceId.equals(tripInstance.getId()) && !externalLines.contains(tripInstance.getId()); -- if (isInternalFeeder) { -- TripStop feederStop = findTripStop(tripInstance, fetcherStopId); -- feeders.add(new InternalFeeder() -- .withId(new InternalFeederIdentifier() -- .withTripInstanceId(tripInstance.getId()) -- .withArrivalStopId(feederStop.getStopId()) -- .withArrivalStoppingPointId(feederStop.getStoppingPointId()) -- .withArrivalTime(feederStop.getArrival())) -- .withWaitRule(new WaitRule() -- .withMinWaitTime(1) -- .withMaxWaitTime(4) -- .withRuleId("2-7")) -- .withChangeTime(5) -- .withPredictedArrival(feederStop.getArrival())); -- } -- } -- -- // add a phone number to the first one -- if (feeders.size() > 0) { -- feeders.get(0).setPhoneNumber("+41792223344"); -- } -- -- return feeders; -- } -- -- /** -- * Generates external feeders list for the stop id based on the trip id -- * -- * @param fetcherTripId unique trip line id -- * @param fetcherStopId unique trip stop id -- * @return internal feeders list for the specified stop in the specified trip -- */ -- private List<ExternalFeeder> getExternalFeeders(final String fetcherTripId, final String fetcherStopId) { -- final List<ExternalFeeder> feeders = new ArrayList<>(); -- -- for (final TripInstance tripInstance : getTripInstances(fetcherStopId)) { -- boolean isExternalFeeder = !fetcherTripId.equals(tripInstance.getId()) && externalLines.contains(tripInstance.getId()); -- if (isExternalFeeder) { -- TripStop feederStop = findTripStop(tripInstance, fetcherStopId); -- feeders.add(new ExternalFeeder() -- .withId(new ExternalFeederIdentifier() -- .withExternalTripId(tripInstance.getId()) -- .withExternalSystemId("TEST SYSTEM") -- .withArrival(feederStop.getArrival())) -- .withChangeTime(1) -- .withLine("ext-line-1") -- .withCategory("External BUS (TEST)") -- .withDirection(tripInstance.getDirectionId() + " (ext)") -- .withPredictedArrival(feederStop.getArrival()) -- .withStatus(new FeederStatus() -- .withExplicitWait(false) -- .withHasRealtime(false) -- .withWaitTimeIsSufficient(true) -- .withFetcherShouldWait(false)) -- .withWaitRule(new WaitRule() -- .withRuleId("2-7") -- .withMaxWaitTime(7) -- .withMinWaitTime(2))); -- } -- } -- return feeders; -- } -- -- -- -- public List<WaitReport> buildWaitReports(final String feederTripId, final String feederArrivalStopId) { -- -- TripStop feederTripStop = findTripStop(getTripInstance(feederTripId), feederArrivalStopId); -- -- InternalFeederIdentifier internalFeederIdentifier = new InternalFeederIdentifier(); -- internalFeederIdentifier.setArrivalStoppingPointId(feederArrivalStopId); -- internalFeederIdentifier.setTripInstanceId(feederTripId); -- internalFeederIdentifier.setArrivalStopId(feederArrivalStopId); -- internalFeederIdentifier.setArrivalTime(feederTripStop.getArrival()); -- -- List<WaitReport> waitReports = new ArrayList<>(); -- -- Map<TripStop, List<TripInstance>> intersections = getIntersectionTripStopsOfTripId(feederTripId); -- -- intersections.forEach((tripStop, tripInstances) -> { -- if (tripStop.getStopId().equals(feederArrivalStopId)) { -- for (TripInstance tripInstance : tripInstances) { -- -- FetcherIdentifier fetcherIdentifier = new FetcherIdentifier(); -- fetcherIdentifier.setDepartureTime(tripStop.getDeparture()); -- fetcherIdentifier.setDepartureStopId(tripStop.getStopId()); -- fetcherIdentifier.setTripInstanceId(tripInstance.getId()); -- fetcherIdentifier.setDepartureStoppingPointId(tripStop.getStoppingPointId()); -- -- Fetcher fetcher = new Fetcher(); -- fetcher.setId(fetcherIdentifier); -- fetcher.setPhoneNumber("+1234567890"); -- fetcher.setPredictedDeparture(tripStop.getDeparture()); -- -- WaitReport waitReport = new WaitReport(); -- waitReport.setFeeder(internalFeederIdentifier); -- waitReport.setFetcher(fetcher); -- waitReport.setTimestamp(new DateTime()); -- waitReport.setWaiting(false); -- waitReport.setWaitingUntil(tripStop.getDeparture()); -- -- waitReports.add(waitReport); -- } -- } -- }); -- return waitReports; -- } -- -- -- /** -- * Extracts all intersection stops of the selected trip -- * -- */ -- private Map<TripStop, List<TripInstance>> getIntersectionTripStopsOfTripId(final String tripId) { -- Map<TripStop, List<TripInstance>> intersectionStops = new HashMap<>(); -- for (TripStop lineStop : availableLines.get(tripId)) { -- List<TripInstance> tripReferences = getTripInstances(lineStop.getStopId()); -- for (TripInstance tripReference : tripReferences) { -- if (!tripReference.getId().equals(tripId)) { -- for (TripStop potentialIntersection : availableLines.get(tripReference.getId())) { -- if (potentialIntersection.getStopId().equals(lineStop.getStopId())) { -- if (null == intersectionStops.get(lineStop)) { -- intersectionStops.put(lineStop, new ArrayList<>()); -- } -- intersectionStops.get(lineStop).add(tripReference); -- } -- } -- } -- } -- } -- return intersectionStops; -- } -- -- private TripStop findTripStop(TripInstance tripInstance, String stopId) { -- return tripInstance.getTripStops().stream() -- .filter(tripStop -> tripStop.getStopId().equals(stopId)) -- .findFirst() -- .get(); -- } -- -- public TripInstance[] getTripInstances() { -- return availableTripInstances.values().toArray(new TripInstance[availableTripInstances.size()]); -- } -- -- public void clear() { -- availableTripInstances.clear(); -- availableLines.clear(); -- externalLines.clear(); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/DeparturesTestUI.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/DeparturesTestUI.java -deleted file mode 100644 -index a64d15b..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/DeparturesTestUI.java -+++ /dev/null -@@ -1,186 +0,0 @@ --package ch.post.it.paisa.trillian.test.single.instance; -- --import ch.post.it.paisa.api.timetable.planner.v1.Departure; --import ch.post.it.paisa.api.timetable.planner.v1.DepartureBoard; --import ch.post.it.paisa.api.timetable.planner.v1.Stop; --import ch.post.it.paisa.api.timetable.registration.v1.TripInitialization; --import ch.post.it.paisa.slarti.test.ui.elements.DrivingScreen; --import ch.post.it.paisa.slarti.test.ui.elements.Navigation; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.LegacyTestUI; --import ch.post.it.paisa.trillian.test.ui.pages.DeparturePage; --import org.joda.time.DateTime; --import org.junit.Before; --import org.junit.Test; --import org.openqa.selenium.WebElement; -- --import static ch.post.it.paisa.trillian.test.RestAssuredSupport.deleteResource; --import static ch.post.it.paisa.trillian.test.RestAssuredSupport.putResource; --import static ch.post.it.paisa.trillian.test.TestPaths.*; --import static ch.post.it.paisa.trillian.test.TrillianTestRestHelper.putTripInstanceInformationToZaphake; --import static ch.post.it.paisa.trillian.test.ui.TextFixtures.tripInitialization; --import static ch.post.it.paisa.trillian.test.ui.TextFixtures.tripPosition; --import static java.lang.Thread.sleep; --import static java.util.Arrays.asList; --import static junit.framework.TestCase.assertTrue; --import static org.junit.Assert.assertEquals; --import static org.junit.Assert.assertNotNull; -- --/** -- * Test for the Departures UI Tab -- * <p> -- * Adds departures test data (represented by ch.post.it.paisa.api.timetable.situation.v1.Connection) -- * and tests different UI areas -- * <p> -- * Currently the page has no interactions, but that may change in the future -- * <p> -- * Created by martindobrev on 1/11/17. -- */ --public class DeparturesTestUI extends LegacyTestUI { -- -- @Before -- public void setupTestData() { -- deleteResource(DEPARTUREBOARD_URL); -- deleteResource(TRIP_INITIALIZATION); -- deleteResource(TRIP_POSITION); -- } -- -- @Test -- public void testConnectionDisplay() { -- TripInitialization tripInitialization = tripInitialization(); -- putTripInstanceInformationToZaphake(tripInitialization.getTripInstance()); -- putResource(TRIP_INITIALIZATION, tripInitialization); -- putResource(TRIP_POSITION, tripPosition(2, tripInitialization.getTripInstance())); -- -- DepartureBoard departureBoard = new DepartureBoard() -- .withDepartures(asList( -- departure(" 1").withPredictedDeparture(DateTime.now().plusMinutes(5)), -- departure(" 2").withPredictedDeparture(DateTime.now().plusMinutes(0)), -- departure(" 3").withActualDeparture(DateTime.now().plusMinutes(4)), -- departure(" 4").withActualDeparture(DateTime.now().plusMinutes(0)), -- departure(" 5").withActualDeparture(DateTime.now().minusMinutes(1)), -- departure(" 6").withCanceled(true), -- departure(" 7"), -- departure(" 8"), -- departure(" 9"), -- departure(" 10") -- )); -- -- putResource(DEPARTUREBOARD_URL, departureBoard); -- -- DeparturePage departurePage = goToDeparturePage(); -- -- assertTrue("There shall be some departures displayed", departurePage.departuresAvailable()); -- assertEquals("Only 10 departure shall be available", 10, departurePage.getNumberOfDepartures()); -- -- String departureName = departurePage.getDepartureName(1); -- assertNotNull("The first departure shall not be null", departureName); -- assertEquals(departureBoard.getDepartures().get(0).getName(), departureName); -- -- String departureTime = departurePage.getDepartureTime(1); -- assertEquals(getTime(departureBoard.getDepartures().get(0).getDeparture()), departureTime); -- -- String departureDirection = departurePage.getDepartureDirection(1); -- assertEquals(departureBoard.getDepartures().get(0).getDirection(), departureDirection); -- -- String departureDelay = departurePage.getDepartureDelay(1); -- assertEquals("+5'", departureDelay); -- -- departureDelay = departurePage.getDepartureDelay(2); -- assertEquals("", departureDelay); -- -- departureDelay = departurePage.getDepartureDelay(3); -- assertEquals(getActualDepartureTime(departureBoard, 2) + " (+4')", departureDelay); -- -- departureDelay = departurePage.getDepartureDelay(4); -- assertEquals(getActualDepartureTime(departureBoard, 3) + " (+0')", departureDelay); -- -- departureDelay = departurePage.getDepartureDelay(5); -- assertEquals(getActualDepartureTime(departureBoard, 4) + " (-1')", departureDelay); -- -- departureDelay = departurePage.getDepartureDelay(6); -- assertEquals("Annuliert", departureDelay); -- } -- -- @Test -- public void testConnectionDisplayRefreshAfter5Seconds() throws InterruptedException { -- TripInitialization tripInitialization = tripInitialization(); -- putTripInstanceInformationToZaphake(tripInitialization.getTripInstance()); -- putResource(TRIP_INITIALIZATION, tripInitialization); -- putResource(TRIP_POSITION, tripPosition(2, tripInitialization.getTripInstance())); -- -- DepartureBoard departureBoard = new DepartureBoard() -- .withDepartures(asList( -- departure(" 1"), -- departure(" 2"), -- departure(" 3") -- )); -- -- putResource(DEPARTUREBOARD_URL, departureBoard); -- -- DeparturePage departurePage = goToDeparturePage(); -- -- assertEquals("Only 3 departure shall be available", 3, departurePage.getNumberOfDepartures()); -- -- departureBoard = new DepartureBoard() -- .withDepartures(asList( -- departure(" 1"), -- departure(" 2"), -- departure(" 3"), -- departure(" 4"), -- departure(" 5") -- )); -- -- putResource(DEPARTUREBOARD_URL, departureBoard); -- -- assertEquals("Only 3 departure shall be available", 3, departurePage.getNumberOfDepartures()); -- -- sleep(5000); -- -- assertEquals("Only 5 departure shall be available", 5, departurePage.getNumberOfDepartures()); -- } -- -- private String getActualDepartureTime(DepartureBoard departureBoard, int index) { -- return getTime(departureBoard.getDepartures().get(index).getActualDeparture()); -- } -- -- private String getTime(DateTime dateTime) { -- return dateTime.toString("HH:mm"); -- } -- -- private Departure departure(String id) { -- return new Departure() -- .withCategory("S" + id) -- .withTrain("38357" + id) -- .withLine("3" + id) -- .withName("S 3" + id) -- .withStop(new Stop() -- .withId("801404100" + id) -- .withName("Untergrombach" + id)) -- .withDeparture(DateTime.now()) -- .withDirection("Karlsruhe Hbf" + id) -- .withDestination(new Stop() -- .withId("801422800" + id) -- .withName("Karlsruhe Hbf" + id)) -- .withDestinationDateTime(DateTime.now().plusHours(3)); -- } -- -- private DeparturePage goToDeparturePage() { -- -- Navigation navigation1 = new Navigation(seleniumHelper); -- -- navigation1.touchDrivingScreenModule(); -- DrivingScreen drivingScreen = new DrivingScreen(seleniumHelper); -- drivingScreen.waitForDrivingScreenToActivate(); -- -- BaseTestTrillian.switchToFrame("module-SlartiComboModule"); -- WebElement connectionElement = seleniumHelper.getWebElement("//span[contains(@class,'icon-th-list')]"); -- connectionElement.click(); -- -- BaseTestTrillian.switchToFrame("module-Trillian"); -- -- return new DeparturePage(driver, seleniumHelper); -- } -- -- --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/IncomingPhoneCallTestUI.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/IncomingPhoneCallTestUI.java -deleted file mode 100644 -index e181441..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/IncomingPhoneCallTestUI.java -+++ /dev/null -@@ -1,132 +0,0 @@ --package ch.post.it.paisa.trillian.test.single.instance; -- --import ch.post.it.paisa.api.communication.modem.v1.Direction; --import ch.post.it.paisa.api.communication.modem.v1.State; --import ch.post.it.paisa.api.communication.v1.CallInfo; --import ch.post.it.paisa.trillian.test.TrillianTestRestHelper; --import ch.post.it.paisa.trillian.test.ui.BasePhoneCallTest; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNotification; --import ch.post.it.paisa.trillian.test.ui.pages.CallLogPage; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import org.joda.time.DateTime; --import org.junit.Before; --import org.junit.FixMethodOrder; --import org.junit.Test; --import org.junit.runners.MethodSorters; --import org.openqa.selenium.By; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.ui.ExpectedConditions; -- --import java.util.List; -- --import static ch.post.it.paisa.trillian.test.NotificationLabelConstants.INCOMING_CALL_NUMBER; --import static org.junit.Assert.assertEquals; -- --@FixMethodOrder(MethodSorters.NAME_ASCENDING) --public class IncomingPhoneCallTestUI extends BasePhoneCallTest { -- -- private SlartiNotification notification; -- -- @Before -- public void setup() { -- super.setupPhoneCallTest(); -- notification = factory.getNotification(); -- } -- -- @Test -- public void testIncomingCall() { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- putCallState(Direction.INCOMING, State.DIALING); -- assertPhoneCallSection("+4176xxxxxxxx"); -- seleniumHelper.switchToRoot(); -- seleniumHelper.getDriver().findElements(By.className("notification-CALL")); -- List<WebElement> elements = seleniumHelper.getDriver().findElements(By.className("notification-message")); -- expectOneElementWithText(elements, "Anruf von +4176xxxxxxxx"); -- performAndAssertPhoneCall(Direction.INCOMING, "Aktives Gespräch mit +4176xxxxxxxx"); -- } -- -- @Test -- public void testOutgoingCall() { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- putCallState(Direction.OUTGOING, State.DIALING); -- assertPhoneCallSection("+4176xxxxxxxx"); -- seleniumHelper.switchToRoot(); -- List<WebElement> elements = seleniumHelper.getDriver().findElements(By.className("notification-message")); -- expectOneElementWithText(elements, "Rufaufbau... +4176xxxxxxxx"); -- performAndAssertPhoneCall(Direction.OUTGOING, "Aktives Gespräch mit +4176xxxxxxxx"); -- } -- -- @Test -- public void testCallLogWithMulitpleCallEntries() { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- final OverviewPage overviewPage = factory.getOverviewPage(); -- -- final int callNumberToTest = 7; -- for (int i = 0; i < callNumberToTest; i++) { -- final CallInfo callLogEntry = new CallInfo(); -- callLogEntry.setId("dummy4SelemiumTest_" + i); -- callLogEntry.setTime(DateTime.now()); -- callLogEntry.setPhoneNumber(INCOMING_CALL_NUMBER); -- TrillianTestRestHelper.addCallLogEntry(callLogEntry); -- } -- -- assertEquals(3, overviewPage.getCallLogSize());// Max 3 in Favourites -- -- overviewPage.touchGoToCalllogButton(); -- final CallLogPage callLogPage = factory.getCalllogPage(); -- callLogPage.waitForTitle(); -- -- assertEquals(callNumberToTest, callLogPage.getCallLogSize()); -- callLogPage.touchGoBackButton(); -- -- TrillianTestRestHelper.clearCallLog(); -- -- seleniumHelper.switchToRoot(); // be on SLARTI IFrame -- -- } -- -- private void performAndAssertPhoneCall(Direction callDirection, String activePhoneCallMessage) { -- List<WebElement> elements; -- // Activate call -- putCallState(callDirection, State.ACTIVE); -- elements = getWait().until(ExpectedConditions.visibilityOfAllElements(driver.findElements(By.className("text")))); -- expectOneElementWithText(elements, activePhoneCallMessage); -- // hang up -- putCallState(Direction.NONE, State.NONE); -- getWait().until(ExpectedConditions.invisibilityOfAllElements(driver.findElements(By.className("text")))); -- } -- -- private void expectOneElementWithText(List<WebElement> elements, String expected) { -- assertEquals(1, elements.size()); -- assertEquals(expected, elements.iterator().next().getText()); -- } -- -- private void assertPhoneCallSection(String phonenumber) { -- // TODO: Reverse lookup against telephone book (Implement additional fields) -- getWait().until(webDriver -> seleniumHelper.getDriver().findElement(By.id("PhoneNumber")).getText().trim().equals(phonenumber)); -- } -- -- --// private void sendAndValidateRing() { --// final Notification incomingCall = callNotificationFactory.createIncomingCall(); --// triggerEvent(RING); --// notification.assertVisibleSummaryAndOKAndCancelButtons(incomingCall.getMessage().getSummary()); --// } -- -- private void pressAndValidateOk() { -- notification.touchNotificationButtonOk(); -- // TODO Check for Slarti Active Call -- BaseTestTrillian.switchToFrame("module-Trillian"); -- //openDialPad(); -- //final DialPad dialPad = factory.getDialPad(); -- //assertTrue(dialPad.hasActiveCall()); -- } -- --// private void checkEndCallAndCallLog() { --// assertCallEnded(); --// assertCallLogUpdated(); --// } -- -- --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/OutgoingPhoneCallTestUI.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/OutgoingPhoneCallTestUI.java -deleted file mode 100644 -index c4fd79d..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/OutgoingPhoneCallTestUI.java -+++ /dev/null -@@ -1,108 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test.single.instance; -- --import ch.post.it.paisa.trillian.test.NotificationLabelConstants; --import ch.post.it.paisa.trillian.test.TrillianTestRestHelper; --import ch.post.it.paisa.trillian.test.ui.BasePhoneCallTest; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNotification; --import org.junit.Before; --import org.junit.FixMethodOrder; --import org.junit.Ignore; --import org.junit.Test; --import org.junit.runners.MethodSorters; -- --import static ch.post.it.paisa.trillian.test.NotificationLabelConstants.*; --import static ch.post.it.paisa.trillian.test.TrillianTestRestHelper.GsmEvent.*; --import static ch.post.it.paisa.trillian.test.TrillianTestRestHelper.triggerEvent; --import static org.junit.Assert.assertFalse; -- --@FixMethodOrder(MethodSorters.NAME_ASCENDING) --public class OutgoingPhoneCallTestUI extends BasePhoneCallTest { -- -- -- private SlartiNotification notification; -- -- private String expectedOutgoingCallSummaryWithNumber; -- --// @Before --// public void setup() { --// super.setupPhoneCallTest(); --// notification = factory.getNotification(); --// expectedOutgoingCallSummaryWithNumber = callNotificationFactory.createCallDailing(NotificationLabelConstants.OUTGOING_CALL_NUMBER,DUMMY_DETAILS).getMessage().getSummary(); --// } -- --// @Ignore // FIXME ignored and opened ISABUFC-1483 --// @Test --// public void uc1_out_testOutgoingCallWithHangup() { --// initiateAndAssertOutgoingCall(OUTGOING_CALL_NUMBER); --// --// notification.touchNotificationButtonCancel(); --// notification.waitForNotificationButtonCancelClose(); --// // new Toast --// assertFalse("There shall not be a registered active call, but one was found!", TrillianTestRestHelper.isCallStatusActive()); --// assertCallLogUpdated(); --// } -- --// @Ignore // FIXME ignored and opened ISABUFC-1483 --// @Test --// public void uc2_out_testOutgoingCallWithBusy() { --// initiateAndAssertOutgoingCall(OUTGOING_CALL_NUMBER); --// --// triggerEvent(BUSY); --// // new Toast --// assertFalse("There shall not be a registered active call, but one was found!", TrillianTestRestHelper.isCallStatusActive()); --// assertCallLogUpdated(); --// } -- --// @Ignore // FIXME ignored and opened ISABUFC-1483 --// @Test --// public void uc3_out_testOutgoingCallWithRemoteAcceptAndLocalHangupLongActiveCall() { --// initiateAndAssertOutgoingCall(OUTGOING_CALL_NUMBER); --// --// triggerEvent(OK); --// triggerEvent(COLP); --// --// hangup(); --// --// assertFalse("There shall not be a registered active call, but one was found!", TrillianTestRestHelper.isCallStatusActive()); --// assertCallLogUpdated(); --// } -- --// @Test --// @Ignore --// public void uc3_out_testOutgoingCallWithRemoteAcceptAndRemoteHangup() { --// wait(WAIT_TIME_AFTER_EVENT_LONG); --// initiateAndAssertOutgoingCall(OUTGOING_CALL_NUMBER); --// --// triggerEvent(OK); --// wait(200); --// triggerEvent(COLP); --// wait(WAIT_TIME_AFTER_EVENT_LONG); --// triggerEvent(NO_CARRIER); // Remote Hangup --// wait(WAIT_TIME_AFTER_EVENT); --// --// assertFalse("There shall not be a registered active call, but one was found!", TrillianTestRestHelper.isCallStatusActive()); --// assertCallLogUpdated(); --// } -- --// @Test --// @Ignore --// public void uc4_out_testOutgoingCallWithKeypad() { --// wait(WAIT_TIME_AFTER_EVENT_LONG); --// initiateAndAssertOutgoingCallOnDialPad(OUTGOING_CALL_NUMBER, OUTGOING_CALL_NUMBER);// No Alpha available --// wait(WAIT_TIME_AFTER_EVENT_LONG); --// notification.assertVisibleSummary("Call Ended Message should showup", expectedOutgoingCallSummaryWithNumber); --// notification.touchNotificationButtonCancel(); --// wait(WAIT_TIME_AFTER_EVENT); --// assertFalse("There shall not be a registered active call, but one was found!", TrillianTestRestHelper.isCallStatusActive()); --// assertCallLogUpdated(); --// } -- --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/OverviewTestUI.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/OverviewTestUI.java -deleted file mode 100644 -index 8873af1..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/OverviewTestUI.java -+++ /dev/null -@@ -1,149 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test.single.instance; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.BookInfo; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.Contact; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.ContactType; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.path.PAISAControlcenterPhonebookAPI; --import ch.post.it.paisa.trillian.test.TrillianTestRestHelper; --import ch.post.it.paisa.trillian.test.ui.LegacyTestUI; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import org.junit.AfterClass; --import org.junit.Before; --import org.junit.BeforeClass; --import org.junit.Test; --import org.openqa.selenium.WebElement; -- --import java.util.List; -- --import static ch.post.it.paisa.trillian.test.TestPaths.getHoustonBaseUrl; --import static ch.post.it.paisa.trillian.test.TrillianTestRestHelper.*; --import static org.junit.Assert.assertFalse; --import static org.junit.Assert.assertNotNull; -- --/** -- * Tests the basic Overview UI functions -- * <p> -- * For now checks only that favourites -- * are correctly displayed -- * <p> -- * Since the phonebook entries are dependent -- * on the eagle information, only the test data -- * is to be tested - otherwise the test will probably -- * fail on the jenkins server since there are other -- * phonebook entries -- * <p> -- * <p> -- * Created by martindobrev on 10/11/16. -- */ --public class OverviewTestUI extends LegacyTestUI { -- -- -- private static final Integer TEST_PLANNING_AREA_ID_2 = 2; -- /** -- * overview page element for convenient information extraction -- */ -- private OverviewPage overviewPage; -- -- @BeforeClass -- public static void createTestPhonebook() { -- TrillianTestRestHelper.putSyncParametersToHouston(); -- TrillianTestRestHelper.publishDefaultAffiliation(DEFAULT_VEHICLE); -- TrillianTestRestHelper.publishCurrentPlanningArea(DEFAULT_PLANNING_AREA_ID); -- -- BookInfo bookInfoA = new BookInfo(); -- bookInfoA.setName(DEFAULT_PHONEBOOK_NAME); -- bookInfoA.setVersion("1"); -- final String bookInfoUrlA = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE -- .replace("{planningAreaId}", DEFAULT_PLANNING_AREA_ID.toString()) -- .replace("{bookId}", DEFAULT_PHONEBOOK_ID); -- RestHelper.put(bookInfoA, bookInfoUrlA); -- -- BookInfo bookInfoB = new BookInfo(); -- bookInfoB.setName(DEFAULT_PHONEBOOK_NAME); -- bookInfoB.setVersion("1"); -- final String bookInfoUrlB = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE -- .replace("{planningAreaId}", TEST_PLANNING_AREA_ID_2.toString()) -- .replace("{bookId}", DEFAULT_PHONEBOOK_ID); -- RestHelper.put(bookInfoB, bookInfoUrlB); -- -- final Contact emergencyEntry = new Contact(); -- emergencyEntry.setDescription("TEST EMERGENCY"); -- emergencyEntry.setType(ContactType.EMERGENCY); -- emergencyEntry.setPhoneNumber("000"); -- final String emergencyEntryUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.contacts.contactId$.RESOURCE -- .replace("{planningAreaId}", DEFAULT_PLANNING_AREA_ID.toString()) -- .replace("{bookId}", DEFAULT_PHONEBOOK_ID) -- .replace("{contactId}", "TEST_SOS"); -- RestHelper.put(emergencyEntry, emergencyEntryUrl); -- //---------------------------------------------- -- final Contact controlCenterEntry = new Contact(); -- controlCenterEntry.setDescription("TEST CONTROL CENTER"); -- controlCenterEntry.setType(ContactType.CONTROLCENTER); -- controlCenterEntry.setPhoneNumber("001"); -- final String controlCenterEntryUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.contacts.contactId$.RESOURCE -- .replace("{planningAreaId}", DEFAULT_PLANNING_AREA_ID.toString()) -- .replace("{bookId}", DEFAULT_PHONEBOOK_ID) -- .replace("{contactId}", "TEST_CC"); -- RestHelper.put(controlCenterEntry, controlCenterEntryUrl); -- //---------------------------------------------- -- final Contact emergencyEntryInDifferentPlanningArea = new Contact(); -- emergencyEntryInDifferentPlanningArea.setDescription("TEST EMERGENCY 2"); -- emergencyEntryInDifferentPlanningArea.setType(ContactType.EMERGENCY); -- emergencyEntryInDifferentPlanningArea.setPhoneNumber("003"); -- final String emergencyEntryInDifferentPlanningAreaUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.contacts.contactId$.RESOURCE -- .replace("{planningAreaId}", TEST_PLANNING_AREA_ID_2.toString()) -- .replace("{bookId}", DEFAULT_PHONEBOOK_ID) -- .replace("{contactId}", "TEST_SOS1"); -- RestHelper.put(emergencyEntryInDifferentPlanningArea, emergencyEntryInDifferentPlanningAreaUrl); -- //---------------------------------------------- -- -- TrillianTestRestHelper.waitUntilPhonebooksSynced(); -- } -- -- @AfterClass -- public static void deleteTestPhonebook() { -- TrillianTestRestHelper.deletePhonebook(DEFAULT_PHONEBOOK_ID); -- TrillianTestRestHelper.deletePhonebook(TEST_PLANNING_AREA_ID_2, DEFAULT_PHONEBOOK_ID); -- } -- -- /** -- * Switches to the phonebook tab and then goes back -- * <p> -- * This refreshes the phonebook entries - necessary -- * operation because phonebooks are not updated dynamically, -- * only on reload (because dynamical updates will happen -- * very rarely) -- */ -- @Before -- public void refreshPhonebookEntries() { -- selectPhonebookByName(DEFAULT_PHONEBOOK_NAME); -- -- factory.getOverviewPage().touchGoToPhonebookButton(); -- factory.getPhonebookPage().touchGoBackButton(); -- -- TrillianTestRestHelper.deleteVehicleMessagingNotifications(); -- } -- -- @Test -- public void testEmergencyPhonebookEntryInOtherPlanningAreadNotDisplayedInFavourites() { -- overviewPage = factory.getOverviewPage(); -- List<WebElement> favouriteEntries = overviewPage.getFavouriteEntries(); -- assertNotNull("No favourite entries were found!", favouriteEntries); -- boolean sosEntryPresent = false; -- for (WebElement el : favouriteEntries) { -- if (el.getText().contains("TEST EMERGENCY 2")) { -- sosEntryPresent = true; -- } -- } -- assertFalse("SOS Entry 'TEST EMERGENCY 2' should not display in the favourite entries", sosEntryPresent); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/SlartiCallNotificationTestUI.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/SlartiCallNotificationTestUI.java -deleted file mode 100644 -index 8cf75c5..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/SlartiCallNotificationTestUI.java -+++ /dev/null -@@ -1,108 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test.single.instance; -- --import ch.post.it.paisa.api.notifications.v1.Notification; --import ch.post.it.paisa.trillian.test.ui.LegacyTestUI; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNotification; --import org.junit.After; --import org.junit.Before; --import org.springframework.context.support.ResourceBundleMessageSource; -- --import static ch.post.it.paisa.trillian.test.TrillianTestRestHelper.putSlartiNotification; -- --public class SlartiCallNotificationTestUI extends LegacyTestUI { -- -- private static final String CALLER_ALPHA = "Barack Obama"; -- private Notification latestSentNotification; -- -- -- @Before -- public void setup() { -- final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); -- messageSource.setBasename("resources/messages"); -- seleniumHelper.switchToRoot(); // be on SLARTI IFrame -- final SlartiNotification notificationUI = factory.getNotification(); -- notificationUI.assertNotVisible(); -- } -- -- @After -- public void tearDown() { -- if (latestSentNotification != null) { -- latestSentNotification.getMessage().getOptions().setHidden(true); -- putSlartiNotification(latestSentNotification); -- latestSentNotification = null; -- } -- } -- -- --// @Test --// public void createIncomingCallTest() { --// final SlartiNotification notificationUI = factory.getNotification(); --// --// latestSentNotification = callNotificationFactory.createIncomingCall(); --// putSlartiNotification(latestSentNotification); --// --// assertTrue(notificationUI.isNotificationContainerVisible()); --// notificationUI.assertNotificationTitleEqualTo(NotificationLabelConstants.INCOMING_CALL_RING); --// } --// --// @Test --// public void updateIncomingCallLabelTest() { --// final SlartiNotification notificationUI = factory.getNotification(); --// --// latestSentNotification = callNotificationFactory.createIncomingCall(); --// putSlartiNotification(latestSentNotification); --// --// latestSentNotification = callNotificationFactory.updateIncomingCallLabel(latestSentNotification.getMessage().getId(),CALLER_ALPHA,DUMMY_DETAILS); --// putSlartiNotification(latestSentNotification); --// --// assertTrue(notificationUI.isNotificationContainerVisible()); --// notificationUI.assertNotificationTitleEqualTo(NotificationLabelConstants.INCOMING_CALL_LABEL + " Barack Obama"); --// } --// --// --// @Test --// public void createCallDailingTest() { --// final SlartiNotification notificationUI = factory.getNotification(); --// --// latestSentNotification = callNotificationFactory.createCallDailing(CALLER_ALPHA,DUMMY_DETAILS); --// putSlartiNotification(latestSentNotification); --// --// assertTrue(notificationUI.isNotificationContainerVisible()); --// notificationUI.assertNotificationTitleEqualTo(NotificationLabelConstants.CALL_DIAL_TEXT + " Barack Obama"); --// } --// --// --// @Test --// public void createCallEndedTest() { --// final SlartiNotification notificationUI = factory.getNotification(); --// --// latestSentNotification = callNotificationFactory.createCallEnded(); --// putSlartiNotification(latestSentNotification); --// --// assertTrue(notificationUI.isNotificationContainerVisible()); --// notificationUI.assertNotificationTitleEqualTo(NotificationLabelConstants.CALL_ENDED_TEXT); --// } --// --// --// @Test --// public void closeOnIncomingCallTimeout() { --// final SlartiNotification notificationUI = factory.getNotification(); --// --// latestSentNotification = callNotificationFactory.createIncomingCall(); --// putSlartiNotification(latestSentNotification); --// notificationUI.assertVisible(); --// latestSentNotification = callNotificationFactory.closeOnIncomingCallTimeout(latestSentNotification.getMessage().getId(),CALLER_ALPHA); --// putSlartiNotification(latestSentNotification); --// notificationUI.assertNotVisible(); --// --// assertFalse("No Notification should be visible after closeActiveCall", notificationUI.isNotificationContainerVisible()); --// } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/TrillianNavigationTestUI.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/TrillianNavigationTestUI.java -deleted file mode 100644 -index 0bec8b3..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/TrillianNavigationTestUI.java -+++ /dev/null -@@ -1,77 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test.single.instance; -- --import ch.post.it.paisa.trillian.test.ui.LegacyTestUI; --import ch.post.it.paisa.trillian.test.ui.pages.CallLogPage; --import ch.post.it.paisa.trillian.test.ui.pages.MessagingPage; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import ch.post.it.paisa.trillian.test.ui.pages.PhonebookPage; --import org.junit.BeforeClass; --import org.junit.Test; -- --public class TrillianNavigationTestUI extends LegacyTestUI { -- -- @BeforeClass -- public static void init() { -- } -- -- @Test -- public void testPhonebookNavigation(){ -- OverviewPage overviewPage = factory.getOverviewPage(); -- overviewPage.waitForTitle(); -- overviewPage.touchGoToPhonebookButton(); -- -- PhonebookPage phonebookPage = factory.getPhonebookPage(); -- phonebookPage.waitForTitle(); -- phonebookPage.touchGoBackButton(); -- -- overviewPage.waitForTitle(); -- } -- -- @Test -- public void testMessagingNavigation(){ -- OverviewPage overviewPage = factory.getOverviewPage(); -- overviewPage.waitForTitle(); -- overviewPage.touchGoToMessagesButton(); -- -- MessagingPage messagingPage = factory.getMessagingPage(); -- messagingPage.waitForTitle(); -- messagingPage.touchGoBackButton(); -- -- overviewPage.waitForTitle(); -- } -- -- -- @Test -- public void testCallLogNavigation(){ -- OverviewPage overviewPage = factory.getOverviewPage(); -- overviewPage.waitForTitle(); -- overviewPage.touchGoToCalllogButton(); -- -- CallLogPage callLogPage = factory.getCalllogPage(); -- callLogPage.waitForTitle(); -- callLogPage.touchGoBackButton(); -- -- overviewPage.waitForTitle(); -- } -- -- @Test -- public void testDialPadNavigation() throws InterruptedException{ -- OverviewPage overviewPage = factory.getOverviewPage(); -- overviewPage.waitForTitle(); -- overviewPage.assertDialPadClosed(); -- -- overviewPage.touchDialPadButton(); -- overviewPage.assertDialPadVisible(); -- -- overviewPage.touchDialPadCloseButton(); -- overviewPage.assertDialPadClosed(); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/TrillianPhonebookTestFilter.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/TrillianPhonebookTestFilter.java -deleted file mode 100644 -index 91e48c6..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/TrillianPhonebookTestFilter.java -+++ /dev/null -@@ -1,191 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test.single.instance; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.BookInfo; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.Contact; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.ContactType; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.path.PAISAControlcenterPhonebookAPI; --import ch.post.it.paisa.trillian.test.TrillianTestRestHelper; --import ch.post.it.paisa.trillian.test.ui.LegacyTestUI; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import ch.post.it.paisa.trillian.test.ui.pages.PhonebookPage; --import org.junit.AfterClass; --import org.junit.Before; --import org.junit.BeforeClass; --import org.junit.Test; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; -- --import java.security.MessageDigest; --import java.security.NoSuchAlgorithmException; -- --import static ch.post.it.paisa.trillian.test.TestPaths.getHoustonBaseUrl; --import static ch.post.it.paisa.trillian.test.TrillianTestRestHelper.*; --import static org.junit.Assert.assertEquals; -- --/** -- * Class TrillianPhonebookTestFilter -- * -- * Test cases for the filtering of phonebook entries -- * -- * Currently tests only the -- */ --public class TrillianPhonebookTestFilter extends LegacyTestUI { -- private static final Logger LOG = LoggerFactory.getLogger(TrillianPhonebookTestUI.class); -- -- private PhonebookPage phonebookPage; -- -- private static final String[] letters = new String[]{"A", "a", "O", "o", "U", "u", "Ä", "ä", "Ö", "ö", "Ü", "ü"}; -- -- private static final String[] phoneNumbers = new String[]{ -- "+49 123 456 189", -- "+49-000-456-629", -- "+49/000/772/342", -- "+49 000 -- 878 -/ -223", -- "+34(225)128-004", -- "+49 000 000 005", -- "+49 000 000 006", -- "+49 000 000 007", -- "+49 000 000 008", -- "+49 000 000 009", -- "+49 000 000 010", -- "+49 000 000 011" -- }; -- -- -- @BeforeClass -- public static void createTestPhonebook() throws NoSuchAlgorithmException { -- TrillianTestRestHelper.putSyncParametersToHouston(); -- TrillianTestRestHelper.publishDefaultAffiliation(DEFAULT_VEHICLE); -- TrillianTestRestHelper.publishCurrentPlanningArea(DEFAULT_PLANNING_AREA_ID); -- MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); -- BookInfo bookInfo = new BookInfo(); -- bookInfo.setName(DEFAULT_PHONEBOOK_NAME); -- bookInfo.setVersion("1"); -- final String bookInfoUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE -- .replace("{planningAreaId}", DEFAULT_PLANNING_AREA_ID.toString()) -- .replace("{bookId}", DEFAULT_PHONEBOOK_ID); -- -- for (int i = 0; i < letters.length; i++) { -- Contact contact = new Contact(); -- contact.setType(ContactType.PARTNER); -- String letter = letters[i]; -- contact.setPhoneNumber(phoneNumbers[i]); -- contact.setDescription(letter + "qwerty"); -- String contactId = TrillianTestRestHelper.generateContactId(contact.getDescription(), contact.getPhoneNumber(), messageDigest); -- -- final String contactUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.contacts.contactId$.RESOURCE -- .replace("{planningAreaId}", DEFAULT_PLANNING_AREA_ID.toString()) -- .replace("{bookId}", DEFAULT_PHONEBOOK_ID) -- .replace("{contactId}", contactId); -- RestHelper.put(contact, contactUrl); -- LOG.info("Created PhonebookEntry {}", letter); -- } -- RestHelper.put(bookInfo, bookInfoUrl); -- TrillianTestRestHelper.waitUntilPhonebooksSynced(letters.length); -- } -- -- @AfterClass -- public static void deleteTestPhonebook() { -- TrillianTestRestHelper.deletePhonebook(DEFAULT_PHONEBOOK_ID); -- } -- -- @Before -- public void initOverViewPageAndPhonebookPage() { -- selectPhonebookByName(DEFAULT_PHONEBOOK_NAME); -- -- OverviewPage overviewPage = factory.getOverviewPage(); -- overviewPage.touchGoToPhonebookButton(); -- phonebookPage = factory.getPhonebookPage(); -- phonebookPage.waitForTitle(); -- } -- -- @Test -- public void testPhonebookFilterLetters() { -- try { -- for (String letter : letters) { -- LOG.info("Searching for: " + letter + "qwerty"); -- phonebookPage.touchSearchButton(); -- phonebookPage.enterSearchText(letter + "qwerty"); -- assertEquals("Phonebook should have 4 Entries with begin with the letter " + letter + " and end with 'qwerty'" -- , 4, phonebookPage.getPhonebookEntriesSize()); -- phonebookPage.touchClearSearchTextButton(); -- } -- } finally { -- phonebookPage.touchGoBackButton(); -- } -- } -- -- @Test -- public void testPhonebookFilterPhoneNumberEliminatesWhitespaces() { -- try { -- phonebookPage.touchSearchButton(); -- phonebookPage.enterSearchText("561"); -- assertEquals("Phonebook should have only 1 Entry" -- , 1, phonebookPage.getPhonebookEntriesSize()); -- phonebookPage.touchClearSearchTextButton(); -- } finally { -- phonebookPage.touchGoBackButton(); -- } -- } -- -- @Test -- public void testPhonebookFilterPhoneNumberEliminatesMinuses() { -- try { -- phonebookPage.touchSearchButton(); -- phonebookPage.enterSearchText("5662"); -- assertEquals("Phonebook should have only 1 Entry" -- , 1, phonebookPage.getPhonebookEntriesSize()); -- phonebookPage.touchClearSearchTextButton(); -- } finally { -- phonebookPage.touchGoBackButton(); -- } -- } -- -- @Test -- public void testPhonebookFilterPhoneNumberEliminatesSlashes() { -- try { -- phonebookPage.touchSearchButton(); -- phonebookPage.enterSearchText("77234"); -- assertEquals("Phonebook should have only 1 Entry" -- , 1, phonebookPage.getPhonebookEntriesSize()); -- phonebookPage.touchClearSearchTextButton(); -- } finally { -- phonebookPage.touchGoBackButton(); -- } -- } -- -- @Test -- public void testPhonebookFilterPhoneNumberEliminatesMultipleSlashesWhitespacesAndMinuses() { -- try { -- phonebookPage.touchSearchButton(); -- phonebookPage.enterSearchText("878223"); -- assertEquals("Phonebook should have only 1 Entry" -- , 1, phonebookPage.getPhonebookEntriesSize()); -- phonebookPage.touchClearSearchTextButton(); -- } finally { -- phonebookPage.touchGoBackButton(); -- } -- } -- -- @Test -- public void testPhonebookFilterPhoneNumberEliminatesBrackets() { -- try { -- phonebookPage.touchSearchButton(); -- phonebookPage.enterSearchText("342251"); -- assertEquals("Phonebook should have only 1 Entry" -- , 1, phonebookPage.getPhonebookEntriesSize()); -- phonebookPage.touchClearSearchTextButton(); -- } finally { -- phonebookPage.touchGoBackButton(); -- } -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/TrillianPhonebookTestUI.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/TrillianPhonebookTestUI.java -deleted file mode 100644 -index 6d60476..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/single/instance/TrillianPhonebookTestUI.java -+++ /dev/null -@@ -1,133 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test.single.instance; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.BookInfo; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.Contact; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.ContactType; --import ch.post.it.paisa.api.controlcenter.phonebook.v1.path.PAISAControlcenterPhonebookAPI; --import ch.post.it.paisa.trillian.test.TrillianTestRestHelper; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.LegacyTestUI; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNotification; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import ch.post.it.paisa.trillian.test.ui.pages.PhonebookPage; --import org.junit.*; --import org.junit.runners.MethodSorters; -- --import java.security.MessageDigest; --import java.security.NoSuchAlgorithmException; -- --import static ch.post.it.paisa.trillian.test.TestPaths.getHoustonBaseUrl; --import static ch.post.it.paisa.trillian.test.TrillianTestRestHelper.*; --import static org.junit.Assert.*; -- --@FixMethodOrder(MethodSorters.NAME_ASCENDING) --public class TrillianPhonebookTestUI extends LegacyTestUI { -- -- private OverviewPage overviewPage; -- -- @BeforeClass -- public static void reCreateTestPhonebook() throws NoSuchAlgorithmException { -- TrillianTestRestHelper.putSyncParametersToHouston(); -- TrillianTestRestHelper.publishDefaultAffiliation(DEFAULT_VEHICLE); -- TrillianTestRestHelper.publishCurrentPlanningArea(DEFAULT_PLANNING_AREA_ID); -- MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); -- BookInfo bookInfo = new BookInfo(); -- bookInfo.setName(DEFAULT_PHONEBOOK_NAME); -- bookInfo.setVersion("1"); -- final String bookInfoUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.info.RESOURCE -- .replace("{planningAreaId}", DEFAULT_PLANNING_AREA_ID.toString()) -- .replace("{bookId}", DEFAULT_PHONEBOOK_ID); -- -- for (int i = 1; i <= 100; i++) { -- Contact contact = new Contact(); -- contact.setType(ContactType.DRIVER); -- contact.setPhoneNumber(String.format("+41 99 %03d %02d %02d", i, (i + 1) % 100, (i + 2) % 100)); -- contact.setDescription(String.format("Vorname%d Nachname%d", i % 10, i / 10)); -- String contactId = TrillianTestRestHelper.generateContactId(contact.getDescription(), contact.getPhoneNumber(), messageDigest); -- -- final String contactUrl = getHoustonBaseUrl() + PAISAControlcenterPhonebookAPI.planningareas.planningAreaId$.books.bookId$.contacts.contactId$.RESOURCE -- .replace("{planningAreaId}", DEFAULT_PLANNING_AREA_ID.toString()) -- .replace("{bookId}", DEFAULT_PHONEBOOK_ID) -- .replace("{contactId}", contactId); -- RestHelper.put(contact, contactUrl); -- } -- RestHelper.put(bookInfo, bookInfoUrl); -- TrillianTestRestHelper.waitUntilPhonebooksSynced(100); -- } -- -- -- @AfterClass -- public static void deleteTestPhonebook() { -- TrillianTestRestHelper.deletePhonebook(DEFAULT_PHONEBOOK_ID); -- } -- -- @Ignore // FIXME ignored and opened ISABUFC-1483 -- @Test -- public void uc01_testDisplayFavourites() { -- overviewPage = factory.getOverviewPage(); -- overviewPage.touchGoToPhonebookButton(); -- factory.getPhonebookPage().touchGoBackButton(); -- -- assertNotNull(overviewPage.getFavouriteEntries()); -- assertTrue("Phonebook should be loaded for Selenium Test - No Entries available - check Houston Connection", -- overviewPage.getFavouriteEntries().size() > 0); -- overviewPage.touchInitiateCallFromFavourite(); -- cancelSlartiNotification(); -- } -- -- -- @Ignore // FIXME ignored and opened ISABUFC-1483 -- @Test -- public void uc03_testPlaceCallFromPhonebook() { -- overviewPage = factory.getOverviewPage(); -- overviewPage.touchGoToPhonebookButton(); -- final PhonebookPage phonebookPage = factory.getPhonebookPage(); -- phonebookPage.waitForTitle(); -- try { -- phonebookPage.placeCallOnPhonebookEntry(1); -- cancelSlartiNotification(); -- } finally { -- phonebookPage.touchGoBackButton(); -- } -- } -- -- -- /** -- * Tests that the label "there are more than 30 entries available" -- * disappears when the user is filtering the phonebook and there are -- * less than 30 entries found for the filtered text -- */ -- @Test -- public void uc04_testLabelThatShowsMoreThan30EntriesDisplaysDisappearsCorrectlyWhenFiltering() { -- selectPhonebookByName(DEFAULT_PHONEBOOK_NAME); -- overviewPage = factory.getOverviewPage(); -- overviewPage.touchGoToPhonebookButton(); -- final PhonebookPage phonebookPage = factory.getPhonebookPage(); -- phonebookPage.waitForTitle(); -- try { -- phonebookPage.touchSearchButton(); -- phonebookPage.enterSearchText("Vorname1"); -- assertFalse("Display label shall be hidden when the search filter results in less than 30 phonebook entries", -- phonebookPage.isDispayLimitedTextShown()); -- } finally { -- phonebookPage.touchGoBackButton(); -- } -- } -- -- private void cancelSlartiNotification() { -- seleniumHelper.switchToRoot(); // be on SLARTI IFrame -- final SlartiNotification notification = factory.getNotification(); -- notification.touchNotificationButtonCancel(); -- notification.waitForNotificationButtonCancelClose(); -- BaseTestTrillian.switchToFrame("module-Trillian"); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/AbstractSteps.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/AbstractSteps.java -deleted file mode 100644 -index 9cb8d7e..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/AbstractSteps.java -+++ /dev/null -@@ -1,247 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.slarti.test.ui.elements.DrivingScreen; --import ch.post.it.paisa.slarti.test.ui.elements.Login; --import ch.post.it.paisa.trillian.test.SeleniumContext; --import ch.post.it.paisa.trillian.test.e2e.TestHelper; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNavigation; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import io.cucumber.core.api.Scenario; --import io.cucumber.datatable.DataTable; --import org.openqa.selenium.By; --import org.openqa.selenium.JavascriptExecutor; --import org.openqa.selenium.StaleElementReferenceException; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.ui.WebDriverWait; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; -- --import java.time.Duration; --import java.util.ArrayList; --import java.util.List; --import java.util.Optional; -- -- --public abstract class AbstractSteps extends BaseTestTrillian { -- private static final Logger log = LoggerFactory.getLogger(AbstractSteps.class); -- protected static final int RETRY_COUNTER = 5; -- protected static final int RETRY_SLEEP_TIME = 2000; -- private static boolean initialized = false; -- -- -- protected void init(boolean stayOnLoginView) throws Throwable { -- if (initialized) { -- // we arrive here for every step file instantiation but need to initialize the driver only once -- return; -- } -- driver = SeleniumContext.getDriver(); -- factory = SeleniumContext.getTrillianSeleniumFactory(); -- seleniumHelper = SeleniumContext.getSeleniumHelper(); -- -- startUp(stayOnLoginView); -- -- initialized = true; -- } -- -- protected void cleanup(Scenario scenario) { -- if (initialized) { -- SeleniumContext.logIfFailed(scenario); -- initialized = false; -- log.info("scenario cleaned up"); -- } -- } -- -- -- protected OverviewPage navigateToAndGetTrillianOverviewPage() { -- final SlartiNavigation slartiNavigation = new SlartiNavigation(driver, seleniumHelper); -- slartiNavigation.touchTrillianModule(); -- BaseTestTrillian.switchToFrame("module-Trillian"); -- return factory.getOverviewPage(); -- } -- -- -- /** -- * @return List of Phonebook entry who show on UI -- */ -- protected List<PhonebookEntry> getPhonebookEntries() { -- waitUntilPhonebookEntriesPresent(); -- WebElement phonebookEntriesListElement = seleniumHelper.getWebElementById("phonebookEntries"); -- -- List<WebElement> phonebookEntriesListItemElements = phonebookEntriesListElement.findElements(By.tagName("li")); -- -- int count = 0; -- List<PhonebookEntry> results = new ArrayList<>(); -- for (WebElement phonebookEntriesListItemElement : phonebookEntriesListItemElements) { -- WebElement detailPanelElement = phonebookEntriesListItemElement.findElement(By.className("main")); -- //WebElement typeElement = detailPanelElement.findElement(By.id("type-" + count)); -- WebElement nameElement = detailPanelElement.findElement(By.id("name-" + count)); -- WebElement shiftNumberElement = detailPanelElement.findElement(By.id("shiftNumber-" + count)); -- WebElement lineNumberElement = detailPanelElement.findElement(By.id("lineNumber-" + count)); -- WebElement tripStopNameElement = detailPanelElement.findElement(By.id("tripStopName-" + count)); -- WebElement departureElement = detailPanelElement.findElement(By.id("departure-" + count)); -- WebElement directionTextElement = detailPanelElement.findElement(By.id("directionText-" + count)); -- WebElement phoneNumberElement = detailPanelElement.findElement(By.id("phoneNumber-" + count)); -- -- WebElement rightPanelElement = phonebookEntriesListItemElement.findElement(By.className("main-right")); -- WebElement vehicleIdElement = rightPanelElement.findElement(By.id("vehicleId-" + count)); -- WebElement licencePlateElement = rightPanelElement.findElement(By.id("licencePlate-" + count)); -- -- PhonebookEntry phonebookEntry = new PhonebookEntry(); -- // phonebookEntry.setType( typeElement.getText()); -- phonebookEntry.setName(nameElement.getText()); -- phonebookEntry.setTelephoneNumber(phoneNumberElement.getText()); -- phonebookEntry.setDeparture(departureElement.getText()); -- phonebookEntry.setDirectionText(directionTextElement.getText()); -- phonebookEntry.setLicencePlate(licencePlateElement.getText()); -- phonebookEntry.setLineNumber(lineNumberElement.getText()); -- phonebookEntry.setShiftNumber(shiftNumberElement.getText()); -- phonebookEntry.setTripStopName(tripStopNameElement.getText()); -- phonebookEntry.setVehicleId(vehicleIdElement.getText()); -- -- results.add(phonebookEntry); -- count = count + 1; -- } -- return results; -- } -- -- protected void waitUntilPhonebookEntriesPresent() { -- new WebDriverWait(driver, Duration.ofSeconds(10)) -- .ignoring(StaleElementReferenceException.class) -- .until(driver -> { -- List<WebElement> elements = seleniumHelper.getWebElementById("phonebookEntries").findElements(By.tagName("li")); -- if (elements.size() > 0) { -- // make sure element can be accessed -- elements.get(0).findElement(By.xpath("div[1]")); -- } -- return true; -- }); -- } -- -- -- protected List<ExpectedPhonebookData> getExpectedDataFromTable(DataTable dataTable) { -- List<List<String>> dataRows = dataTable.asLists(String.class); -- List<String> headerRow = dataRows.get(0); -- List<ExpectedPhonebookData> result = new ArrayList<>(); -- ExpectedPhonebookData headerIndexData = new ExpectedPhonebookData(); -- for (int i = 0; i < headerRow.size(); i++) { -- switch (headerRow.get(i)) { -- case ExpectedPhonebookData.TYPE_ENTRY_KEY: -- headerIndexData.typeColumnIndex = i; -- break; -- case ExpectedPhonebookData.NAME_ENTRY_KEY: -- headerIndexData.nameColumnIndex = i; -- break; -- case ExpectedPhonebookData.TELEPHONENUMBER_ENTRY_KEY: -- headerIndexData.telephoneNumberColumnIndex = i; -- break; -- case ExpectedPhonebookData.LINENUMBER_ENTRY_KEY: -- headerIndexData.lineNumberColumnIndex = i; -- break; -- case ExpectedPhonebookData.SHIFTNUMBER_ENTRY_KEY: -- headerIndexData.shiftNumberColumnIndex = i; -- break; -- case ExpectedPhonebookData.TRIPSTOPNAME_ENTRY_KEY: -- headerIndexData.stopNameColumnIndex = i; -- break; -- case ExpectedPhonebookData.DEPARTURE_ENTRY_KEY: -- headerIndexData.departureColumnIndex = i; -- break; -- case ExpectedPhonebookData.DIRECTIONTEXT_ENTRY_KEY: -- headerIndexData.directionTextColumnIndex = i; -- break; -- case ExpectedPhonebookData.VEHICLEID_ENTRY_KEY: -- headerIndexData.vehicleIdColumnIndex = i; -- break; -- case ExpectedPhonebookData.LICENCEPLATE_ENTRY_KEY: -- headerIndexData.licencePlateColumnIndex = i; -- break; -- case ExpectedPhonebookData.DESCRIPTION_ENTRY_KEY: -- headerIndexData.descriptionColumnIndex = i; -- break; -- default: -- throw new RuntimeException("Unknown key name: " + headerRow.get(i)); -- } -- } -- for (int i = 1; i < dataRows.size(); i++) { -- List<String> dataRow = dataRows.get(i); -- ExpectedPhonebookData expectedPhonebookData = new ExpectedPhonebookData(); -- for (int r = 0; r < dataRow.size(); r++) { -- if (headerIndexData.typeColumnIndex == r) { -- expectedPhonebookData.entryType = Optional.ofNullable(dataRow.get(r)); -- } else if (headerIndexData.nameColumnIndex == r) { -- expectedPhonebookData.entryName = Optional.ofNullable(dataRow.get(r)); -- } else if (headerIndexData.telephoneNumberColumnIndex == r) { -- expectedPhonebookData.entryTelephoneNumber = Optional.ofNullable(dataRow.get(r)); -- } else if (headerIndexData.lineNumberColumnIndex == r) { -- expectedPhonebookData.entryLineNumber = Optional.ofNullable(dataRow.get(r)); -- } else if (headerIndexData.shiftNumberColumnIndex == r) { -- expectedPhonebookData.entryShiftNumber = Optional.ofNullable(dataRow.get(r)); -- } else if (headerIndexData.stopNameColumnIndex == r) { -- expectedPhonebookData.entryTripStopName = Optional.ofNullable(dataRow.get(r)); -- } else if (headerIndexData.departureColumnIndex == r) { -- expectedPhonebookData.entryDeparture = Optional.ofNullable(dataRow.get(r)); -- } else if (headerIndexData.directionTextColumnIndex == r) { -- expectedPhonebookData.entryDirectionText = Optional.ofNullable(dataRow.get(r)); -- } else if (headerIndexData.vehicleIdColumnIndex == r) { -- expectedPhonebookData.entryVehicleId = Optional.ofNullable(dataRow.get(r)); -- } else if (headerIndexData.licencePlateColumnIndex == r) { -- expectedPhonebookData.entryLicencePlate = Optional.ofNullable(dataRow.get(r)); -- } else if (headerIndexData.descriptionColumnIndex == r) { -- expectedPhonebookData.entryDescription = Optional.ofNullable(dataRow.get(r)); -- } -- } -- result.add(expectedPhonebookData); -- } -- return result; -- } -- -- /** -- * Open the start page of the specific vehicle. -- */ -- protected static void openSlartiStartPage(String vehicleId) { -- String baseUrl = TestHelper.getEagleBaseUrlFromVehicleId(vehicleId); -- String slartiUrl = baseUrl + "/services" + StartGUI.SLARTI_INDEX_HTML + StartGUI.DEV_MODE_PARAM; -- -- StartGUI.waitForTrillianToBeRunning(slartiUrl); -- driver.get(slartiUrl); -- -- // wait until the splash screen is gone (copied from Slarti) -- SeleniumHelper.retryTill(o -> !seleniumHelper.switchToRootAndIsWebElementExistentAndDisplayedByXpath("//*[@id=\"splash\"]"), 20, 500); -- } -- -- protected void login(String givenName, String surname, String vehicleId) { -- String legicId = TestHelper.getUserCardIdByFullName(givenName, surname); -- String pin = TestHelper.getUserPinByFullName(givenName, surname); -- -- openSlartiStartPage(vehicleId); -- -- final Login login = new Login(seleniumHelper); -- try { -- ((JavascriptExecutor) driver).executeScript("localStorage.clear()"); -- } catch (Exception e) { -- log.warn("localStorage.clear() seems failed, just continue.", e); -- } -- // Login with driver card -- login.waitForAccountBadgeView(); -- TestHelper.badgeWithLegicId(legicId, vehicleId); -- // Login for cash register (e.g. with driver card or with team card) -- login.waitForWalletBadgeView(); -- TestHelper.badgeWithLegicId(legicId, vehicleId); -- login.touchLoginButton(); -- -- goToTourtripHomeFromDrivingScreen(); -- -- LegacyTestUI.openTrillianModule(); -- } -- -- protected void openTheSlartiStartPageOnVehicle(String vehicleId, boolean stayOnDrivingScreen) { -- openSlartiStartPage(vehicleId); -- if (stayOnDrivingScreen) { -- DrivingScreen drivingScreen = new DrivingScreen(seleniumHelper); -- SeleniumHelper.retryTill(o -> drivingScreen.isDrivingScreenActive()); -- } else { -- goToTourtripHomeFromDrivingScreen(); -- } -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/BasePhoneCallTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/BasePhoneCallTest.java -deleted file mode 100644 -index 42578a1..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/BasePhoneCallTest.java -+++ /dev/null -@@ -1,22 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui; -- --import ch.post.it.paisa.trillian.test.TrillianTestRestHelper; --import org.junit.After; -- --import static ch.post.it.paisa.trillian.test.TrillianTestRestHelper.triggerEvent; -- --/** -- * Class BasePhoneCallTest. -- */ --public abstract class BasePhoneCallTest extends LegacyTestUI { -- @After -- public void afterPhoneTestCleanup() { -- triggerEvent(TrillianTestRestHelper.GsmEvent.NO_CARRIER); // NO_CARRIER means other party hanged up -- TrillianTestRestHelper.clearCallLog(); -- } -- -- protected void setupPhoneCallTest() { -- seleniumHelper.switchToRoot(); // be on SLARTI IFrame -- TrillianTestRestHelper.clearCallLog(); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/BaseTestTrillian.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/BaseTestTrillian.java -deleted file mode 100644 -index 9952818..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/BaseTestTrillian.java -+++ /dev/null -@@ -1,210 +0,0 @@ -- --package ch.post.it.paisa.trillian.test.ui; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.slarti.test.ui.elements.DrivingScreen; --import ch.post.it.paisa.slarti.test.ui.elements.Login; --import ch.post.it.paisa.trillian.process.user.information.LanguageService; --import ch.post.it.paisa.trillian.test.TrillianTestRestHelper; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNavigation; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import com.google.common.base.Stopwatch; --import org.junit.Assert; --import org.junit.Rule; --import org.junit.rules.TestName; --import org.junit.rules.TestWatcher; --import org.junit.runner.Description; --import org.junit.runners.model.Statement; --import org.openqa.selenium.*; --import org.openqa.selenium.support.ui.ExpectedConditions; --import org.openqa.selenium.support.ui.FluentWait; --import org.openqa.selenium.support.ui.Wait; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; --import org.springframework.context.support.ResourceBundleMessageSource; -- --import java.time.Duration; --import java.util.concurrent.TimeUnit; -- --import static ch.post.it.paisa.trillian.test.TrillianTestRestHelper.triggerEvent; -- --public abstract class BaseTestTrillian extends ControllerTest { -- private static final Logger LOG = LoggerFactory.getLogger(BaseTestTrillian.class); -- -- protected static WebDriver driver; -- protected static TrillianSeleniumFactory factory; -- protected static SeleniumHelper seleniumHelper; -- -- @Rule -- public TestName testName = new TestName(); -- @Rule -- public TestWatcher screenshotRule = new TestWatcher() { -- @Override -- public Statement apply(Statement base, Description description) { -- return new CatchExceptionsStatement(base); -- } -- -- @Override -- protected void failed(Throwable e, Description description) { -- if (seleniumHelper != null) { -- try { -- seleniumHelper.handleException(e); -- } catch (Throwable t) { -- t.printStackTrace(); -- } -- } -- } -- -- class CatchExceptionsStatement extends Statement { -- private final Statement fNext; -- -- CatchExceptionsStatement(Statement base) { -- fNext = base; -- } -- -- @Override -- public void evaluate() throws Throwable { -- try { -- fNext.evaluate(); -- } catch (Throwable e) { -- seleniumHelper.handleException(e); -- throw e; -- } -- } -- } -- }; -- private Stopwatch stopwatch; -- -- public static void goToTourtripHomeFromDrivingScreen() { -- // ISABUFC-1498 click a button on the driving screen to close it -- DrivingScreen drivingScreen = new DrivingScreen(seleniumHelper); -- SeleniumHelper.retryTill(o -> drivingScreen.isDrivingScreenActive()); -- drivingScreen.touchTourtripButton(); -- drivingScreen.waitForDrivingScreenToDeactivate(); -- } -- -- public static void openTrillianModule() { -- final SlartiNavigation navigation = new SlartiNavigation(driver, seleniumHelper); -- navigation.touchTrillianModule(); -- switchToFrame("module-Trillian"); -- final OverviewPage s = new OverviewPage(driver, seleniumHelper); -- s.waitForTitle(); -- } -- -- public static void skipLogin() { -- LOG.info("starting skipLogin()"); -- final Login login = new Login(seleniumHelper); -- if (login.isLoginActive()) { -- LOG.info("login.isLoginActive()"); -- LOG.info("clearing localStorage"); -- ((JavascriptExecutor) driver).executeScript("localStorage.clear()"); -- LOG.info("clicking skipLogin button"); -- login.touchSkipLogin(); -- login.waitForLoginToDisappear(); -- goToTourtripHomeFromDrivingScreen(); -- login.switchToRoot(); -- } else { -- goToTourtripHomeFromDrivingScreen(); -- } -- } -- -- private static void legicLogin() { -- LOG.info("starting legicLogin()"); -- final Login login = new Login(seleniumHelper); -- if (login.isLoginActive()) { -- LOG.info("login.isLoginActive()"); -- LOG.info("clearing localStorage"); -- ((JavascriptExecutor) driver).executeScript("localStorage.clear()"); -- -- LOG.info("clicking legicLogin button"); -- login.touchManualLegicMainButton(); -- -- final String legicId = System.getProperty("legicID"); -- LOG.info("write legic id number {}", legicId); -- login.setManualLegicId(legicId); -- -- LOG.info("clicking login button"); -- login.touchLoginButton(); -- login.switchToRoot(); -- } else { -- LOG.info("either login is not active or the legic button is not displayed, continuing as usual"); -- } -- } -- -- public final void startUp(boolean stayOnLoginView) throws Throwable { -- stopwatch = Stopwatch.createStarted(); -- seleniumHelper.methodLogStart(testName.getMethodName()); -- loadStartPage(stayOnLoginView); -- waitForApplicationToBeStarted(); -- } -- -- private void waitForApplicationToBeStarted() { -- final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); -- messageSource.setBasename("resources/messages"); -- final LanguageService languageService = new LanguageService(messageSource); -- LOG.info("Trillian Module on OverviewPage"); -- } -- -- private void loadStartPage(boolean stayOnLoginView) { -- // TrillianTestRestHelper.setLanguageDefault(); -- final StartGUI startGUI = new StartGUI(driver); -- startGUI.openStartPage(); -- if (!stayOnLoginView) { -- if (Boolean.valueOf(System.getProperty("skipLogin", "true"))) { -- skipLogin(); -- } else { -- // check properties available -- Assert.assertNotNull("If skiplogin is false, the PIN number must be set as programm argument like '-DPIN=111111'", System.getProperty("PIN")); -- Assert.assertNotNull("If skiplogin is false, the legicId number must be set as programm argument like '-DlegicID=111111'", System.getProperty("legicID")); -- legicLogin(); -- } -- -- openTrillianModule(); -- } -- -- triggerEvent(TrillianTestRestHelper.GsmEvent.NO_CARRIER); // NO_CARRIER means other party hanged up -- } -- -- public void tearDown() { -- seleniumHelper.methodLogEnd(testName.getMethodName(), stopwatch.elapsed(TimeUnit.MILLISECONDS)); -- } -- -- protected void wait(final int timeout) { -- seleniumHelper.sleep(timeout); -- } -- -- public static Wait<WebDriver> getWait() { -- return new FluentWait<>(driver) -- .withTimeout(Duration.ofSeconds(20)) -- .pollingEvery(Duration.ofMillis(200)) -- .ignoring(NoSuchElementException.class) -- .ignoring(StaleElementReferenceException.class); -- } -- -- public static void waitForElement(WebElement element) { -- getWait().until(ExpectedConditions.elementToBeClickable(element)); -- } -- -- public static void switchToFrame(String frameId) { -- LOG.info("SeleniumContext: Switching to frame '" + frameId + "'."); -- seleniumHelper.switchToRoot(); -- String frameIdXPath = "//*[@id=\"" + frameId + "\"]"; -- getWait().until(driver -> driver.findElements(By.xpath(frameIdXPath)).size() == 1); -- seleniumHelper.switchToFrameByXpath("//*[@id=\"" + frameId + "\"]"); -- LOG.info("switchToFrame: END. Done."); -- } -- -- public static void waitAndClickById(String id) { -- seleniumHelper.waitTillClickable(By.id(id)); -- seleniumHelper.getWebElementById(id).click(); -- } -- -- public static void waitAndSendKeysById(String id, String keys) { -- seleniumHelper.waitTillClickable(By.id(id)); -- seleniumHelper.getWebElementById(id).sendKeys(keys); -- } -- public static void waitAndTouchByWebElement(String id) { -- seleniumHelper.waitTillClickable(By.id(id)); -- seleniumHelper.touchByWebElement(driver.findElement(By.id(id))); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/ControllerTest.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/ControllerTest.java -deleted file mode 100644 -index 46f50e7..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/ControllerTest.java -+++ /dev/null -@@ -1,126 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui; -- --import ch.post.it.paisa.alice.service.domain.core.json.ExtendedObjectMapper; --import com.fasterxml.jackson.databind.JsonNode; --import io.restassured.RestAssured; --import io.restassured.response.Response; --import org.apache.http.HttpStatus; --import org.junit.Assert; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; -- --import java.nio.charset.StandardCharsets; --import java.util.HashMap; --import java.util.List; --import java.util.Map; --import java.util.stream.Collectors; -- --import static ch.post.it.paisa.trillian.test.TestPaths.getEagle1BaseUrl; --import static ch.post.it.paisa.trillian.test.TestPaths.getHoustonBaseUrl; --import static com.jayway.awaitility.Awaitility.given; --import static com.jayway.awaitility.Duration.TEN_SECONDS; --import static java.util.Collections.emptyList; -- --public class ControllerTest { -- -- private static final Logger LOG = LoggerFactory.getLogger(ControllerTest.class); -- private static final ExtendedObjectMapper OBJECT_MAPPER = new ExtendedObjectMapper(); -- -- protected static void putObjectWithVehicledIdInHeader(Object object, String url, String vehicleId, final Object... uriVariables) { -- url = getHoustonBaseUrl() + url; -- LOG.info("PUT {}", url); -- RestAssured.given().contentType("application/json").given().header("x-vehicleid", vehicleId). -- body(toJsonNode(object).toString().getBytes(StandardCharsets.UTF_8)).put(url, uriVariables). -- then().assertThat().statusCode(HttpStatus.SC_OK); -- } -- -- protected static void put(Object object, String url, final Object... uriVariables) { -- url = getHoustonBaseUrl() + url; -- LOG.info("PUT {}", url); -- -- if (object instanceof String) { -- RestAssured.given().contentType("application/json").given(). -- body(((String) object).getBytes(StandardCharsets.UTF_8)).put(url, uriVariables). -- then().assertThat().statusCode(HttpStatus.SC_OK); -- -- } else { -- RestAssured.given().contentType("application/json").given(). -- body(toJsonNode(object).toString().getBytes(StandardCharsets.UTF_8)).put(url, uriVariables). -- then().assertThat().statusCode(HttpStatus.SC_OK); -- } -- } -- -- protected static Response get(String url) { -- url = getHoustonBaseUrl() + url; -- LOG.info("GET {}", url); -- return RestAssured.get(url); -- } -- -- protected static Response getFromEagle1(String url) { -- url = getEagle1BaseUrl() + url; -- LOG.info("GET {}", url); -- return RestAssured.get(url); -- } -- -- protected final List<String> getIds(final String url, final Object... uriVariables) { -- Response response = RestAssured.get(url, uriVariables); -- if (response.getStatusCode() == HttpStatus.SC_NOT_FOUND) { -- return emptyList(); -- } -- -- Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode()); -- -- @SuppressWarnings("unchecked") final Map<String, List<String>> idMap = response.getBody().as(HashMap.class); -- if (idMap.values().isEmpty()) { -- return emptyList(); -- } -- List<String> results = idMap -- .values() -- .iterator() -- .next() -- .stream() -- .filter(v -> !"empty".equals(v)) -- .map(v -> v.endsWith("/") ? v.substring(0, v.length() - 1) : v) -- .collect(Collectors.toList()); -- -- LOG.info("GET {}, Ids: {}", url, String.join(",", results)); -- return results; -- } -- -- -- protected static void delete(String url, Object... uriVariables) { -- LOG.info("DEL {}", url); -- Response response = RestAssured.given().delete(url, uriVariables); -- Assert.assertEquals(response.getStatusCode(), HttpStatus.SC_OK); -- } -- -- public static void ensurePresent(String url, Object... uriVariables) { -- given().await().atMost(TEN_SECONDS).until(() -> RestAssured.get(url, uriVariables).then().extract().statusCode() == HttpStatus.SC_OK); -- } -- -- public static void ensureNotFound(String url, Object... uriVariables) { -- LOG.info("ensureNotFound {}", url); -- given().await().atMost(TEN_SECONDS).until(() -> RestAssured.get(url, uriVariables).then().extract().statusCode() == HttpStatus.SC_NOT_FOUND); -- } -- -- private static JsonNode toJsonNode(Object object) { -- return OBJECT_MAPPER.convertValue(object, JsonNode.class); -- } -- -- public static void deleteAllChildren(String url) { -- if (url.endsWith("/")) { -- url = url.substring(0, url.length() - 1); -- } -- final String name = url.substring(url.lastIndexOf('/') + 1); -- final Response response = get(url); -- if (response.statusCode() == HttpStatus.SC_OK) { -- final List<String> children = response.jsonPath().getList(name); -- for (String child : children) { -- if (child.endsWith("/")) { -- child = child.substring(0, child.length() - 1); -- } -- delete(url + "/" + child); -- } -- } -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/ExpectedPhonebookData.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/ExpectedPhonebookData.java -deleted file mode 100644 -index 45c78ab..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/ExpectedPhonebookData.java -+++ /dev/null -@@ -1,82 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui; -- -- --import java.util.Optional; -- --public class ExpectedPhonebookData { -- public static final String TYPE_ENTRY_KEY = "=Type="; -- public static final String NAME_ENTRY_KEY = "=Name="; -- public static final String TELEPHONENUMBER_ENTRY_KEY = "=Phone Number="; -- public static final String LINENUMBER_ENTRY_KEY = "=Line Number="; -- public static final String SHIFTNUMBER_ENTRY_KEY = "=Shift Number="; -- public static final String TRIPSTOPNAME_ENTRY_KEY = "=Trip Stop Name="; -- public static final String DEPARTURE_ENTRY_KEY = "=Departure="; -- public static final String DIRECTIONTEXT_ENTRY_KEY = "=Direction Text="; -- public static final String VEHICLEID_ENTRY_KEY = "=Vehicle Id="; -- public static final String LICENCEPLATE_ENTRY_KEY = "=License Plate="; -- public static final String DESCRIPTION_ENTRY_KEY = "=Description="; -- -- public int typeColumnIndex = -1; -- public int nameColumnIndex = -1; -- public int telephoneNumberColumnIndex = -1; -- public int lineNumberColumnIndex = -1; -- public int shiftNumberColumnIndex = -1; -- public int stopNameColumnIndex = -1; -- public int departureColumnIndex = -1; -- public int directionTextColumnIndex = -1; -- public int vehicleIdColumnIndex = -1; -- public int licencePlateColumnIndex = -1; -- public int descriptionColumnIndex = -1; -- -- public Optional<String> entryType = Optional.empty(); -- public Optional<String> entryName = Optional.empty(); -- public Optional<String> entryTelephoneNumber = Optional.empty(); -- public Optional<String> entryLineNumber = Optional.empty(); -- public Optional<String> entryShiftNumber = Optional.empty(); -- public Optional<String> entryTripStopName = Optional.empty(); -- public Optional<String> entryDeparture = Optional.empty(); -- public Optional<String> entryDirectionText = Optional.empty(); -- public Optional<String> entryVehicleId = Optional.empty(); -- public Optional<String> entryLicencePlate = Optional.empty(); -- public Optional<String> entryDescription = Optional.empty(); -- -- @Override -- public String toString() { -- StringBuilder builder = new StringBuilder(); -- if (entryType.isPresent()) { -- builder.append("Type: " + entryType.get() + ", "); -- } -- if (entryName.isPresent()) { -- builder.append("Name: " + entryName.get() + ", "); -- } -- if (entryTelephoneNumber.isPresent()) { -- builder.append("TelephoneNumber: " + entryTelephoneNumber.get() + ", "); -- } -- if (entryLineNumber.isPresent()) { -- builder.append("LineNumber: " + entryLineNumber.get() + ", "); -- } -- if (entryShiftNumber.isPresent()) { -- builder.append("ShiftNumber: " + entryShiftNumber.get() + ", "); -- } -- if (entryTripStopName.isPresent()) { -- builder.append("TripStopName: " + entryTripStopName.get() + ", "); -- } -- if (entryDeparture.isPresent()) { -- builder.append("Departure: " + entryDeparture.get() + ", "); -- } -- if (entryDirectionText.isPresent()) { -- builder.append("DirectionText: " + entryDirectionText.get() + ", "); -- } -- if (entryVehicleId.isPresent()) { -- builder.append("VehicleId: " + entryVehicleId.get() + ", "); -- } -- if (entryLicencePlate.isPresent()) { -- builder.append("LicencePlate: " + entryLicencePlate.get() + ", "); -- } -- if (entryDescription.isPresent()) { -- builder.append("Description: " + entryDescription.get() + ", "); -- } -- -- return builder.toString(); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/LegacyTestUI.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/LegacyTestUI.java -deleted file mode 100644 -index 99edafb..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/LegacyTestUI.java -+++ /dev/null -@@ -1,90 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui; -- --import ch.post.it.paisa.alice.service.test.core.rest.RestHelper; --import ch.post.it.paisa.api.communication.modem.v1.CallState; --import ch.post.it.paisa.api.communication.modem.v1.Direction; --import ch.post.it.paisa.api.communication.modem.v1.State; --import ch.post.it.paisa.api.communication.modem.v1.path.CommunicationModemAPI; --import ch.post.it.paisa.trillian.test.SeleniumContext; --import ch.post.it.paisa.trillian.test.TestPaths; --import ch.post.it.paisa.trillian.test.TrillianTestRestHelper; --import ch.post.it.paisa.trillian.test.e2e.TestHelper; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNavigation; --import ch.post.it.paisa.trillian.test.ui.mock.MockInstances; --import org.joda.time.DateTime; --import org.junit.After; --import org.junit.Before; --import org.junit.BeforeClass; --import org.openqa.selenium.By; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.ui.ExpectedConditions; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; -- --import static ch.post.it.paisa.trillian.test.TestPaths.getEagle1BaseUrl; --import static com.jayway.awaitility.Awaitility.given; --import static com.jayway.awaitility.Duration.TEN_SECONDS; --import static junit.framework.TestCase.assertFalse; -- -- --public abstract class LegacyTestUI extends BaseTestTrillian { -- private static final Logger LOG = LoggerFactory.getLogger(LegacyTestUI.class); -- -- @BeforeClass -- public static void setUp() { -- TestHelper.setupLegacyTests(); -- -- LOG.info("creating a new WebDriver ..."); -- seleniumHelper = SeleniumContext.getSeleniumHelper(); -- driver = SeleniumContext.getDriver(); -- factory = new TrillianSeleniumFactory(driver, seleniumHelper); -- } -- -- @Before -- public final void setUpTest() throws Throwable { -- MockInstances.getHouston().reset(); -- MockInstances.resetAllEagles(); -- putCallState(Direction.NONE, State.NONE); -- RestHelper.post(null, getEagle1BaseUrl() + CommunicationModemAPI.call.control.hangup.RESOURCE); -- TrillianTestRestHelper.deleteActiveCall(); -- given().await().atMost(TEN_SECONDS).until(() -> assertFalse(TrillianTestRestHelper.isCallStatusActive())); -- startUp(false); -- } -- -- @After -- public void tearDownTest() { -- tearDown(); -- } -- -- protected void putCallState(Direction direction, State state) { -- CallState call = new CallState(); -- call.setDirection(direction); -- call.setPhoneNumber("+4176xxxxxxxx"); -- call.setState(state); -- call.setTimestamp(new DateTime()); -- // Put the resource -- RestHelper.put(call, TestPaths.getEagle1BaseUrl() + CommunicationModemAPI.call.state.RESOURCE); -- } -- -- protected void selectPhonebookByName(String phonebookName) { -- -- // Note: This is copied from step files and thus results in code redundancy. We should rewrite the Legacy tests to Cuke to solve this -- -- // navigate to the phonebook selection page -- final SlartiNavigation slartiNavigation = new SlartiNavigation(driver, seleniumHelper); -- slartiNavigation.touchTrillianSideMenuByXpathStringSelector("shortcutmenu-Communication", "shortcutmenu-PhonebookSelection"); -- BaseTestTrillian.switchToFrame("module-Trillian"); -- WebElement element = BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(By.id("menu_phonebook_selection"))); -- element.click(); -- -- // select a phonebook -- WebElement buttonElement = seleniumHelper.getWebElement("//button/span[contains(text(),'" + phonebookName + "')]/.."); -- if (!buttonElement.getAttribute("class").contains("active")) { -- buttonElement.click(); -- } -- -- slartiNavigation.touchTrillianModule(); -- -- BaseTestTrillian.switchToFrame("module-Trillian"); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/PhonebookEntry.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/PhonebookEntry.java -deleted file mode 100644 -index df7e5c8..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/PhonebookEntry.java -+++ /dev/null -@@ -1,114 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui; -- --public class PhonebookEntry { -- -- private String type; -- -- private String name; -- -- private String telephoneNumber; -- -- private String lineNumber; -- -- private String shiftNumber; -- -- private String tripStopName; -- -- private String departure; -- -- private String directionText; -- -- private String vehicleId; -- -- private String licencePlate; -- -- private String description; -- -- public String getName() { -- return name; -- } -- -- public void setName(String name) { -- this.name = name; -- } -- -- public String getTelephoneNumber() { -- return telephoneNumber; -- } -- -- public void setTelephoneNumber(String telephoneNumber) { -- this.telephoneNumber = telephoneNumber; -- } -- -- public String getLineNumber() { -- return lineNumber; -- } -- -- public void setLineNumber(String lineNumber) { -- this.lineNumber = lineNumber; -- } -- -- public String getShiftNumber() { -- return shiftNumber; -- } -- -- public void setShiftNumber(String shiftNumber) { -- this.shiftNumber = shiftNumber; -- } -- -- public String getTripStopName() { -- return tripStopName; -- } -- -- public void setTripStopName(String tripStopName) { -- this.tripStopName = tripStopName; -- } -- -- public String getDeparture() { -- return departure; -- } -- -- public void setDeparture(String departure) { -- this.departure = departure; -- } -- -- public String getDirectionText() { -- return directionText; -- } -- -- public void setDirectionText(String directionText) { -- this.directionText = directionText; -- } -- -- public String getVehicleId() { -- return vehicleId; -- } -- -- public void setVehicleId(String vehicleId) { -- this.vehicleId = vehicleId; -- } -- -- public String getLicencePlate() { -- return licencePlate; -- } -- -- public void setLicencePlate(String licencePlate) { -- this.licencePlate = licencePlate; -- } -- -- public String getType() { -- return type; -- } -- -- public void setType(String type) { -- this.type = type; -- } -- -- public String getDescription() { -- return description; -- } -- -- public void setDescription(String description) { -- this.description = description; -- } --} -\ No newline at end of file -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/StartGUI.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/StartGUI.java -deleted file mode 100644 -index c88c6b6..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/StartGUI.java -+++ /dev/null -@@ -1,97 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test.ui; -- --import io.restassured.response.Response; --import org.openqa.selenium.WebDriver; -- --import java.util.logging.Logger; -- --import static ch.post.it.paisa.trillian.test.TestPaths.SLARTI_1_START_PAGE; --import static io.restassured.RestAssured.get; -- --/** -- * This class opens the browser with the start page. -- * -- * @author iselisa -- * changes by roggerj -- */ --public class StartGUI { -- private static final Logger LOG = Logger.getLogger(StartGUI.class.getName()); -- public final static String DEV_MODE_PARAM = "?devMode=true"; -- public static final String SLARTI_INDEX_HTML = "/slarti/index.html"; -- private static final String TRILLIAN_INFO_URL = "/trillian/info"; -- private static final String TRILLIAN_INDEX_HTML = "/trillian/index.html"; -- private WebDriver driver; -- -- private static boolean openedInSlarti = true; -- -- StartGUI(WebDriver driver) { -- this.driver = driver; -- } -- -- /** -- * in case no url is set, the default one will be used -- */ -- void openStartPage() { -- String baseUrl = SLARTI_1_START_PAGE; -- waitForTrillianToBeRunning(baseUrl); -- driver.get(baseUrl + DEV_MODE_PARAM); -- } -- -- public static boolean isOpenedInSlarti() { -- return openedInSlarti; -- } -- -- public static void setOpenedInSlarti(boolean openedInSlarti) { -- StartGUI.openedInSlarti = openedInSlarti; -- } -- -- /** -- * in case no url is set, the default one will be used -- */ -- public void openPage(String baseUrl) { -- waitForTrillianToBeRunning(baseUrl); -- driver.get(baseUrl + DEV_MODE_PARAM); -- } -- -- public static void waitForTrillianToBeRunning(String baseUrl) { -- // before loading the page, we check if we can get the info resource of the application, otherwise we don't need to try starting it -- String infoUrl = null; -- if (baseUrl.contains(SLARTI_INDEX_HTML)) { -- int endIndex = baseUrl.indexOf(SLARTI_INDEX_HTML); -- infoUrl = baseUrl.substring(0, endIndex) + TRILLIAN_INFO_URL; -- } else if (baseUrl.contains(TRILLIAN_INDEX_HTML)) { -- int endIndex = baseUrl.indexOf(TRILLIAN_INDEX_HTML); -- infoUrl = baseUrl.substring(0, endIndex) + TRILLIAN_INFO_URL; -- } -- if (infoUrl != null) { -- boolean infoLoaded = false; -- long start = System.currentTimeMillis(); -- long timeoutMs = 4 * 60 * 1000; // 4 minutes -- while (!infoLoaded) { -- LOG.info("Trying to load trillian info page (max " + timeoutMs + " ms)"); -- Response response = get(infoUrl); -- if (response.getStatusCode() == 200) { -- LOG.info("Trillian is running. Application info: " + response.asString()); -- infoLoaded = true; -- } else { -- LOG.info("Response code for trillian info page (" + infoUrl + ") is " + response.getStatusCode()); -- } -- -- // stop after some time... -- if (System.currentTimeMillis() > start + timeoutMs) { -- break; -- } -- } -- } else { -- LOG.warning("Could not get /trillian/info to check if the application is running because the URL is unknown (" + baseUrl + ")"); -- } -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/TextFixtures.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/TextFixtures.java -deleted file mode 100644 -index 9395c20..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/TextFixtures.java -+++ /dev/null -@@ -1,75 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui; -- --import ch.post.it.paisa.api.logloc.v1.TripStopId; --import ch.post.it.paisa.api.timetable.common.v1.TripInstance; --import ch.post.it.paisa.api.timetable.common.v1.TripInstanceTimetableType; --import ch.post.it.paisa.api.timetable.common.v1.TripStop; --import ch.post.it.paisa.api.logloc.v1.Halt; --import ch.post.it.paisa.api.logloc.v1.TripPosition; -- --import ch.post.it.paisa.api.timetable.registration.v1.TripInitialization; --import org.joda.time.DateTime; --import org.joda.time.LocalDate; -- --import java.util.ArrayList; --import java.util.List; -- --public class TextFixtures { -- -- public static TripInitialization tripInitialization() { -- return tripInitialization(tripInstance()); -- } -- -- public static TripInitialization tripInitialization(TripInstance tripInstance) { -- return new TripInitialization(). -- withTimestamp(DateTime.now()). -- withTripInstanceId(tripInstance.getId()). -- withTripInstance(tripInstance); -- } -- -- public static TripInstance tripInstance() { -- return new TripInstance(). -- withId("tripInstance-1"). -- withBlockNumber("blockNumber-1"). -- withTimetableType(TripInstanceTimetableType.PLANNED). -- withLineNumber("336"). -- withTripStops(tripStops()). -- withOperatingDay(LocalDate.now()); -- } -- -- public static List<TripStop> tripStops() { -- ArrayList<TripStop> stops = new ArrayList<>(); -- DateTime now = DateTime.now(); -- stops.add(new TripStop().withStopId("1").withStoppingPointId("1").withName("StopName1").withArrival(now.plusMinutes(1)).withDeparture(now.plusMinutes(2))); -- stops.add(new TripStop().withStopId("2").withStoppingPointId("2").withName("StopName2").withArrival(now.plusMinutes(3)).withDeparture(now.plusMinutes(4))); -- stops.add(new TripStop().withStopId("3").withStoppingPointId("3").withName("StopName3").withArrival(now.plusMinutes(5)).withDeparture(now.plusMinutes(6))); -- stops.add(new TripStop().withStopId("4").withStoppingPointId("4").withName("StopName4").withArrival(now.plusMinutes(7)).withDeparture(now.plusMinutes(8))); -- return stops; -- } -- -- public static TripPosition tripPosition() { -- TripInstance tripInstance = tripInstance(); -- return tripPosition(2, tripInstance); -- } -- -- public static TripPosition tripPosition(int currentSequenceNr, TripInstance tripInstance) { -- List<TripStop> tripStops = tripInstance.getTripStops(); -- int tripStopIndex = currentSequenceNr - 1; // sequenceNumbers in PAISA APIs start with 1 -- return new TripPosition() -- .withTimestamp(DateTime.now()) -- .withPrevious(halt(currentSequenceNr - 1, tripStops.get(currentSequenceNr - 2), tripInstance.getId())) -- .withCurrent(halt(currentSequenceNr, tripStops.get(currentSequenceNr -1), tripInstance.getId())) -- .withNext(halt(currentSequenceNr + 1, tripStops.get(currentSequenceNr), tripInstance.getId())); -- } -- -- private static Halt halt(int sequenceNr, TripStop tripStop, String tripInstanceId) { -- return new Halt() -- .withSequenceNumber(sequenceNr) -- .withTripStopId(new TripStopId() -- .withStopId(tripStop.getStopId()) -- .withTripId(tripInstanceId) -- .withStoppingPointId(tripStop.getStoppingPointId()) -- .withArrival(tripStop.getArrival()) -- .withDeparture(tripStop.getDeparture())); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/TrillianSeleniumFactory.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/TrillianSeleniumFactory.java -deleted file mode 100644 -index 6f9347d..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/TrillianSeleniumFactory.java -+++ /dev/null -@@ -1,110 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test.ui; -- -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumFactory; --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.slarti.test.ui.elements.Keyboard; --import ch.post.it.paisa.trillian.test.ui.elements.DialPad; --import ch.post.it.paisa.trillian.test.ui.elements.KeypadDialog; --import ch.post.it.paisa.trillian.test.ui.elements.SlartiNotification; --import ch.post.it.paisa.trillian.test.ui.pages.CallLogPage; --import ch.post.it.paisa.trillian.test.ui.pages.MessagingPage; --import ch.post.it.paisa.trillian.test.ui.pages.OverviewPage; --import ch.post.it.paisa.trillian.test.ui.pages.PhonebookPage; --import org.openqa.selenium.WebDriver; -- --/** -- * Class SeleniumFactory. -- * This provides all GUI elements for testing. -- * -- * @author iselisa -- * @version $$Revision: 1429 $$ -- * @see <script>links('$$HeadURL: https://repository.pnet.ch/svn/reposdev-paisa/04_Implementation/services/slarti/trunk/slarti-test/src/main/java/ch/post/it/paisa/slarti/test/ui/base/SeleniumFactory.java $$');</script> -- */ --public class TrillianSeleniumFactory extends SeleniumFactory { -- private SeleniumHelper seleniumHelper; -- private WebDriver driver; -- -- private OverviewPage overviewPage; -- private PhonebookPage phonebookPage; -- private MessagingPage messagingPag; -- private Keyboard keyboard; -- private SlartiNotification slartiNotification; -- private CallLogPage callLog; -- private KeypadDialog keypadDialog; -- private DialPad dialPad; -- -- -- public TrillianSeleniumFactory(WebDriver driver, SeleniumHelper seleniumHelper) { -- super(seleniumHelper); -- this.driver = driver; -- this.seleniumHelper = seleniumHelper; -- } -- -- public OverviewPage getOverviewPage() { -- if (overviewPage == null) { -- overviewPage = new OverviewPage(driver, seleniumHelper); -- } -- return overviewPage; -- } -- -- public PhonebookPage getPhonebookPage() { -- if (phonebookPage == null) { -- phonebookPage = new PhonebookPage(driver, seleniumHelper); -- } -- return phonebookPage; -- } -- -- public MessagingPage getMessagingPage() { -- if (messagingPag == null) { -- messagingPag = new MessagingPage(driver, seleniumHelper); -- } -- return messagingPag; -- } -- -- public SlartiNotification getNotification() { -- if (slartiNotification == null) { -- slartiNotification = new SlartiNotification(driver, seleniumHelper); -- } -- return slartiNotification; -- } -- -- public Keyboard getKeyboard() { -- if (keyboard == null) { -- keyboard = new Keyboard(seleniumHelper); -- } -- return keyboard; -- } -- -- -- public CallLogPage getCalllogPage() { -- if (callLog == null) { -- callLog = new CallLogPage(driver, seleniumHelper); -- } -- return callLog; -- } -- -- public KeypadDialog getKeypadDialog() { -- if (keypadDialog == null) { -- keypadDialog = new KeypadDialog(driver, seleniumHelper); -- } -- return keypadDialog; -- } -- -- public DialPad getDialPad() { -- if (dialPad == null) { -- dialPad = new DialPad(driver, seleniumHelper); -- } -- return dialPad; -- } -- -- --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/DialPad.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/DialPad.java -deleted file mode 100644 -index 5d8b0e2..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/DialPad.java -+++ /dev/null -@@ -1,101 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.elements; -- -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import org.openqa.selenium.By; --import org.openqa.selenium.WebDriver; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.FindBy; --import org.openqa.selenium.support.How; --import org.openqa.selenium.support.ui.ExpectedConditions; -- --import java.util.HashMap; --import java.util.Map; -- --import static org.junit.Assert.assertEquals; --import static org.junit.Assert.assertNotNull; -- --/** -- * Class FrameStartPage. -- * This represents the PearlCord iframe of the demo module. -- * -- * @author iselisa -- * @version $$Revision: 2374 $$ -- */ --public class DialPad extends Element { -- -- private static final String XPATH_DIALPAD_DIALOG_INPUT = "//*[@id='dialpad-input']"; -- private static final String XPATH_DIALPAD_CALL_BUTTON = "//*[@id='dialpadCallButton']"; -- private static final String XPATH_ACTIVE_CALL_SECTION = "//*[@id='activeCall']"; -- private static final String XPATH_DIALPAD_HANGUP_BUTTON = "//*[@id='dialpadHangupCall']"; -- private static final String XPATH_DIALPAD_CLOSE_BUTTON = "//*[@id='dialpadCloseButton']"; -- -- @FindBy(how= How.XPATH, using=XPATH_DIALPAD_DIALOG_INPUT) -- private WebElement dialPadInputField; -- -- @FindBy(how= How.XPATH, using=XPATH_DIALPAD_CALL_BUTTON) -- private WebElement dialPadButton; -- -- private final Map<String,String> keyMap = new HashMap<>(); -- -- public DialPad(final WebDriver driver, final SeleniumHelper seleniumHelper) { -- super(driver, seleniumHelper); -- -- keyMap.put("1","dialpad-keypad-key-1"); -- keyMap.put("2","dialpad-keypad-key-2"); -- keyMap.put("3","dialpad-keypad-key-3"); -- keyMap.put("4","dialpad-keypad-key-4"); -- keyMap.put("5","dialpad-keypad-key-5"); -- keyMap.put("6","dialpad-keypad-key-6"); -- keyMap.put("7","dialpad-keypad-key-7"); -- keyMap.put("8","dialpad-keypad-key-8"); -- keyMap.put("9","dialpad-keypad-key-9"); -- keyMap.put("*","dialpad-keypad-key-10"); -- keyMap.put("0","dialpad-keypad-key-11"); -- keyMap.put("#","dialpad-keypad-key-12"); -- } -- -- public void dialKeyByKey(final String number) { -- for (final String key : number.split("")) { -- final String keyIdToPress= keyMap.get(key); -- if(keyIdToPress == null) { -- throw new IllegalArgumentException("Key not available on keypad: " + key); -- } -- pressDialPadButton(keyIdToPress); -- seleniumHelper.sleep(200); -- } -- } -- -- private void pressDialPadButton(final String keyIdToPress) { -- final String key_xpath = "//*[@id=\""+keyIdToPress+"\"]"; -- seleniumHelper.touchByXpath(key_xpath); -- } -- -- public void assertNumberFieldTextEquals(final String numberToCheck) { -- seleniumHelper.getWebElement(XPATH_DIALPAD_DIALOG_INPUT); -- final String numberDialed = dialPadInputField.getAttribute("value"); -- assertNotNull(numberDialed); -- assertEquals(numberToCheck, numberDialed); -- } -- -- public void touchDialPadCallButton() { -- seleniumHelper.touchByWebElement(dialPadButton); -- } -- -- public boolean hasActiveCall() { -- final WebElement activeCallSection = seleniumHelper.getWebElement(XPATH_ACTIVE_CALL_SECTION); -- return activeCallSection.isDisplayed(); -- } -- -- public void touchHangup() { -- WebElement webElement = BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(By.xpath(XPATH_DIALPAD_HANGUP_BUTTON))); -- webElement.click(); -- -- BaseTestTrillian.getWait().until(webDriver -> driver.findElements(By.xpath(XPATH_DIALPAD_HANGUP_BUTTON)).size() == 0); -- } -- -- public void touchClose() { -- seleniumHelper.touchByXpath(XPATH_DIALPAD_CLOSE_BUTTON); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/Element.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/Element.java -deleted file mode 100644 -index 2d41135..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/Element.java -+++ /dev/null -@@ -1,128 +0,0 @@ -- --package ch.post.it.paisa.trillian.test.ui.elements; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import org.openqa.selenium.By; --import org.openqa.selenium.WebDriver; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.PageFactory; --import org.openqa.selenium.support.ui.ExpectedConditions; -- --import java.util.logging.Level; --import java.util.logging.Logger; -- --/** -- * Class Element. -- * This represents some reusable methods for the GUI Elements. -- * -- * @author iselisa -- * @version $$Revision: 1107 $$ -- * @see <script>links('$$HeadURL: https://repository.pnet.ch/svn/reposdev-paisa/04_Implementation/services/slarti/trunk/slarti-test/src/main/java/ch/post/it/paisa/slarti/test/ui/elements/Element.java $$');</script> -- */ --public abstract class Element { -- private final static String XPATH_REPLACE = "{XPATH}"; -- -- public static final int SHORT_WAIT_TIME = 2000; -- private final Logger LOG = Logger.getLogger(this.getClass().getName()); -- -- protected WebDriver driver; -- protected SeleniumHelper seleniumHelper; -- -- public Element(final WebDriver driver, final SeleniumHelper seleniumHelper) { -- this.driver = driver; -- this.seleniumHelper = seleniumHelper; -- PageFactory.initElements(driver, this); -- } -- -- protected boolean isWebElementVisibleByXpath(final String xpath) -- { -- return !driver.findElements(By.xpath(xpath)).isEmpty(); -- } -- -- protected void touchMenuElement(final String xpath) { -- WebElement webElement = BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(By.xpath(xpath))); -- webElement.click(); -- } -- -- protected void given(final String message, final Object... params) { -- LOG.log(Level.INFO, "given " + message, params); -- } -- -- protected void when(final String message, final Object... params) { -- LOG.log(Level.INFO, "\twhen " + message, params); -- } -- -- protected void then(final String message, final Object... params) { -- LOG.log(Level.INFO, "\tthen " + message, params); -- } -- -- protected void and(final String message, final Object... params) { -- LOG.log(Level.INFO, "\tand " + message, params); -- } -- -- protected void but(final String message, final Object... params) { -- LOG.log(Level.INFO, "\tbut " + message, params); -- } -- -- public void waitByCss(final String cssSelector) { -- seleniumHelper.waitUntil(ExpectedConditions.elementToBeClickable(By.cssSelector(cssSelector))); -- } -- -- -- -- protected void nextButton() { -- seleniumHelper.sleep(SHORT_WAIT_TIME); -- seleniumHelper.touchBySelector("linti-button-next"); -- } -- -- protected void backButton() { -- seleniumHelper.sleep(SHORT_WAIT_TIME); -- seleniumHelper.touchBySelector("linti-button-back"); -- } -- -- /** -- * Returns true if class attribute of the element contains the expectedClass. -- * @param element -- * @param expectedClass -- * @return -- */ -- protected boolean hasCssClass(final WebElement element, final String expectedClass) { -- final String classes = element.getAttribute("class"); -- if (classes != null) { -- final String[] separateClasses = classes.split(" "); -- for (final String cssClass : separateClasses) { -- if (cssClass != null && cssClass.trim().equalsIgnoreCase(expectedClass)) { -- return true; -- } -- } -- } -- return false; -- } -- -- -- protected void touchMenuElement(final WebElement element, final String xpath) { -- seleniumHelper.waitByXpath(xpath); -- seleniumHelper.touchByWebElement(element); -- } -- -- public void waitForBackendDisplayChange() { -- seleniumHelper.sleep(SHORT_WAIT_TIME); -- } -- -- public void touchSearchButton() { -- seleniumHelper.touchBySelector("#searchButton"); -- } -- -- public void enterSearchText(final String s) { -- final WebElement searchText = driver.findElement(By.id("searchText")); -- searchText.sendKeys(s); -- // TODO: we should dynamically wait until the UI is updated, ideally the UI would show a spinner to allow for this? -- seleniumHelper.sleep( 3000); -- } -- -- public void touchClearSearchTextButton() { -- seleniumHelper.touchBySelector("#clearSearchTextButton"); -- seleniumHelper.sleep( 3000); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/KeypadDialog.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/KeypadDialog.java -deleted file mode 100644 -index e743df8..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/KeypadDialog.java -+++ /dev/null -@@ -1,22 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.elements; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import org.openqa.selenium.WebDriver; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.FindBy; --import org.openqa.selenium.support.How; -- --public class KeypadDialog extends Element { -- public KeypadDialog(WebDriver driver, SeleniumHelper seleniumHelper) { -- super(driver, seleniumHelper); -- //seleniumHelper.wait(driver); -- } -- -- @FindBy(how= How.ID, using="callingDialPadTitle") -- private WebElement callingDialPadTitle; -- -- public void waitForTitle() { -- BaseTestTrillian.waitForElement(callingDialPadTitle); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/SlartiNavigation.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/SlartiNavigation.java -deleted file mode 100644 -index 04afbff..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/SlartiNavigation.java -+++ /dev/null -@@ -1,84 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.elements; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import org.openqa.selenium.By; --import org.openqa.selenium.WebDriver; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.FindBy; --import org.openqa.selenium.support.How; --import org.openqa.selenium.support.ui.ExpectedConditions; -- --public class SlartiNavigation extends Element{ -- -- private final static String XPATH_MODULE_TRILLIAN_NAVIGATION = "//*[@id=\"TrillianEntry\"]"; -- -- private final static String XPATH_MODULE_SLARTI_SIDE_MENU = "//*[@id=\"toggle-shortcutmenu\"]"; -- -- private final static String XPATH_MODULE_TRILLIAN_CALLOG_BUTTON = "//*[@id=\"goToCallLogButton\"]"; -- -- private final static String XPATH_MODULE_BACK_BUTTON = "//*[@id='headerbarBackButton']"; -- -- @FindBy(how = How.XPATH, using = XPATH_MODULE_TRILLIAN_NAVIGATION) -- private WebElement moduleTrillian; -- -- public SlartiNavigation(final WebDriver driver, final SeleniumHelper seleniumHelper) { -- super(driver, seleniumHelper); -- } -- -- /** -- * Opens the main Trillian module -- */ -- public void touchTrillianModule() { -- seleniumHelper.switchToRoot(); -- touchMenuElement(moduleTrillian, XPATH_MODULE_TRILLIAN_NAVIGATION); -- } -- -- public void touchTrillianCalllog() { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- touchMenuElement(XPATH_MODULE_TRILLIAN_CALLOG_BUTTON); -- } -- -- /** -- * Opens the connections tab from the side-menu -- * -- * 1. opens the side menu -- * 2. clicks the "connections" entry inside the side menu -- */ -- public void touchTrillianSideMenuByXpathStringSelector(String... elementIdsToSelect) { -- seleniumHelper.switchToRoot(); -- -- WebElement webElement = BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(By.xpath(XPATH_MODULE_SLARTI_SIDE_MENU))); -- webElement.click(); -- -- if (null != elementIdsToSelect) { -- for (String id : elementIdsToSelect) { -- String xpathWithId = "//*[@id=\"" + id + "\"]"; -- WebElement idElement = BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(By.xpath(xpathWithId))); -- idElement.click(); -- } -- } -- } -- -- -- /** -- * Initiates a click action on the back button -- * -- * Can be used to return from each element that -- * dispays a back button -- * -- */ -- public void touchGoBackButton(String moduleId) { -- touchGoBackButton(moduleId, true); -- } -- -- public void touchGoBackButton(String moduleId, boolean wait) { -- BaseTestTrillian.switchToFrame(moduleId); -- driver.findElement(By.xpath(XPATH_MODULE_BACK_BUTTON)).click(); -- if (wait) { -- BaseTestTrillian.getWait().until(driver -> driver.findElements(By.xpath(XPATH_MODULE_BACK_BUTTON)).size() == 0); -- } -- } -- -- --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/SlartiNotification.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/SlartiNotification.java -deleted file mode 100644 -index 6a65282..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/SlartiNotification.java -+++ /dev/null -@@ -1,120 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.elements; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.SeleniumContext; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import org.openqa.selenium.By; --import org.openqa.selenium.WebDriver; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.ui.ExpectedConditions; -- --import java.util.List; --import java.util.UUID; -- --import static org.junit.Assert.*; -- --public class SlartiNotification extends Element{ -- -- -- private static final String XPATH_INCOMING_CALL_TITLE = "//div[contains(@class, 'notification-title')]"; // "//div[@id=\"toast-title\"]"; -- -- private static final String XPATH_INCOMING_CALL_DETAIL = "//div[contains(@class, 'notification-detail')]"; // "//div[@id=\"toast-title\"]"; -- -- private static final String XPATH_INCOMING_NOTIFICATION = "//div[@id=\"toast-container\"]"; -- private static final String XPATH_CANCEL_BUTTON = "//button[contains(@class, 'notification-cancel-button')]"; -- private static final String XPATH_OK_BUTTON = "//button[contains(@class, 'notification-ok-button')]"; -- -- -- public SlartiNotification(final WebDriver driver, final SeleniumHelper seleniumHelper) { -- super(driver, seleniumHelper); -- } -- -- public void assertHasOKButton() { -- BaseTestTrillian.getWait().until(webDriver -> driver.findElements(By.xpath(XPATH_OK_BUTTON)).size() > 0); -- assertFalse(driver.findElements(By.xpath(XPATH_OK_BUTTON)).isEmpty()); -- } -- -- // ISABUFC-1310 -- public void assertOKButtonTextEqualTo(final String buttonText) { -- WebElement button = driver.findElement(By.xpath(XPATH_OK_BUTTON)); -- assertEquals("Text of Notification's OK button should be: " + buttonText, buttonText, button.getText()); -- } -- -- // ISABUFC-1310 -- public void assertCancelButtonTextEqualTo(final String buttonText) { -- WebElement button = driver.findElement(By.xpath(XPATH_CANCEL_BUTTON)); -- assertEquals("Text of Notification's Cancel button should be: " + buttonText, buttonText, button.getText()); -- } -- -- public void assertHasCancelButton() { -- BaseTestTrillian.getWait().until(webDriver -> driver.findElements(By.xpath(XPATH_CANCEL_BUTTON)).size() > 0); -- assertFalse(driver.findElements(By.xpath(XPATH_CANCEL_BUTTON)).isEmpty()); -- } -- -- public void touchNotificationButtonOk() { -- WebElement notificationButtonOk = BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath(XPATH_OK_BUTTON)))); -- notificationButtonOk.click(); -- } -- -- public void touchNotificationButtonCancel() { -- WebElement notificationButtonCancel = BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath(XPATH_CANCEL_BUTTON)))); -- notificationButtonCancel.click(); -- } -- -- public void waitForNotificationButtonCancelClose() { -- BaseTestTrillian.getWait().until(webDriver -> driver.findElements(By.xpath(XPATH_CANCEL_BUTTON)).size() == 0); -- } -- -- -- public boolean isNotificationContainerVisible() { -- return seleniumHelper.withReducedTimeout(() -> seleniumHelper.switchToRootAndIsWebElementVisible(XPATH_INCOMING_NOTIFICATION)); -- } -- -- public void assertVisible() { -- assertTrue("Notification not visible", isNotificationContainerVisible()); -- } -- -- public void assertNotVisible() { -- if(isNotificationContainerVisible()) { -- final List<WebElement> webElements = this.driver.findElements(By.xpath(XPATH_INCOMING_CALL_TITLE)); -- final StringBuilder errorText = new StringBuilder(); -- for (final WebElement toastTitle : webElements) { -- errorText.append("visible Notification with Title:").append(toastTitle.getText()).append("\n"); -- } -- if(!webElements.isEmpty()) { -- fail(errorText.toString()); -- } -- } -- } -- -- public void assertNotificationTitleEqualTo(final String title) { -- BaseTestTrillian.getWait().until(webdriver -> isNotificationContainerVisible()); -- BaseTestTrillian.getWait().until(webDriver -> title.equals(getNotificationTitle())); -- } -- -- public void assertNotificationDetailEqualTo(final String message) { -- final List<WebElement> elements = BaseTestTrillian.getWait().until(ExpectedConditions.visibilityOfAllElements(driver.findElements(By.xpath(XPATH_INCOMING_CALL_DETAIL)))); -- assertFalse("No Detail found: " + XPATH_INCOMING_CALL_DETAIL, elements.isEmpty()); -- final WebElement toastTitle = elements.get(0); -- assertNotNull("Notification detail shall not be null", toastTitle); -- assertEquals("Detail of Notification should be: " + message, message, toastTitle.getText()); -- } -- -- /** -- * Extracts the title of the toast (notification) -- * -- */ -- public String getNotificationTitle() { -- return getNotificationTitleWebElement().getText(); -- } -- -- private WebElement getNotificationTitleWebElement() { -- BaseTestTrillian.getWait().until(webdriver -> isNotificationContainerVisible()); -- final List<WebElement> elements = BaseTestTrillian.getWait().until(ExpectedConditions.visibilityOfAllElements(driver.findElements(By.xpath(XPATH_INCOMING_CALL_TITLE)))); -- return elements.get(0); -- } -- -- public void waitNotificationWithTimeout() { -- BaseTestTrillian.getWait().until(webDriver -> driver.findElements(By.xpath(XPATH_INCOMING_NOTIFICATION)).size() == 0); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/ToggleButton.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/ToggleButton.java -deleted file mode 100644 -index efe6210..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/elements/ToggleButton.java -+++ /dev/null -@@ -1,69 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test.ui.elements; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import org.openqa.selenium.By; --import org.openqa.selenium.WebDriver; --import org.openqa.selenium.WebElement; -- --import java.util.List; -- --/** -- * Wraps calls to a linti toggle button -- * -- * @author josttho -- * @version $$Revision$$ -- * @see <script>links('$$HeadURL$$');</script> -- */ --public class ToggleButton extends Element { -- private final String id; -- private final WebElement masterDiv; -- private final WebElement masterElement; -- -- -- public static final String OFF = "state-0"; -- public static final String ON = "state-1"; -- -- /** -- * -- * @param driver -- * @param seleniumHelper -- * @param id Id of the toggle button (for example "wayOfTraveling" if using <linti-button-toggle id="wayOfTraveling".../>) -- */ -- public ToggleButton(final WebDriver driver, final SeleniumHelper seleniumHelper, final String id) { -- super(driver, seleniumHelper); -- this.id = id; -- masterDiv = driver.findElement(By.cssSelector("#" + id + " div")); -- masterElement = driver.findElement(By.cssSelector("#" + id)); -- } -- -- public boolean isStateActive(final String state) { -- final List<WebElement> spans = masterDiv.findElements(By.tagName("span")); -- for (final WebElement span : spans) { -- if (span.getAttribute("class").contains("active")) { -- return span.getAttribute("class").contains(state); -- } -- } -- return false; -- } -- -- public boolean isEnabled() { -- final String disabledAttribute = masterElement.getAttribute("disabled"); -- return disabledAttribute == null; -- } -- -- public boolean isDisabled() { -- return !isEnabled(); -- } -- -- public void selectId(final String itemId) { -- seleniumHelper.touchBySelector("#" + id + " div span." + itemId); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/EagleMockInstance.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/EagleMockInstance.java -deleted file mode 100644 -index 3f12920..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/EagleMockInstance.java -+++ /dev/null -@@ -1,327 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.mock; -- -- --import ch.post.it.paisa.alice.service.domain.core.json.ExtendedObjectMapper; --import com.fasterxml.jackson.databind.JsonNode; --import com.github.tomakehurst.wiremock.client.*; --import io.restassured.RestAssured; --import org.apache.commons.lang.StringUtils; --import org.apache.http.HttpStatus; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; --import org.springframework.web.bind.annotation.RequestMethod; -- --import javax.annotation.Nullable; --import java.net.URI; --import java.net.URISyntaxException; --import java.util.ArrayList; --import java.util.HashSet; --import java.util.List; --import java.util.Set; -- --import static ch.post.it.paisa.trillian.test.TestPaths.*; --import static com.github.tomakehurst.wiremock.client.WireMock.*; -- --/** -- * Create a hook route to wiremock to override the given URL. -- * <p> -- * taken from Slarti, extended to support query parameters -- */ -- --public class EagleMockInstance { -- -- private static final Logger LOG = LoggerFactory.getLogger(EagleMockInstance.class); -- final ExtendedObjectMapper OBJECT_MAPPER = new ExtendedObjectMapper(); -- -- final JsonNode toJsonNode(Object object) { -- return OBJECT_MAPPER.convertValue(object, JsonNode.class); -- } -- -- private final MockServer mockServer; -- private final WireMock wireMockClient; -- private final String serverUrlBase; -- private Set<String> routeHookSet = new HashSet<>(); -- -- EagleMockInstance(MockServer mockServer) { -- this.mockServer = mockServer; -- this.serverUrlBase = getEagleUrl(); -- this.wireMockClient = new WireMock(getHostFromUrl(serverUrlBase), getPortFromUrl(serverUrlBase), "/eagle/mock"); -- this.wireMockClient.resetMappings(); -- } -- -- -- @SuppressWarnings("unused") -- public void forPost(String path) { -- prepareStubFor(RequestMethod.POST, path, HttpStatus.SC_OK, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public void forPost(String path, int statusCodeToReturn, Object body) { -- prepareStubFor(RequestMethod.POST, path, HttpStatus.SC_OK, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public void forPost(String path, int statusCodeToReturn) { -- prepareStubFor(RequestMethod.POST, path, statusCodeToReturn, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public void forPost(String path, int statusCodeToReturn, Integer fixedDelay) { -- prepareStubFor(RequestMethod.POST, path, statusCodeToReturn, null, null, fixedDelay); -- } -- -- @SuppressWarnings("unused") -- public void forPut(String path) { -- prepareStubFor(RequestMethod.PUT, path, HttpStatus.SC_OK, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public void forPut(String path, int statusCodeToReturn) { -- prepareStubFor(RequestMethod.PUT, path, statusCodeToReturn, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public void forPut(String path, int statusCodeToReturn, Integer fixedDelay) { -- prepareStubFor(RequestMethod.PUT, path, statusCodeToReturn, null, null, fixedDelay); -- } -- -- @SuppressWarnings("unused") -- public void forGet(String path) { -- prepareStubFor(RequestMethod.GET, path, HttpStatus.SC_OK, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public void forGet(String path, int statusCodeToReturn) { -- prepareStubFor(RequestMethod.GET, path, statusCodeToReturn, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public void forGet(String path, int statusCodeToReturn, Object body) { -- prepareStubFor(RequestMethod.GET, path, statusCodeToReturn, body, ResponseType.JSON, null); -- } -- -- @SuppressWarnings("unused") -- public void forGet(String path, int statusCodeToReturn, Object body, String queryName, String queryValueThatNeedsToMatch) { -- List<QueryParameter> queryParameters = new ArrayList<>(); -- queryParameters.add(new QueryParameter(queryName, queryValueThatNeedsToMatch)); -- prepareStubFor(RequestMethod.GET, path, queryParameters, statusCodeToReturn, body, ResponseType.JSON, null); -- } -- -- @SuppressWarnings("unused") -- public void forGet(String path, int statusCodeToReturn, Object body, ResponseType responseType) { -- prepareStubFor(RequestMethod.GET, path, statusCodeToReturn, body, responseType, null); -- } -- -- private void prepareStubFor(RequestMethod requestMethod, String path, int statusCodeToReturn, @Nullable Object body, -- @Nullable ResponseType responseType, @Nullable Integer fixedDelay) { -- prepareStubFor(requestMethod, path, new ArrayList<>(), statusCodeToReturn, body, responseType, fixedDelay); -- } -- -- void prepareStubFor(RequestMethod requestMethod, String path, List<QueryParameter> queryParameters, -- int statusCodeToReturn, @Nullable Object body, @Nullable ResponseType responseType, @Nullable Integer fixedDelay) { -- -- if (path.startsWith("/")) { -- path = path.substring(1); -- } -- if (path.endsWith("/")) { -- path = path.substring(0, path.length() - 1); -- } -- -- if (responseType == null) { -- responseType = ResponseType.JSON; -- } -- -- String filterPath = null; -- if (path.contains("{")) { -- filterPath = path.substring(path.indexOf("}") + 2, path.length()); -- path = path.substring(0, path.indexOf("{") - 1); -- } -- -- UrlMatchingStrategy urlMatching = urlMatching("^/" + path + ".*"); -- LOG.info("running on {}, the base url is {}", mockServer, serverUrlBase); -- -- String routeHookUrl = serverUrlBase + "/" + path + "/_hooks/route/mocked/" + path; -- getRouteHookSet().add(routeHookUrl); -- StringBuilder bodyBuilder = new StringBuilder(); -- bodyBuilder.append("{"); -- -- if (StringUtils.isNotEmpty(filterPath)) { -- String filterPrefix = "/eagle/"; -- bodyBuilder.append("\"filter\":\"" + filterPrefix + path + "/[^/]+/" + filterPath + "\","); -- } -- -- bodyBuilder.append("\"destination\":\"" + serverUrlBase + "/mock/" + path + "\""); -- bodyBuilder.append("}"); -- RestAssured.given().contentType("application/json"). -- body(bodyBuilder.toString()).then().given(). -- put(routeHookUrl); -- -- -- ResponseDefinitionBuilder aResponse = new ResponseDefinitionBuilder(); -- aResponse.withStatus(statusCodeToReturn); -- -- if (body != null) { -- if (ResponseType.JSON.equals(responseType)) { -- aResponse.withHeader("Content-Type", "application/json"); -- aResponse.withBody(toJsonNode(body).toString()); -- } else { -- aResponse.withBody(body.toString()); -- } -- } -- if (fixedDelay != null) { -- aResponse.withFixedDelay(fixedDelay); -- } -- -- // stub for -- MappingBuilder mappingBuilder = null; -- if (RequestMethod.POST.equals(requestMethod)) { -- mappingBuilder = WireMock.post(urlMatching); -- } else if (RequestMethod.PUT.equals(requestMethod)) { -- mappingBuilder = WireMock.put(urlMatching); -- } else if (RequestMethod.GET.equals(requestMethod)) { -- mappingBuilder = WireMock.get(urlMatching); -- } else if (RequestMethod.DELETE.equals(requestMethod)) { -- mappingBuilder = WireMock.delete(urlMatching); -- } -- -- assert (mappingBuilder != null); -- -- for (QueryParameter queryParameter : queryParameters) { -- mappingBuilder.withQueryParam(queryParameter.name, WireMock.equalTo(queryParameter.value)); -- } -- -- mappingBuilder.willReturn(aResponse); -- wireMockClient.register(mappingBuilder); -- } -- -- -- @SuppressWarnings("unused") -- public boolean verifyForPost(String path) { -- return prepareVerifyFor(RequestMethod.POST, path); -- } -- -- @SuppressWarnings("unused") -- public boolean verifyForPost(String path, String body) { -- return prepareVerifyFor(RequestMethod.POST, path, body); -- } -- -- @SuppressWarnings("unused") -- public boolean verifyForPut(String path) { -- return prepareVerifyFor(RequestMethod.PUT, path); -- } -- -- @SuppressWarnings("unused") -- public boolean verifyForPut(String path, String... stuffInBody) { -- return prepareVerifyFor(RequestMethod.PUT, path, stuffInBody); -- } -- -- @SuppressWarnings("unused") -- public boolean verifyForGet(String path) { -- return prepareVerifyFor(RequestMethod.GET, path); -- } -- -- -- @SuppressWarnings("unused") -- public boolean verifyForDelete(String path) { -- return prepareVerifyFor(RequestMethod.DELETE, path); -- } -- -- private boolean prepareVerifyFor(RequestMethod requestMethod, String path, String... stuffInBody) { -- boolean verifyResult; -- if (path.startsWith("/")) { -- path = path.substring(1); -- } -- if (path.endsWith("/")) { -- path = path.substring(0, path.length() - 1); -- } -- -- UrlMatchingStrategy urlMatching = urlMatching("^/" + path + ".*"); -- RequestPatternBuilder requestPatternBuilder = null; -- if (RequestMethod.POST.equals(requestMethod)) { -- requestPatternBuilder = postRequestedFor(urlMatching); -- } else if (RequestMethod.PUT.equals(requestMethod)) { -- requestPatternBuilder = putRequestedFor(urlMatching); -- } else if (RequestMethod.GET.equals(requestMethod)) { -- requestPatternBuilder = getRequestedFor(urlMatching); -- } else if (RequestMethod.DELETE.equals(requestMethod)) { -- requestPatternBuilder = deleteRequestedFor(urlMatching); -- } -- -- assert (requestPatternBuilder != null); -- -- for (String stuff : stuffInBody) { -- requestPatternBuilder.withRequestBody(containing(stuff)); -- } -- -- try { -- wireMockClient.verifyThat(requestPatternBuilder); -- verifyResult = true; -- } catch (VerificationException e) { -- LOG.error("No match found.", e); -- verifyResult = false; -- } -- return verifyResult; -- } -- -- -- String getEagleUrl() { -- switch (mockServer) { -- case EAGLE1: -- return getEagle1BaseUrl(); -- case EAGLE2: -- return getEagle2BaseUrl(); -- case EAGLE3: -- return getEagle3BaseUrl(); -- default: -- throw new IllegalArgumentException(); -- } -- } -- -- private Set<String> getRouteHookSet() { -- return routeHookSet; -- } -- -- private void setRouteHook(Set<String> routeHookSet) { -- this.routeHookSet = routeHookSet; -- } -- -- -- void remove() { -- for (String routeHook : getRouteHookSet()) { -- RestAssured.delete(routeHook); -- } -- } -- -- void reset() { -- clearAllVariablesValue(); -- wireMockClient.resetMappings(); -- wireMockClient.resetRequests(); -- wireMockClient.resetScenarios(); -- } -- -- -- void clearAllVariablesValue() { -- remove(); -- setRouteHook(new HashSet<>()); -- } -- -- String getHostFromUrl(String url) { -- URI uri = null; -- try { -- uri = new URI(url); -- } catch (URISyntaxException e) { -- throw new RuntimeException(e); -- } -- return uri.getHost(); -- } -- -- int getPortFromUrl(String url) { -- URI uri = null; -- try { -- uri = new URI(url); -- } catch (URISyntaxException e) { -- throw new RuntimeException(e); -- } -- return uri.getPort(); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/HoustonMock.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/HoustonMock.java -deleted file mode 100644 -index 6756272..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/HoustonMock.java -+++ /dev/null -@@ -1,320 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.mock; -- -- --import ch.post.it.paisa.alice.service.domain.core.json.ExtendedObjectMapper; --import com.fasterxml.jackson.databind.JsonNode; --import com.github.tomakehurst.wiremock.client.*; --import io.restassured.RestAssured; --import org.apache.commons.lang.StringUtils; --import org.apache.http.HttpStatus; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; --import org.springframework.web.bind.annotation.RequestMethod; -- --import javax.annotation.Nullable; --import java.util.ArrayList; --import java.util.HashSet; --import java.util.List; --import java.util.Set; -- --import static ch.post.it.paisa.trillian.test.TestPaths.*; --import static com.github.tomakehurst.wiremock.client.WireMock.*; -- --/** -- * Create a hook route to wiremock to override the given URL. -- * <p> -- * taken from Slarti, extended to support query parameters -- */ --public class HoustonMock { -- private static final Logger LOG = LoggerFactory.getLogger(HoustonMock.class); -- -- private static final JsonNode toJsonNode(Object object) { -- return OBJECT_MAPPER.convertValue(object, JsonNode.class); -- } -- -- private static final ExtendedObjectMapper OBJECT_MAPPER = new ExtendedObjectMapper(); -- static Set<HoustonMock> mockSet = new HashSet<>(); -- static HoustonMock mock; -- private static Set<String> routeHookSet = new HashSet<>(); -- private static RequestPatternBuilder matcher; -- -- HoustonMock() { -- } -- -- @SuppressWarnings("unused") -- public static void forPut(String path) { -- prepareStubFor(RequestMethod.PUT, path, HttpStatus.SC_OK, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public static void forPut(String path, int statusCodeToReturn) { -- prepareStubFor(RequestMethod.PUT, path, statusCodeToReturn, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public static void forPut(String path, int statusCodeToReturn, Integer fixedDelay) { -- prepareStubFor(RequestMethod.PUT, path, statusCodeToReturn, null, null, fixedDelay); -- } -- -- @SuppressWarnings("unused") -- public static void forGet(String path) { -- prepareStubFor(RequestMethod.GET, path, HttpStatus.SC_OK, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public static void forGet(String path, int statusCodeToReturn) { -- prepareStubFor(RequestMethod.GET, path, statusCodeToReturn, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public static void forGet(String path, int statusCodeToReturn, Object body) { -- prepareStubFor(RequestMethod.GET, path, statusCodeToReturn, body, ResponseType.JSON, null); -- } -- -- @SuppressWarnings("unused") -- public static void forGet(String path, int statusCodeToReturn, Object body, String queryName, String queryValueThatNeedsToMatch) { -- List<QueryParameter> queryParameters = new ArrayList<>(); -- queryParameters.add(new QueryParameter(queryName, queryValueThatNeedsToMatch)); -- prepareStubFor(RequestMethod.GET, path, queryParameters, statusCodeToReturn, body, ResponseType.JSON, null); -- } -- -- @SuppressWarnings("unused") -- public static void forGet(String path, int statusCodeToReturn, Object body, ResponseType responseType) { -- prepareStubFor(RequestMethod.GET, path, statusCodeToReturn, body, responseType, null); -- } -- -- @SuppressWarnings("unused") -- public static void forDelete(String path) { -- prepareStubFor(RequestMethod.DELETE, path, HttpStatus.SC_OK, null, null, null); -- } -- -- @SuppressWarnings("unused") -- public static void forDelete(String path, int statusCodeToReturn) { -- prepareStubFor(RequestMethod.DELETE, path, statusCodeToReturn, null, null, null); -- } -- -- private static void prepareStubFor(RequestMethod requestMethod, String path, int statusCodeToReturn, @Nullable Object body, -- @Nullable ResponseType responseType, @Nullable Integer fixedDelay) { -- prepareStubFor(requestMethod, path, new ArrayList<>(), statusCodeToReturn, body, responseType, fixedDelay); -- } -- -- static void prepareStubFor(RequestMethod requestMethod, String path, List<QueryParameter> queryParameters, -- int statusCodeToReturn, @Nullable Object body, @Nullable ResponseType responseType, @Nullable Integer fixedDelay) { -- -- if (path.startsWith("/")) { -- path = path.substring(1); -- } -- if (path.endsWith("/")) { -- path = path.substring(0, path.length() - 1); -- } -- -- if (responseType == null) { -- responseType = ResponseType.JSON; -- } -- -- String filterPath = null; -- if (path.contains("{")) { -- filterPath = path.substring(path.indexOf("}") + 2, path.length()); -- path = path.substring(0, path.indexOf("{") - 1); -- } -- -- UrlMatchingStrategy urlMatching = urlMatching("^/" + path + ".*"); -- HoustonMock.setMatcher(putRequestedFor(urlMatching)); -- -- String baseUrl = getHoustonBaseUrl(); -- -- LOG.info("running on {}, the base url for Houston is {}", System.getProperty("server.host", "localhost"), baseUrl); -- -- String routeHookUrl = baseUrl + "/" + path + "/_hooks/route/mocked/" + path; -- HoustonMock.getRouteHookSet().add(routeHookUrl); -- StringBuilder bodyBuilder = new StringBuilder(); -- bodyBuilder.append("{"); -- -- if (StringUtils.isNotEmpty(filterPath)) { -- String filterPrefix = "/houston/"; -- bodyBuilder.append("\"filter\":\"" + filterPrefix + path + "/[^/]+/" + filterPath + "\","); -- } -- -- bodyBuilder.append("\"destination\":\"" + baseUrl + "/mock/" + path + "\""); -- bodyBuilder.append("}"); -- RestAssured.given().contentType("application/json"). -- body(bodyBuilder.toString()).then().given(). -- put(routeHookUrl); -- -- -- ResponseDefinitionBuilder aResponse = new ResponseDefinitionBuilder(); -- aResponse.withStatus(statusCodeToReturn); -- -- if (body != null) { -- if (ResponseType.JSON.equals(responseType)) { -- aResponse.withHeader("Content-Type", "application/json"); -- aResponse.withBody(toJsonNode(body).toString()); -- } else { -- aResponse.withBody(body.toString()); -- } -- } -- if (fixedDelay != null) { -- aResponse.withFixedDelay(fixedDelay); -- } -- -- // stub for -- MappingBuilder mappingBuilder = null; -- if (RequestMethod.POST.equals(requestMethod)) { -- mappingBuilder = WireMock.post(urlMatching); -- } else if (RequestMethod.PUT.equals(requestMethod)) { -- mappingBuilder = WireMock.put(urlMatching); -- } else if (RequestMethod.GET.equals(requestMethod)) { -- mappingBuilder = WireMock.get(urlMatching); -- } else if (RequestMethod.DELETE.equals(requestMethod)) { -- mappingBuilder = WireMock.delete(urlMatching); -- } -- -- assert (mappingBuilder != null); -- -- for (QueryParameter queryParameter : queryParameters) { -- mappingBuilder.withQueryParam(queryParameter.name, WireMock.equalTo(queryParameter.value)); -- } -- -- mappingBuilder.willReturn(aResponse); -- WireMock.stubFor(mappingBuilder); -- -- HoustonMock.getMockSet().add(HoustonMock.getMock()); -- } -- -- @SuppressWarnings("unused") -- public static boolean verifyForPost(String path) { -- return prepareVerifyFor(RequestMethod.POST, path); -- } -- -- @SuppressWarnings("unused") -- public static boolean verifyForPost(String path, String body) { -- return prepareVerifyFor(RequestMethod.POST, path, body); -- } -- -- @SuppressWarnings("unused") -- public static boolean verifyForPut(String path) { -- return prepareVerifyFor(RequestMethod.PUT, path); -- } -- -- @SuppressWarnings("unused") -- public static boolean verifyForPut(String path, String... stuffInBody) { -- return prepareVerifyFor(RequestMethod.PUT, path, stuffInBody); -- } -- -- @SuppressWarnings("unused") -- public static boolean verifyForGet(String path) { -- return prepareVerifyFor(RequestMethod.GET, path); -- } -- -- -- @SuppressWarnings("unused") -- public static boolean verifyForDelete(String path) { -- return prepareVerifyFor(RequestMethod.DELETE, path); -- } -- -- private static boolean prepareVerifyFor(RequestMethod requestMethod, String path, String... stuffInBody) { -- boolean verifyResult; -- if (path.startsWith("/")) { -- path = path.substring(1); -- } -- if (path.endsWith("/")) { -- path = path.substring(0, path.length() - 1); -- } -- -- UrlMatchingStrategy urlMatching = urlMatching("^/" + path + ".*"); -- RequestPatternBuilder requestPatternBuilder = null; -- if (RequestMethod.POST.equals(requestMethod)) { -- requestPatternBuilder = postRequestedFor(urlMatching); -- } else if (RequestMethod.PUT.equals(requestMethod)) { -- requestPatternBuilder = putRequestedFor(urlMatching); -- } else if (RequestMethod.GET.equals(requestMethod)) { -- requestPatternBuilder = getRequestedFor(urlMatching); -- } else if (RequestMethod.DELETE.equals(requestMethod)) { -- requestPatternBuilder = deleteRequestedFor(urlMatching); -- } -- -- assert (requestPatternBuilder != null); -- -- for (String stuff : stuffInBody) { -- requestPatternBuilder.withRequestBody(containing(stuff)); -- } -- -- try { -- WireMock.verify(requestPatternBuilder); -- verifyResult = true; -- } catch (VerificationException e) { -- LOG.error("No match found.", e); -- verifyResult = false; -- } -- return verifyResult; -- } -- -- private static Set<HoustonMock> getMockSet() { -- return mockSet; -- } -- -- private static void setMockSet(Set<HoustonMock> mockSet) { -- HoustonMock.mockSet = mockSet; -- } -- -- private static HoustonMock getMock() { -- return mock; -- } -- -- -- private static void clearMock() { -- HoustonMock.mock = null; -- } -- -- private static Set<String> getRouteHookSet() { -- return HoustonMock.routeHookSet; -- } -- -- private static void setRouteHook(Set<String> routeHookSet) { -- HoustonMock.routeHookSet = routeHookSet; -- } -- -- @SuppressWarnings("unused") -- private static RequestPatternBuilder getMatcher() { -- return matcher; -- } -- -- private static void setMatcher(RequestPatternBuilder matcher) { -- HoustonMock.matcher = matcher; -- } -- -- public static void reset() { -- mockSet.forEach(HoustonMock::remove); -- -- clearAllVariablesValue(); -- mock = new HoustonMock(); -- -- WireMock.configureFor(HOUSTON_HOST, Integer.parseInt(HOUSTON_PORT), HOUSTON_PATH + "/mock"); -- WireMock.reset(); -- } -- -- static void clearAllVariablesValue() { -- HoustonMock.setMockSet(new HashSet<>()); -- HoustonMock.clearMock(); -- HoustonMock.setRouteHook(new HashSet<>()); -- HoustonMock.setMatcher(null); -- } -- -- -- void remove() { -- for (String routeHook : getRouteHookSet()) { -- RestAssured.delete(routeHook); -- } -- } -- -- --// static class QueryParameter { --// String name; --// String value; --// --// QueryParameter(String name, String value) { --// this.name = name; --// this.value = value; --// } --// } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/MockInstances.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/MockInstances.java -deleted file mode 100644 -index fe69426..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/MockInstances.java -+++ /dev/null -@@ -1,42 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.mock; -- --public class MockInstances { -- private static EagleMockInstance eagleMock1 = null; -- private static EagleMockInstance eagleMock2 = null; -- private static EagleMockInstance eagleMock3 = null; -- private static HoustonMock houstonMock = null; -- -- public static EagleMockInstance getEagle1() { -- if (eagleMock1 == null) { -- eagleMock1 = new EagleMockInstance(MockServer.EAGLE1); -- } -- return eagleMock1; -- } -- -- public static EagleMockInstance getEagle2() { -- if (eagleMock2 == null) { -- eagleMock2 = new EagleMockInstance(MockServer.EAGLE2); -- } -- return eagleMock2; -- } -- -- public static EagleMockInstance getEagle3() { -- if (eagleMock3 == null) { -- eagleMock3 = new EagleMockInstance(MockServer.EAGLE3); -- } -- return eagleMock3; -- } -- -- public static HoustonMock getHouston() { -- if (houstonMock == null) { -- houstonMock = new HoustonMock(); -- } -- return houstonMock; -- } -- -- public static void resetAllEagles() { -- if (eagleMock1 != null) eagleMock1.reset(); -- if (eagleMock2 != null) eagleMock2.reset(); -- if (eagleMock3 != null) eagleMock3.reset(); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/MockServer.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/MockServer.java -deleted file mode 100644 -index fa27fe7..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/MockServer.java -+++ /dev/null -@@ -1,8 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.mock; -- --public enum MockServer { -- HOUSTON, -- EAGLE1, -- EAGLE2, -- EAGLE3 --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/QueryParameter.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/QueryParameter.java -deleted file mode 100644 -index b8fd54c..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/QueryParameter.java -+++ /dev/null -@@ -1,11 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.mock; -- --class QueryParameter { -- String name; -- String value; -- -- QueryParameter(String name, String value) { -- this.name = name; -- this.value = value; -- } --} -\ No newline at end of file -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/ResponseType.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/ResponseType.java -deleted file mode 100644 -index f3e4a31..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/mock/ResponseType.java -+++ /dev/null -@@ -1,6 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.mock; -- --public enum ResponseType { -- HTML, -- JSON --} -\ No newline at end of file -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/CallLogPage.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/CallLogPage.java -deleted file mode 100644 -index b9209cb..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/CallLogPage.java -+++ /dev/null -@@ -1,72 +0,0 @@ --/* -- * ------------------------------------------------------------------------------------------------ -- * Copyright 2014 by Swiss Post, Information Technology Services -- * ------------------------------------------------------------------------------------------------ -- * $Id$ -- * ------------------------------------------------------------------------------------------------ -- */ -- --package ch.post.it.paisa.trillian.test.ui.pages; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.SeleniumContext; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.Element; --import org.junit.Assert; --import org.openqa.selenium.By; --import org.openqa.selenium.TimeoutException; --import org.openqa.selenium.WebDriver; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.FindBy; --import org.openqa.selenium.support.How; --import org.openqa.selenium.support.ui.ExpectedConditions; -- --import java.util.List; -- -- --public class CallLogPage extends Element { -- -- -- private final static String TAG_NAME_BACK_BUTTON = "linti-button-back"; -- -- private final static String XPATH_CALLLOG_ENTRIES = "//*[@id='callLogEntry']/li"; -- -- -- @FindBy(how = How.TAG_NAME, using = TAG_NAME_BACK_BUTTON) -- private WebElement goBackButton; -- -- @FindBy(how = How.ID, using = "trillianCalllogTitle") -- private WebElement trillianMessagesTitle; -- -- -- public CallLogPage(final WebDriver driver, final SeleniumHelper seleniumHelper) { -- super(driver, seleniumHelper); -- } -- -- public void waitForTitle() { -- SeleniumContext.writeBrowserScreenshot("call log page"); -- BaseTestTrillian.getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("trillianCalllogTitle"))); -- BaseTestTrillian.waitForElement(trillianMessagesTitle); -- } -- -- public void touchGoBackButton() { -- seleniumHelper.touchByWebElement(goBackButton); -- } -- -- public int getCallLogSize() { -- final List<WebElement> webElements = this.driver.findElements(By.xpath(XPATH_CALLLOG_ENTRIES)); -- return webElements.size(); -- } -- -- public void assertThatThereAreNoCallLogEntries() { -- try { -- seleniumHelper.waitUntil((webDriver) -> seleniumHelper.withoutTimeout(() -> this.driver.findElements(By.xpath(XPATH_CALLLOG_ENTRIES)).size()) == 0); -- } catch (TimeoutException e) { -- Assert.fail("There are one or more call log entries displayed, but there should be none."); -- } -- } -- -- --} -- -- -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/CallbackPossibility.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/CallbackPossibility.java -deleted file mode 100644 -index c0d6178..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/CallbackPossibility.java -+++ /dev/null -@@ -1,11 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.pages; -- --public class CallbackPossibility { -- public String name; -- public String number; -- -- @Override -- public String toString() { -- return "[name: " + name + ", number: " + number + "]"; -- } --} -\ No newline at end of file -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/ConnectionPage.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/ConnectionPage.java -deleted file mode 100644 -index 2297d74..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/ConnectionPage.java -+++ /dev/null -@@ -1,335 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.pages; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.Element; --import org.openqa.selenium.By; --import org.openqa.selenium.NoSuchElementException; --import org.openqa.selenium.WebDriver; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.FindBy; --import org.openqa.selenium.support.How; --import org.openqa.selenium.support.ui.ExpectedConditions; --import org.openqa.selenium.support.ui.FluentWait; --import org.openqa.selenium.support.ui.Wait; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; -- --import java.time.Duration; --import java.util.ArrayList; --import java.util.List; --import java.util.function.Function; -- --/** -- * Helper class to access different elements in the trillian connections page -- * -- * !!! NOTE !!! XPath indexes of array elements begin from 1, not from ZERO -- * So whenever xpath index is required, always keep in mind that 0 will return null -- */ --public class ConnectionPage extends Element { -- -- -- private final static Logger LOG = LoggerFactory.getLogger(ConnectionPage.class); -- -- private final static String TRILLIAN_IFRAME_ID = "module-Trillian"; -- -- private final static String XPATH_CURRENT_STATION_TITLE_ID = "//*[@id=\"headerbarTitle\"]"; -- -- private final static String XPATH_BACK_BUTTON = "//*[@id=\"headerbarBackButton\"]"; -- -- private final static String XPATH_INBOUND_CONNECTION_NUMBER = "//*[@id=\"inboundConnectionsList\"]/li[{xpathIndex}]//button[contains(@class, 'info-button')]"; -- -- private final static String XPATH_MENU_TAB_INBOUND_CONNECTIONS = "//linti-menu//ul/li[1]"; -- -- private final static String XPATH_SELECTED_CONNECTION_STATUS_BROKEN = "//*[@ng-show=\"ctrl.selectedInboundConnection.broken\"]"; -- private final static String XPATH_SELECTED_CONNECTION_STATUS_IN_DANGER = "//p[@ng-show=\"ctrl.selectedInboundConnection.inDanger\"]"; -- -- private final static String XPATH_SELECTED_CONNECTION_MAX_WAIT_TIME = "//*[contains(@class, 'max-wait-time')]"; -- -- private final static String XPATH_SELECTED_CONNECTION_ARRIVAL_TIME = -- "//*[@translate='trillian.connections.arrival_label']"; -- -- private final static String XPATH_RECOMMENDED_DEPARTIRE_TIME_ID = "//*[@id='recommendedDepartureTime']"; -- -- private final static String XPATH_CLOSE_DIALOG_BUTTON = -- "//linti-dialog//linti-footerbar//button[@translate='common.close']"; -- -- private final static String XPATH_CONFIRM_WAIT_RECOMMENDATION_BUTTON_ID = "//*[@id='confirmRecommendationButton']"; -- -- private final static String XPATH_REJECT_WAIT_RECOMMENDATION_BUTTON_ID = "//*[@id='rejectRecommendationButton']"; -- -- private final static String XPATH_WAIT_RECOMMENDATION_CONFIRMATION_MESSAGE = "//*[@id='connectionsWaitingConfirmation']/p/span[2]"; -- -- @FindBy(how = How.ID, using = "currentStationNotFoundTitle") -- private WebElement currentStationNotFoundTitle; -- -- @FindBy(how = How.ID, using = "currentStationTitle") -- private WebElement currentStationTitle; -- -- @FindBy(how = How.CLASS_NAME, using = "toggle-sidemenu") -- private WebElement sideMenu; -- -- @FindBy(how = How.ID, using = "ConnectionsEntry") -- private WebElement connectionsEntry; -- -- @FindBy(how = How.XPATH, using = XPATH_BACK_BUTTON) -- private WebElement goBackButton; -- -- -- private boolean isSelectedConnectionDialogOpen = false; -- -- public ConnectionPage(final WebDriver driver, final SeleniumHelper seleniumHelper) { -- super(driver, seleniumHelper); -- } -- -- /** -- * Selects the tab showing the wait recommendations -- */ -- public void selectWaitRecommendationsTab() { -- switchDriverToTrillianFrame(); -- this.driver.findElement(By.xpath(XPATH_MENU_TAB_INBOUND_CONNECTIONS)).click(); -- } -- -- /** -- * Extracts the complete current station name content -- * -- * @return complete content inside the title tag (h2) -- */ -- public String getCurrentStationName() { -- switchDriverToTrillianFrame(); -- WebElement stationTitle = getElementByXpathExpressionAndFluentWait(5, 1, XPATH_CURRENT_STATION_TITLE_ID); -- return stationTitle.getText(); -- } -- -- /** -- * Checks if the current title element is displayed -- * -- * @return -- */ -- public boolean isTitleVisibleDisplayed() { -- switchDriverToTrillianFrame(); -- WebElement stationVisible = getElementByXpathExpressionAndFluentWait(5, 1, XPATH_CURRENT_STATION_TITLE_ID); -- return stationVisible.isDisplayed(); -- } -- -- /** -- * Retrieves the inbound connection element by the specified xpath index -- * -- * !!! NOTE !!! XPath indexes of array elements begin from 1, not from ZERO!!! -- * -- * @param xpathIndex xpath index of inbound connection element that is to be retrieved -- * @return -- */ -- public WebElement getInboundConnectionButtonByIndex(int xpathIndex) { -- switchDriverToTrillianFrame(); -- String xpathExpression = XPATH_INBOUND_CONNECTION_NUMBER.replace("{xpathIndex}", String.valueOf(xpathIndex)); -- return getElementByXpathExpressionAndFluentWait(5, 1, xpathExpression); -- } -- -- -- /** -- * Selects the specified inbound connection -- * -- * !!! NOTE !!! XPath indexes of array elements begin from 1, not from ZERO!!! -- * -- * @param xpathIndex index of the inbound connection that is to be selected -- */ -- public void selectInboundConnectionByIndex(int xpathIndex) { -- switchDriverToTrillianFrame(); -- WebElement inboundConnectionLiTag = getInboundConnectionButtonByIndex(xpathIndex); -- if (inboundConnectionLiTag == null) { -- LOG.error("Cannot find inbound connection with the xpathIndex: " + xpathIndex); -- return; -- -- } -- -- if (inboundConnectionLiTag.getAttribute("class").contains("selected")) { -- LOG.info("The inbound connection with the index: " -- + xpathIndex -- + " appears to be selected alredy, aborting select"); -- return; -- } -- seleniumHelper.touchByWebElement(inboundConnectionLiTag); -- isSelectedConnectionDialogOpen = true; -- } -- -- /** -- * Clicks the CONFIRM button on the currently selected wait recommendation -- */ -- public void confirmCurrentlySelectedWaitRecommendation() { -- switchDriverToTrillianFrame(); -- WebElement confirmButton = this.driver.findElement(By.xpath(XPATH_CONFIRM_WAIT_RECOMMENDATION_BUTTON_ID)); -- confirmButton.click(); -- isSelectedConnectionDialogOpen = false; -- } -- -- /** -- * Clicks the REJECT button on the currently selected wait recommendation -- */ -- public void rejectCurrentlySelectedWaitRecommendation() { -- switchDriverToTrillianFrame(); -- WebElement confirmButton = this.driver.findElement(By.xpath(XPATH_REJECT_WAIT_RECOMMENDATION_BUTTON_ID)); -- confirmButton.click(); -- isSelectedConnectionDialogOpen = false; -- } -- -- /** -- * Retrieves the status of the selected connection (if it exists), null otherwise -- * -- * @return -- */ -- public InboundConnectionStatus getSelectedInboundConnectionStatus() { -- switchDriverToTrillianFrame(); -- boolean broken = getElementByXpathExpressionAndFluentWait(3, 1, XPATH_SELECTED_CONNECTION_STATUS_BROKEN).isDisplayed(); -- boolean inDanger = getElementByXpathExpressionAndFluentWait(3, 1, XPATH_SELECTED_CONNECTION_STATUS_IN_DANGER).isDisplayed(); -- -- if (broken) { -- return InboundConnectionStatus.BROKEN; -- } -- -- if (inDanger) { -- return InboundConnectionStatus.POTENTIALLY_BROKEN; -- } -- -- return InboundConnectionStatus.OK; -- } -- -- -- /** -- * Extracts the max wait time from the selected element if any -- * -- * @return -- */ -- public String getSelectedConnectionMaxWaitTime() { -- switchDriverToTrillianFrame(); -- WebElement maxWaitTimeSpan = -- getElementByXpathExpressionAndFluentWait(5, 1, XPATH_SELECTED_CONNECTION_MAX_WAIT_TIME); -- if (null == maxWaitTimeSpan) { -- return null; -- } -- return maxWaitTimeSpan.getText(); -- } -- -- /** -- * Extracts the arrival time from the selected element if any -- * -- * @return -- */ -- public String getSelectedConnectionArrivalTime() { -- switchDriverToTrillianFrame(); -- WebElement arrivalTimeDiv = getElementByXpathExpressionAndFluentWait(5, 1, -- XPATH_SELECTED_CONNECTION_ARRIVAL_TIME + "/parent::*"); -- if (null == arrivalTimeDiv) { -- return null; -- } -- return arrivalTimeDiv.getText(); -- } -- -- /** -- * Extracts the recommended departure time (together with the label) -- * -- * @return -- */ -- public String getRecommendedDepartureTimeHeaderContents() { -- switchDriverToTrillianFrame(); -- return getElementByXpathExpressionAndFluentWait(5, 1, XPATH_RECOMMENDED_DEPARTIRE_TIME_ID).getText(); -- } -- -- /** -- * Returns the confirmation text of an internal inbound connection. -- * -- * @return -- */ -- public String getConfirmationTextContent() { -- return getElementByXpathExpressionAndFluentWait(5, 1, XPATH_WAIT_RECOMMENDATION_CONFIRMATION_MESSAGE).getText(); -- } -- -- /** -- * Closes the connection details dialog -- * -- * First checks if the dialog is active -- */ -- public void closeDialogIfDisplayed() { -- if (isSelectedConnectionDialogOpen) { -- WebElement closeDialog = getElementByXpathExpressionAndFluentWait(3, 1, XPATH_CLOSE_DIALOG_BUTTON); -- if (closeDialog.isDisplayed()) { -- seleniumHelper.touchByWebElement(closeDialog); -- isSelectedConnectionDialogOpen = false; -- } -- } -- } -- -- /** -- * Switches the selenium web driver to the trillian iFrame -- * -- * Since the SLARTI is based on many frames -- * we have to make sure that the driver is currently -- * in the trillian iFrame, otherwise the searched XPaths -- * won't be found -- */ -- private void switchDriverToTrillianFrame() { -- BaseTestTrillian.switchToFrame(TRILLIAN_IFRAME_ID); -- } -- -- /** -- * Touch header bar's back button -- */ -- public void touchHeaderBarBackButton() { -- switchDriverToTrillianFrame(); -- WebElement element = BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(goBackButton)); -- element.click(); -- } -- -- /** -- * Extracts the element by the specified xpath expression with the help of the FluentWait class -- * -- * FluentWait polls until if finds the element or the timeout setting is reached. Thereby -- * NoSuchElement exceptions are ignored which stops selenium driver from crashing if -- * the element is not yet there -- * -- * @param timeout maximal timeout to wait for the element to show up (in seconds) -- * @param polling interval between each check on element existence (in seconds) -- * @param xpath xpath selected of the element that is being searched -- * @return -- */ -- private WebElement getElementByXpathExpressionAndFluentWait(int timeout, int polling, String xpath) { -- // check parameter validity -- if (timeout <= 0) -- timeout = 5; -- if (polling <= 0) -- polling = 1; -- -- Wait wait = new FluentWait(driver) -- .withTimeout(Duration.ofSeconds(timeout)) -- .pollingEvery(Duration.ofSeconds(polling)) -- .ignoring(NoSuchElementException.class); -- Function<WebDriver, WebElement> waitFunction = -- (WebDriver webDriver) -> webDriver.findElement(By.xpath(xpath)); -- return (WebElement) wait.until(waitFunction); -- } -- -- -- /** -- * Available inbound connection statuses enum -- * -- * Only for conveniece -- */ -- public static enum InboundConnectionStatus { -- BROKEN, POTENTIALLY_BROKEN, OK -- } -- -- public List<String> checkForIncorectLineNumbers() { -- switchDriverToTrillianFrame(); -- String XPATH_LINE_NUMBER = "//ul[@id='inboundConnectionsList']/li//span[@ng-if]"; -- String XPATH_LINE_DIRECTION = "//ul[@id='inboundConnectionsList']/li//span[@class='font-important ng-binding ng-scope']"; -- seleniumHelper.waitByXpath(XPATH_LINE_NUMBER); -- seleniumHelper.waitByXpath(XPATH_LINE_DIRECTION); -- List<WebElement> elements = seleniumHelper.getWebElements(XPATH_LINE_NUMBER); -- elements.addAll(seleniumHelper.getWebElements(XPATH_LINE_DIRECTION)); -- List<String> labels = new ArrayList<>(); -- for (WebElement element : elements) { -- labels.add(element.getText()); -- } -- return labels; -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/DeparturePage.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/DeparturePage.java -deleted file mode 100644 -index e1ed137..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/DeparturePage.java -+++ /dev/null -@@ -1,108 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.pages; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.Element; --import org.joda.time.format.DateTimeFormat; --import org.joda.time.format.DateTimeFormatter; --import org.openqa.selenium.By; --import org.openqa.selenium.WebDriver; --import org.openqa.selenium.WebElement; -- --import static org.junit.Assert.assertEquals; -- --/** -- * Departure page to help extract information from Trillian Departures -- * -- * Created by martindobrev on 1/11/17. -- */ --public class DeparturePage extends Element { -- -- /* -- * constants that are to be used in element selectors -- */ -- private final static String TRILLIAN_IFRAME_ID = "module-Trillian"; -- private final static String XPATH_NO_DEPARTURES_LABEL = "//p[@id='no-departures']"; -- private final static String XPATH_DEPARTURES = "//ul/li"; -- private final static String XPATH_DEPARTURE_BY_INDEX = XPATH_DEPARTURES + "[{xpathIndex}]"; -- -- /** -- * DateTimeFormatter to transform the displayed times on the page to datetime obejcts and vice versa -- */ -- public final static DateTimeFormatter departureTimeFormatter = DateTimeFormat.forPattern("HH:mm"); -- -- public DeparturePage(final WebDriver driver, final SeleniumHelper seleniumHelper) { -- super(driver, seleniumHelper); -- } -- -- -- /** -- * Checks if some departures are available -- * -- * The no departures label is used - if it is visible, there are no departures -- * -- * @return -- */ -- public boolean departuresAvailable() { -- switchDriverToTrillianFrame(); -- final WebElement noDeparturesLabel = this.driver.findElement(By.xpath(XPATH_NO_DEPARTURES_LABEL)); -- return !noDeparturesLabel.isDisplayed(); -- } -- -- /** -- * Returns the number of displayed departures in the UI -- * -- * @return -- */ -- public int getNumberOfDepartures() { -- switchDriverToTrillianFrame(); -- return this.driver.findElements(By.xpath(XPATH_DEPARTURES)).size() - 1; // -1 because of the table header -- } -- -- public String getDepartureName(final int xpathIndex) { -- return getElementValue(xpathIndex, "section[1]"); -- } -- -- public String getDepartureTime(final int xpathIndex) { -- return getElementValue(xpathIndex, "section[2]"); -- } -- -- public String getDepartureDirection(final int xpathIndex) { -- return getElementValue(xpathIndex, "section[3]"); -- } -- -- public String getDeparturePlatform(final int xpathIndex) { -- return getElementValue(xpathIndex, "section[4]"); -- } -- -- public String getDepartureDelay(final int xpathIndex) { -- return getElementValue(xpathIndex, "section[5]"); -- } -- -- private String getElementValue(final int xpathIndex, String path) { -- switchDriverToTrillianFrame(); -- final String xpathSelector = XPATH_DEPARTURE_BY_INDEX.replaceAll("\\{xpathIndex\\}", String.valueOf(xpathIndex + 1)); -- final WebElement connectionEl = this.driver.findElement(By.xpath(xpathSelector)); -- return connectionEl.findElement(By.xpath(path)).getText(); -- } -- -- -- public void assertDelay(final int xpathIndex, final String expectedValue) { -- final String xpathSelector = XPATH_DEPARTURE_BY_INDEX.replaceAll("\\{xpathIndex\\}", String.valueOf(xpathIndex + 1)); -- final WebElement connectionEl = this.driver.findElement(By.xpath(xpathSelector)); -- final WebElement connectionDelay = connectionEl.findElement(By.xpath("section[5]")); -- assertEquals("Connection delay must be " + expectedValue, expectedValue, connectionDelay.getText()); -- } -- -- /** -- * Switches the selenium web driver to the trillian iFrame -- * -- * Since the GUI has multiple nested frames -- * we have to make sure that the driver is currently -- * in the trillian iFrame, otherwise the searched XPaths -- * won't be found -- */ -- private void switchDriverToTrillianFrame() { -- BaseTestTrillian.switchToFrame(TRILLIAN_IFRAME_ID); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/MessagingPage.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/MessagingPage.java -deleted file mode 100644 -index 62aff07..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/MessagingPage.java -+++ /dev/null -@@ -1,324 +0,0 @@ -- --package ch.post.it.paisa.trillian.test.ui.pages; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.Element; --import org.junit.Assert; --import org.openqa.selenium.*; --import org.openqa.selenium.remote.RemoteWebElement; --import org.openqa.selenium.support.FindBy; --import org.openqa.selenium.support.How; --import org.openqa.selenium.support.ui.ExpectedConditions; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; -- --import java.util.HashMap; --import java.util.LinkedList; --import java.util.List; --import java.util.Map; -- -- --public class MessagingPage extends Element { -- private final static Logger LOG = LoggerFactory.getLogger(MessagingPage.class); -- private final static String TAG_NAME_BACK_BUTTON = "linti-button-back"; -- private final static String XPATH_NOTIFICATION_LIST_ITEM = "//ul[@id='notifications']/li"; -- private final static String XPATH_RECEIVED_MESSAGES = "//div[contains(@class,'message') and contains(@class,'received')]"; -- private final static String XPATH_TEXT_MESSAGES_BUTTON = "//*[@id='text-messages']"; -- private final static String XPATH_NOTIFICATIONS_BUTTON = "//*[@id='notifications']"; -- private final static String XPATH_NOTIFICATIONS_PLANNING_AREA_BUTTON = "//*[@id='notifications-planning-area']"; -- private final static String XPATH_NOTIFICATIONS_STOPS_BUTTON = "//*[@id='notifications-stops']"; -- private final static String XPATH_NOTIFICATIONS_LINE_BUTTON = "//*[@id='notifications-line']"; -- -- @FindBy(how = How.TAG_NAME, using = TAG_NAME_BACK_BUTTON) -- private WebElement goBackButton; -- -- @FindBy(how = How.ID, using = "headerbarTitle") -- private WebElement headerbarTitle; -- -- @FindBy(how = How.XPATH, using = XPATH_TEXT_MESSAGES_BUTTON) -- private WebElement textMessagesButton; -- -- @FindBy(how = How.XPATH, using = XPATH_NOTIFICATIONS_BUTTON) -- private WebElement notificationsButton; -- -- @FindBy(how = How.XPATH, using = XPATH_NOTIFICATIONS_PLANNING_AREA_BUTTON) -- private WebElement notificationsPlanningAreaButton; -- -- @FindBy(how = How.XPATH, using = XPATH_NOTIFICATIONS_STOPS_BUTTON) -- private WebElement notificationsStopsButton; -- -- @FindBy(how = How.XPATH, using = XPATH_NOTIFICATIONS_LINE_BUTTON) -- private WebElement notificationsLineButton; -- -- public MessagingPage(final WebDriver driver, final SeleniumHelper seleniumHelper) { -- super(driver, seleniumHelper); -- } -- -- public void waitForTitle() { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- BaseTestTrillian.getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("headerbarTitle"))); -- } -- -- public void touchGoBackButton() { -- seleniumHelper.touchByWebElement(goBackButton); -- } -- -- public static String getTextFromMessageElement(WebElement messageElement) { -- return messageElement.findElement(By.xpath("span[contains(@class,'text')]")).getText(); -- } -- -- private WebElement getLatestMessage() { -- final List<WebElement> webElements = this.driver.findElements(By.xpath(XPATH_RECEIVED_MESSAGES)); -- if (!webElements.isEmpty()) { -- return webElements.get(webElements.size() - 1); -- } -- return null; -- } -- -- public void assertLatestMessageText(final String expectedText) { -- final RemoteWebElement latestMessage = (RemoteWebElement) getLatestMessage(); -- Assert.assertNotNull(latestMessage); -- final String text = getTextFromMessageElement(latestMessage); -- Assert.assertEquals(expectedText, text); -- } -- -- public boolean isMessagePresent(final String expectedTime, final String expectedText) { -- try { -- final List<WebElement> messageEntryElements = this.driver.findElements(By.xpath(XPATH_RECEIVED_MESSAGES)); -- if (!messageEntryElements.isEmpty()) { -- for (WebElement messageEntryElement : messageEntryElements) { -- WebElement textElement = messageEntryElement.findElement(By.xpath("span[contains(@class,'text')]")); -- WebElement timeElement = messageEntryElement.findElement(By.xpath("span[@class='metadata']/span[contains(@class,'time')]")); -- -- // verify text -- boolean isTextMatched = (textElement.getText().contains(expectedText)); -- -- // verify time -- boolean isTimeMatched = (timeElement.getText().contains(expectedTime)); -- -- if (isTimeMatched && isTextMatched) { -- return true; -- } -- LOG.error("Could not find message with time=\"" + expectedTime + "\", text=\"" + expectedText + "\""); -- } -- } else { -- LOG.error("There is no message in the list."); -- } -- } catch (NoSuchElementException e) { -- LOG.error("", e); -- } -- return false; -- } -- -- public void assertCallRequest(String expectedName, String expectedPhoneNumber, String expectedButtonText) { -- final List<WebElement> messageEntryElements = this.driver.findElements(By.xpath(XPATH_RECEIVED_MESSAGES)); -- if (!messageEntryElements.isEmpty()) { -- boolean callRequestFound = false; -- for (WebElement messageEntryElement : messageEntryElements) { -- WebElement firstColumnElement = messageEntryElement.findElement(By.xpath("div[1]")); -- -- // verify name -- WebElement nameElement = firstColumnElement.findElement(By.xpath("div[1]")); -- boolean isNameMatched = expectedName.equals(nameElement.getText()); -- -- // verify phone number -- WebElement phoneNumberElement = firstColumnElement.findElement(By.xpath("div[2]")); -- boolean isPhoneNumberMatched = expectedPhoneNumber.equals(phoneNumberElement.getText()); -- -- // verify button text -- WebElement secondColumnElement = messageEntryElement.findElement(By.xpath("div[2]")); -- boolean isButtonTextMatched; -- try { -- seleniumHelper.waitUntil(webDriver -> secondColumnElement.findElement(By.xpath("button/span[text()='" + expectedButtonText + "']"))); -- isButtonTextMatched = true; -- } catch (TimeoutException e) { -- isButtonTextMatched = false; -- } -- -- callRequestFound = isNameMatched && isPhoneNumberMatched && isButtonTextMatched; -- if (callRequestFound) { -- break; -- } -- } -- -- Assert.assertTrue("Could not find call request with name=\"" + expectedName + "\", phone number=\"" + expectedPhoneNumber + "\", button text=\"" + expectedButtonText + "\"", callRequestFound); -- } else { -- Assert.fail("There is no call request in the list."); -- } -- -- } -- -- public void assertNotification(String expectedTitle, String expectedMessage, String expectedDate, String expectedIcon) { -- final List<WebElement> notificationElements = this.driver.findElements(By.xpath(XPATH_NOTIFICATION_LIST_ITEM)); -- if (!notificationElements.isEmpty()) { -- boolean notificationFound = false; -- List<Map<String, String>> currentNotifications = new LinkedList<>(); -- for (WebElement notificationElement : notificationElements) { -- WebElement firstColumnElement = notificationElement.findElement(By.xpath("div[2]")); -- -- // verify title -- WebElement titleElement = firstColumnElement.findElement(By.xpath("div[1]")); -- String currentTitle = titleElement.getText(); -- boolean isTitleMatched = currentTitle.equals(expectedTitle); -- -- // verify message -- WebElement messageElement = firstColumnElement.findElement(By.xpath("div[2]")); -- String currentMessage = messageElement.getText(); -- boolean isMessageMatched = currentMessage.equals(expectedMessage); -- -- // verify date -- WebElement dateElement = firstColumnElement.findElement(By.xpath("div[3]")); -- String currentDate = dateElement.getText(); -- -- // TODO expectedDate is GMT but currentDate the data in the local time zone? So chop of the time for the moment -- boolean isDateMatched = currentDate.substring(0, 10).equals(expectedDate.substring(0, 10)); -- -- WebElement secondColumnElement = notificationElement.findElement(By.xpath("div[1]")); -- -- // verify icon -- WebElement iconElement = secondColumnElement.findElement(By.xpath("a[not(contains(@class,'ng-hide'))]")); -- String currentIconClass = iconElement.getAttribute("class"); -- boolean isIconMatched = currentIconClass.contains("icon-" + expectedIcon.toLowerCase()); -- -- Map<String, String> currentNotification = new HashMap<>(); -- currentNotification.put("title", currentTitle); -- currentNotification.put("message", currentMessage); -- currentNotification.put("date", currentDate); -- currentNotification.put("iconClass", currentIconClass); -- currentNotifications.add(currentNotification); -- -- notificationFound = isTitleMatched && isMessageMatched && isDateMatched && isIconMatched; -- -- if (notificationFound) { -- break; -- } -- } -- -- // create a message from the list of current notifications -- StringBuilder currentNotificationsMessageBuilder = new StringBuilder(); -- currentNotificationsMessageBuilder.append("\n\n=== Current Notifications ===\n"); -- for (Map<String, String> currentNotification : currentNotifications) { -- currentNotificationsMessageBuilder.append("\n" + currentNotification); -- } -- currentNotificationsMessageBuilder.append("\n\n"); -- -- Assert.assertTrue("Could not find a notification with title=\"" + expectedTitle + "\", message=\"" + expectedMessage + "\", date=\"" + expectedDate + "\", icon=\"" + expectedIcon + "\" from the current notifications: " + currentNotificationsMessageBuilder, notificationFound); -- } else { -- Assert.fail("There is no notification in the list."); -- } -- } -- -- public void assertThatThereAreNoNotifications() { -- try { -- seleniumHelper.waitUntil((webDriver) -> seleniumHelper.withoutTimeout(() -> this.driver.findElements(By.xpath(XPATH_NOTIFICATION_LIST_ITEM)).size()) == 0); -- } catch (TimeoutException e) { -- // There is still a notification, so generate the existing notification message to print out to the log -- final List<WebElement> notificationElements = this.driver.findElements(By.xpath(XPATH_NOTIFICATION_LIST_ITEM)); -- List<Map<String, String>> currentNotifications = new LinkedList<>(); -- for (WebElement notificationElement : notificationElements) { -- WebElement firstColumnElement = notificationElement.findElement(By.xpath("div[1]")); -- WebElement titleElement = firstColumnElement.findElement(By.xpath("div[1]")); -- WebElement messageElement = firstColumnElement.findElement(By.xpath("div[2]")); -- WebElement dateElement = firstColumnElement.findElement(By.xpath("div[3]")); -- -- String currentTitle = titleElement.getText(); -- String currentMessage = messageElement.getText(); -- String currentDate = dateElement.getText(); -- -- WebElement secondColumnElement = notificationElement.findElement(By.xpath("div[2]")); -- WebElement iconElement = secondColumnElement.findElement(By.xpath("a[not(contains(@class,'ng-hide'))]")); -- -- String currentIconClass = iconElement.getAttribute("class"); -- -- Map<String, String> currentNotification = new HashMap<>(); -- currentNotification.put("title", currentTitle); -- currentNotification.put("message", currentMessage); -- currentNotification.put("date", currentDate); -- currentNotification.put("iconClass", currentIconClass); -- currentNotifications.add(currentNotification); -- } -- -- // create a message from the list of current notifications -- StringBuilder currentNotificationsMessageBuilder = new StringBuilder(); -- currentNotificationsMessageBuilder.append("\n=== Current Notifications ===\n"); -- for (Map<String, String> currentNotification : currentNotifications) { -- currentNotificationsMessageBuilder.append("\n" + currentNotification); -- } -- currentNotificationsMessageBuilder.append("\n\n"); -- -- Assert.fail("There are still notifications displayed." + currentNotificationsMessageBuilder); -- } -- } -- -- public void assertThatThereAreNoTextMessagesOrCallRequests() { -- try { -- seleniumHelper.waitUntil((webDriver) -> seleniumHelper.withoutTimeout(() -> this.driver.findElements(By.xpath(XPATH_RECEIVED_MESSAGES)).size()) == 0); -- } catch (TimeoutException e) { -- Assert.fail("There are one or more text messages or call requests displayed, but there should be none."); -- } -- } -- -- public void assertLatestMessageHasOkButton() { -- final RemoteWebElement latestMessage = (RemoteWebElement) getLatestMessage(); -- Assert.assertNotNull(latestMessage); -- final WebElement buttonOk = latestMessage.findElement(By.className("ok-button")); -- Assert.assertNotNull(buttonOk); -- } -- -- public void assertLatestMessageHasOkAndCancelButton() { -- final RemoteWebElement latestMessage = (RemoteWebElement) getLatestMessage(); -- Assert.assertNotNull(latestMessage); -- final WebElement buttonCancel = latestMessage.findElement(By.className("cancel-button")); -- Assert.assertNotNull(buttonCancel); -- final WebElement buttonOk = latestMessage.findElement(By.className("ok-button")); -- Assert.assertNotNull(buttonOk); -- } -- -- -- public void assertLatestMessageIsWithoutButtons() { -- final RemoteWebElement latestMessage = (RemoteWebElement) getLatestMessage(); -- Assert.assertNotNull(latestMessage); -- final WebElement buttonCancel = latestMessage.findElement(By.className("cancel-button")); -- Assert.assertNull(buttonCancel); -- final WebElement buttonOk = latestMessage.findElement(By.className("ok-button")); -- Assert.assertNull(buttonOk); -- } -- -- public void textMessagesButtonIsClickable() { -- seleniumHelper.waitUntil(ExpectedConditions.elementToBeClickable(textMessagesButton)); -- } -- -- public void goToTextMessages() { -- textMessagesButtonIsClickable(); -- textMessagesButton.click(); -- } -- -- public void goToAllNotifications() { -- // open menu -- notificationsButton.click(); -- -- // submenu may not be visible -- if (!driver.findElements(By.xpath(XPATH_NOTIFICATIONS_PLANNING_AREA_BUTTON)).isEmpty() && notificationsPlanningAreaButton.isDisplayed()) { -- // click submenu -- notificationsPlanningAreaButton.click(); -- } -- } -- -- public void goToStopNotifications() { -- // open menu -- notificationsButton.click(); -- // click submenu -- notificationsStopsButton.click(); -- // TODO: make this able to select the third entry in the subsubmenu or something? -- } -- -- public void goToLineNotifications() { -- // open menu -- notificationsButton.click(); -- // click submenu -- notificationsLineButton.click(); -- } --} -- -- -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/OverviewPage.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/OverviewPage.java -deleted file mode 100644 -index 24b3518..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/OverviewPage.java -+++ /dev/null -@@ -1,113 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.pages; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.Element; --import org.openqa.selenium.*; --import org.openqa.selenium.support.FindBy; --import org.openqa.selenium.support.How; --import org.openqa.selenium.support.ui.ExpectedConditions; -- --import java.util.List; -- -- --public class OverviewPage extends Element { -- -- private final static String XPATH_PHONEBOOK_BUTTON = "//*[@id='goToPhonebookButton']"; -- private final static String XPATH_MESSAGES_BUTTON = "//*[@id='goToMessagingButton']"; -- private final static String XPATH_CALLLOG_ENTRIES = "//*[@id='callLogEntry']/li"; -- private final static String XPATH_FAVOURITES_ENTRY = "//*[@id='favouritesEntry']/li"; -- private final static String XPATH_CALLBACK_REQUEST_BUTTON = "//*[@id='callbackRequest']"; -- -- private static final String XPATH_DIALPAD_OPEN_BUTTON = "//*[@id='goToKeypadButton']"; -- private static final String XPATH_DIALPAD_CLOSE_BUTTON = "//*[@id='dialpadCloseButton']"; -- private static final String XPATH_DIALPAD_DIALOG_SHOW = "//*[@id='dialpadDialog' and not (contains(@class,'ng-hide'))]"; -- private static final String XPATH_DIALPAD_DIALOG_HIDE = "//*[@id='dialpadDialog']/dialog-overlay[last() and (contains(@class,'ng-hide'))]"; -- //"//*[@id='dialpadDialog' and (contains(@class,'ng-hide'))]"; -- -- private static final String XPATH_CALLLOG_BUTTON = "//*[@id='goToCallLogButton']"; -- -- -- @FindBy(how = How.ID, using = "trillianTitle") -- private WebElement trillianTitle; -- -- @FindBy(how = How.XPATH, using = XPATH_PHONEBOOK_BUTTON) -- private WebElement goToPhonebookButton; -- -- @FindBy(how = How.XPATH, using = XPATH_MESSAGES_BUTTON) -- private WebElement goToMessagesButton; -- -- @FindBy(how = How.XPATH, using = XPATH_DIALPAD_OPEN_BUTTON) -- private WebElement dialPadOpenButton; -- -- @FindBy(how = How.XPATH, using = XPATH_DIALPAD_CLOSE_BUTTON) -- private WebElement dialPadCloseButton; -- -- @FindBy(how = How.XPATH, using = XPATH_CALLLOG_BUTTON) -- private WebElement callLogButton; -- -- @FindBy(how = How.XPATH, using = XPATH_CALLBACK_REQUEST_BUTTON) -- private WebElement callbackRequest; -- -- -- public OverviewPage(final WebDriver driver, final SeleniumHelper seleniumHelper) { -- super(driver, seleniumHelper); -- } -- -- public void waitForTitle() { -- BaseTestTrillian.waitForElement(trillianTitle); -- } -- -- public void touchGoToPhonebookButton() { -- seleniumHelper.touchByWebElement(goToPhonebookButton); -- } -- -- public void touchGoToMessagesButton() { -- seleniumHelper.touchByWebElement(goToMessagesButton); -- } -- -- public void touchInitiateCallFromFavourite() { -- touchInitiateCallFromFavourite(1); -- } -- -- public void touchInitiateCallFromFavourite(int index) { -- seleniumHelper.touchByXpath("//*[@id=\"favouritesEntry\"]/li[" + index + "]/a[1]"); -- } -- -- public void touchDialPadButton() { -- BaseTestTrillian.switchToFrame("module-Trillian"); -- seleniumHelper.touchByWebElement(dialPadOpenButton); -- } -- -- public void touchGoToCalllogButton() { -- seleniumHelper.touchByWebElement(callLogButton); -- } -- -- public void assertDialPadVisible() { -- isWebElementVisibleByXpath(XPATH_DIALPAD_DIALOG_SHOW); -- } -- -- public void assertDialPadClosed() { -- isWebElementVisibleByXpath(XPATH_DIALPAD_DIALOG_HIDE); -- } -- -- public void touchDialPadCloseButton() { -- seleniumHelper.touchByWebElement(dialPadCloseButton); -- } -- -- public void touchCallbackRequestButton() { -- seleniumHelper.touchByWebElement(callbackRequest); -- } -- -- public List<WebElement> getCallLogList() { -- return BaseTestTrillian.getWait().until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(XPATH_CALLLOG_ENTRIES))); -- } -- -- public int getCallLogSize() { -- return getCallLogList().size(); -- } -- -- public List<WebElement> getFavouriteEntries() { -- return seleniumHelper.getWebElements(XPATH_FAVOURITES_ENTRY); -- } --} -diff --git a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/PhonebookPage.java b/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/PhonebookPage.java -deleted file mode 100644 -index 5940fa6..0000000 ---- a/trillian-test/src/test/java/ch/post/it/paisa/trillian/test/ui/pages/PhonebookPage.java -+++ /dev/null -@@ -1,103 +0,0 @@ --package ch.post.it.paisa.trillian.test.ui.pages; -- --import ch.post.it.paisa.slarti.test.ui.base.SeleniumHelper; --import ch.post.it.paisa.trillian.test.ui.BaseTestTrillian; --import ch.post.it.paisa.trillian.test.ui.elements.Element; --import org.openqa.selenium.By; --import org.openqa.selenium.NoSuchElementException; --import org.openqa.selenium.WebDriver; --import org.openqa.selenium.WebElement; --import org.openqa.selenium.support.FindBy; --import org.openqa.selenium.support.How; --import org.openqa.selenium.support.ui.ExpectedConditions; -- --import java.util.List; -- --import static org.junit.Assert.assertEquals; --import static org.junit.Assert.assertTrue; -- -- --public class PhonebookPage extends Element { -- -- private final static String CSS_PHONEBOOK_ENTRIES = "li.phonebook-entry"; -- private final static String XPATH_LIMITED_PHONEBOOK_DISPLAY_LABEL = "//*[@id='trillian-phonebook-limited-label']"; -- private final static String XPATH_BACK_BUTTON = "//*[@linti-tap=\"headerbar.backAction()\"]"; -- private final static String XPATH_PHONEBOOK_ENTRY_BY_INDEX = "//*[@id='phonebookEntries']/li[{index}]/a[1]"; -- private final static String XPATH_SEARCH_BUTTON = "//*[@id='searchButton']"; -- private final static String XPATH_SEARCH_TEXTBOX = "//*[@id='searchText']"; -- private final static String XPATH_TITLE_TEXT = "//*[@id='headerbarTitle']"; -- -- @FindBy(how= How.XPATH, using=XPATH_BACK_BUTTON) -- private WebElement goBackButton; -- -- @FindBy(how= How.ID, using="trillianPhonebookTitle") -- private WebElement trillianPhonebookTitle; -- -- @FindBy(how= How.XPATH, using=XPATH_TITLE_TEXT) -- private WebElement titleText; -- -- @FindBy(how= How.XPATH, using=XPATH_SEARCH_BUTTON) -- private WebElement searchButton; -- -- @FindBy(how= How.XPATH, using=XPATH_SEARCH_TEXTBOX) -- private WebElement searchTextbox; -- -- public PhonebookPage(final WebDriver driver, final SeleniumHelper seleniumHelper) { -- super(driver, seleniumHelper); -- } -- -- public void touchGoBackButton() { -- WebElement element = BaseTestTrillian.getWait().until(ExpectedConditions.elementToBeClickable(goBackButton)); -- element.click(); -- } -- -- public void waitForTitle() { -- BaseTestTrillian.getWait().until(ExpectedConditions.visibilityOf(trillianPhonebookTitle)); -- } -- -- public String getTitle() { -- waitForTitle(); -- return titleText.getText(); -- } -- -- public void placeCallOnPhonebookEntry(final int entryIndex) { -- final List<WebElement> entries = driver.findElements(By.cssSelector(CSS_PHONEBOOK_ENTRIES)); -- assertTrue(entries.size() >= entryIndex); -- -- String xpathFirstPhonebookEntryButton = XPATH_PHONEBOOK_ENTRY_BY_INDEX.replace("{index}", String.valueOf(entryIndex)); -- final List<WebElement> phonebookButton = driver.findElements(By.xpath(xpathFirstPhonebookEntryButton)); -- assertEquals(phonebookButton.size(), 1); -- seleniumHelper.waitUntil(ExpectedConditions.elementToBeClickable(phonebookButton.get(0))); -- seleniumHelper.touchByWebElement(phonebookButton.get(0)); -- } -- -- public int getPhonebookEntriesSize() { -- final List<WebElement> entries = BaseTestTrillian.getWait().until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector(CSS_PHONEBOOK_ENTRIES))); -- -- return entries.size(); -- } -- -- /** -- * Checks if the limited phonebook display label is shown -- * -- * This is the label that notifies the user about the fact that there are more entries -- * than are currently being shown -- * -- * @return -- */ -- public boolean isDispayLimitedTextShown() { -- try { -- final WebElement limitedPhonebookEntriesLabel = seleniumHelper.getWebElement(XPATH_LIMITED_PHONEBOOK_DISPLAY_LABEL); -- return limitedPhonebookEntriesLabel.isDisplayed(); -- } catch (final NoSuchElementException noElementException) { -- return false; -- } -- } -- -- public void search(String queryString) { -- searchButton.click(); -- searchTextbox.sendKeys(queryString); -- } --} -- -- - |