-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Weather example junit + updated docs (#374)
- Loading branch information
1 parent
5d3487c
commit ed1b0e3
Showing
26 changed files
with
424 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
webtau-docs/pre-filter/installation.md → .../pre-filter/installation-groovy-runner.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Installation | ||
# Installation Of Groovy Runner | ||
|
||
Download and unzip [webtau](https://repo.maven.apache.org/maven2/com/twosigma/webtau/webtau-dist/${project.version}/webtau-dist-${project.version}-webtau.zip). | ||
Add it to your `PATH`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
:include-markdown: installation.md | ||
:include-markdown: installation-groovy-runner.md | ||
|
||
# Bare Minimum | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...ing/src/main/groovy/com/twosigma/webtau/featuretesting/WebTauEndToEndTestValidator.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2019 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.twosigma.webtau.featuretesting | ||
|
||
import com.twosigma.webtau.console.ConsoleOutputs | ||
import com.twosigma.webtau.console.ansi.Color | ||
import com.twosigma.webtau.expectation.ActualPath | ||
import com.twosigma.webtau.expectation.equality.CompareToComparator | ||
import com.twosigma.webtau.utils.FileUtils | ||
import com.twosigma.webtau.utils.JsonUtils | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
import java.util.function.Function | ||
|
||
class WebTauEndToEndTestValidator { | ||
private static final String RUN_DETAILS_FILE_NAME = 'run-details' | ||
private static final String EXPECTATIONS_DIR_NAME = 'test-expectations' | ||
|
||
private WebTauEndToEndTestValidator() { | ||
} | ||
|
||
static void validateAndSaveTestDetails(String testName, Map testDetails, Function resultConverter = { v -> v }) { | ||
def expectedPath = Paths.get(EXPECTATIONS_DIR_NAME) | ||
.resolve(testName).resolve(RUN_DETAILS_FILE_NAME + '.json') | ||
def actualPath = Paths.get(EXPECTATIONS_DIR_NAME) | ||
.resolve(testName).resolve(RUN_DETAILS_FILE_NAME + '.actual.json') | ||
|
||
def serializedTestDetails = JsonUtils.serializePrettyPrint(resultConverter.apply(testDetails)) | ||
|
||
if (! Files.exists(expectedPath)) { | ||
FileUtils.writeTextContent(expectedPath, serializedTestDetails) | ||
|
||
throw new AssertionError('make sure ' + expectedPath + ' is correct. and commit it as a baseline. ' + | ||
'test will not fail next time unless output of the test is changed') | ||
} | ||
|
||
def expectedDetails = resultConverter.apply(JsonUtils.deserializeAsMap( | ||
FileUtils.fileTextContent(expectedPath))) | ||
|
||
CompareToComparator comparator = CompareToComparator.comparator() | ||
def isEqual = comparator.compareIsEqual(new ActualPath('testDetails'), testDetails, expectedDetails) | ||
|
||
if (! isEqual) { | ||
ConsoleOutputs.out('reports are different, you can use IDE to compare files: ', Color.PURPLE, actualPath, | ||
Color.BLUE, ' and ', Color.PURPLE, expectedPath) | ||
FileUtils.writeTextContent(actualPath, serializedTestDetails) | ||
throw new AssertionError(comparator.generateEqualMismatchReport()) | ||
} else { | ||
Files.deleteIfExists(actualPath) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ting/src/test/groovy/com/twosigma/webtau/featuretesting/WebTauRestFeaturesTestData.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2019 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.twosigma.webtau.featuretesting | ||
|
||
import com.twosigma.webtau.http.testserver.TestServer | ||
import com.twosigma.webtau.http.testserver.TestServerJsonResponse | ||
import com.twosigma.webtau.http.testserver.TestServerRedirectResponse | ||
import com.twosigma.webtau.http.testserver.TestServerResponse | ||
import com.twosigma.webtau.utils.JsonUtils | ||
|
||
class WebTauRestFeaturesTestData { | ||
static void registerEndPoints(TestServer testServer) { | ||
def temperature = [temperature: 88] | ||
testServer.registerGet("/weather", json(temperature)) | ||
testServer.registerGet("/redirect", new TestServerRedirectResponse(HttpURLConnection.HTTP_MOVED_TEMP, | ||
testServer, "/weather")) | ||
testServer.registerGet("/city/London", json([time: "2018-11-27 13:05:00", weather: temperature])) | ||
testServer.registerPost("/employee", json([id: 'id-generated-2'], 201)) | ||
testServer.registerGet("/employee/id-generated-2", json([firstName: 'FN', lastName: 'LN'])) | ||
|
||
} | ||
|
||
private static TestServerResponse json(Map response, statusCode = 200) { | ||
return new TestServerJsonResponse(JsonUtils.serialize(response), statusCode) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2019 TWO SIGMA OPEN SOURCE, LLC | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.twosigma.webtau</groupId> | ||
<artifactId>webtau-parent</artifactId> | ||
<version>1.11-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>webtau-junit-like-examples-common</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.twosigma.webtau</groupId> | ||
<artifactId>webtau-http</artifactId> | ||
<version>${project.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.