Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Commit

Permalink
gh-129 - added system test profile
Browse files Browse the repository at this point in the history
Added test to check the ui operation json
  • Loading branch information
p013570 committed Jun 16, 2017
1 parent 6cb5d14 commit b1d37ff
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ script:
- mvn -q test -P travis,build-extras -B
- mvn install -P quick,travis,road-traffic-demo -pl ui &
- sleep 2m
- mvn verify -P travis,system-test -Dwebdriver.gecko.driver=geckodriver -pl ui
- cd python-shell && python3 src/example.py && cd ../
- mvn -Dit.test=QueryBuilderST verify -Dwebdriver.gecko.driver=geckodriver -pl ui/
after_success:
- ./cd/before_deploy.sh
- ./cd/deploy.sh
61 changes: 61 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,65 @@
</license>
</licenses>

<profiles>
<profile>
<id>system-test</id>
<properties>
<skip.surefire.tests>true</skip.surefire.tests>
<skip.failsafe.tests>false</skip.failsafe.tests>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe.version}</version>
<executions>
<execution>
<id>system-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<skipITs>${skip.failsafe.tests}</skipITs>
<argLine>${failsafeArgLine}</argLine>
<excludes>
<exclude>**/*$*</exclude>
<exclude>**/performance/**</exclude>
</excludes>
<includes>
<include>**/*SystemTest.java</include>
<include>**/*ST.java</include>
<include>**/*STs.java</include>
<include>**/*SystemTests.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>validate</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<executions>
<execution>
<id>analyze-compile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
6 changes: 4 additions & 2 deletions ui/src/main/webapp/app/raw/raw.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ <h3>
</h3>

<div ng-repeat="(i, json) in operations track by $index">
<pre ng-show="!editingOperations">
<pre id="operation-{{i}}-json"
ng-show="!editingOperations">
{{operations[i] | json}}
</pre>
<textarea ng-model="operationsForEdit[i]"
<textarea id="editing-operation-{{i}}-json"
ng-model="operationsForEdit[i]"
ng-blur="onOperationsChange()"
ng-show="editingOperations">>
</textarea>
Expand Down
82 changes: 52 additions & 30 deletions ui/src/test/java/uk/gov/gchq/gaffer/ui/QueryBuilderST.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

Expand All @@ -17,14 +18,50 @@
* Assumes the Road Traffic Demo UI is running at localhost:8080.
* To run this selenium test you must have installed the gecko driver, see
* https://github.com/mozilla/geckodriver/releases
* This test can be run via the main method or as a junit test:
* This test can be run via maven using the system-test profile
* <pre>
* mvn -Dit.test=QueryBuilderST verify -Dwebdriver.gecko.driver=/path/to/geckodriver -pl ui/
* mvn verify -Psystem-test -Dwebdriver.gecko.driver=/path/to/geckodriver -pl ui/
* </pre>
*/
public class QueryBuilderST {
private static final int SLOW_FACTOR = 1;
private static final String URL = "http://localhost:8080/ui";
public static final String GECKO_PROPERTY = "webdriver.gecko.driver";
public static final String URL_PROPERTY = "gaffer.ui.test.url";
public static final String SLOW_FACTOR_PROPERTY = "gaffer.ui.test.slow-factor";

private static final String DEFAULT_URL = "http://localhost:8080/ui";
private static final String DEFAULT_SLOW_FACTOR = "5";

private static final String EXPECTED_OPERATION_JSON = "{\n" +
" \"class\": \"uk.gov.gchq.gaffer.operation.impl.get.GetElements\",\n" +
" \"input\": [\n" +
" {\n" +
" \"class\": \"uk.gov.gchq.gaffer.operation.data.EntitySeed\",\n" +
" \"vertex\": \"M5:10\"\n" +
" }\n" +
" ],\n" +
" \"view\": {\n" +
" \"entities\": {},\n" +
" \"edges\": {\n" +
" \"RoadUse\": {\n" +
" \"groupBy\": [],\n" +
" \"preAggregationFilterFunctions\": [\n" +
" {\n" +
" \"predicate\": {\n" +
" \"class\": \"uk.gov.gchq.koryphe.impl.predicate.IsMoreThan\",\n" +
" \"value\": {\n" +
" \"java.util.Date\": 971416800000\n" +
" }\n" +
" },\n" +
" \"selection\": [\n" +
" \"startDate\"\n" +
" ]\n" +
" }\n" +
" ]\n" +
" }\n" +
" }\n" +
" },\n" +
" \"includeIncomingOutGoing\": \"EITHER\"\n" +
"}";
private static final String EXPECTED_RESULTS[] = {
"\"group\": \"RoadUse\",\n" +
" \"source\": \"M5:10\",\n" +
Expand All @@ -37,29 +74,16 @@ public class QueryBuilderST {
" \"directed\": true,\n" +
" \"class\": \"uk.gov.gchq.gaffer.data.element.Edge\"\n"
};
public static final String GECKO_SYS_PROPERTY = "webdriver.gecko.driver";

private WebDriver driver;

public static void main(String[] args) throws Exception {
final QueryBuilderST test = new QueryBuilderST();
if (args.length < 1) {
System.out.println("Usage: <path to gecko driver>");
System.exit(1);
}

System.setProperty(GECKO_SYS_PROPERTY, args[0]);
test.setup();
try {
test.shouldFindRoadUseAroundJunctionM5_10();
} finally {
test.cleanUp();
}
}
private String url;
private int slowFactor;

@Before
public void setup() {
assertNotNull("System property " + GECKO_SYS_PROPERTY + " has not been set", System.getProperty(GECKO_SYS_PROPERTY));
assertNotNull("System property " + GECKO_PROPERTY + " has not been set", System.getProperty(GECKO_PROPERTY));
url = System.getProperty(URL_PROPERTY, DEFAULT_URL);
slowFactor = Integer.parseInt(System.getProperty(SLOW_FACTOR_PROPERTY, DEFAULT_SLOW_FACTOR));
driver = new FirefoxDriver();
}

Expand All @@ -74,10 +98,8 @@ public void cleanUp() {

@Test
public void shouldFindRoadUseAroundJunctionM5_10() throws InterruptedException {
// Go to the Google Suggest home page
driver.get(URL);

Thread.sleep(SLOW_FACTOR * 1000);
driver.get(url);
Thread.sleep(slowFactor * 1000);

// Enter the query string "Cheese"
click("add-seed");
Expand All @@ -102,9 +124,9 @@ public void shouldFindRoadUseAroundJunctionM5_10() throws InterruptedException {
click("step-4-execute");

click("open-raw");
clickTab("Results");
assertEquals(EXPECTED_OPERATION_JSON, getElement("operation-0-json").getText().trim());

// And now list the suggestions
clickTab("Results");
final String results = getElement("raw-edge-results").getText().trim();
for (String expectedResult : EXPECTED_RESULTS) {
assertTrue("Results did not contain: \n" + expectedResult
Expand All @@ -119,12 +141,12 @@ private void enterText(final String id, final String value) {
private void selectOption(final String id, final String optionValue) throws InterruptedException {
Select dropdown = new Select(getElement(id));
dropdown.selectByValue("string:" + optionValue);
Thread.sleep(SLOW_FACTOR * 500);
Thread.sleep(slowFactor * 500);
}

private void click(final String id) throws InterruptedException {
getElement(id).click();
Thread.sleep(SLOW_FACTOR * 500);
Thread.sleep(slowFactor * 500);
}

private void clickTab(final String tabTitle) {
Expand Down

0 comments on commit b1d37ff

Please sign in to comment.