Skip to content

Commit

Permalink
Merge branch 'master' into responseTimeAllure
Browse files Browse the repository at this point in the history
  • Loading branch information
EDbarvinsky authored Apr 16, 2023
2 parents c938742 + 4d88779 commit 9a78df0
Show file tree
Hide file tree
Showing 20 changed files with 324 additions and 47 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,26 @@ jobs:

- name: Upload coverage to Codecov
if: ${{ matrix.platform == 'ubuntu-latest' && ! github.event.pull_request.head.repo.fork || github.ref == 'refs/heads/master' }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload coverage to Codecov
if: ${{ matrix.platform == 'ubuntu-latest' && github.event.pull_request.head.repo.fork }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2

- name: VIVIDUS tasks validation
run: |
./gradlew validateKnownIssues printSteps countSteps -x testVividusInitialization -p vividus-tests --project-prop 'vividus.variables.iterationLimit=3' --project-prop 'vividus.variables.target-platform=ios'
- name: Integration tests
if: matrix.platform == 'ubuntu-latest' || matrix.platform == 'windows-latest'
run: |
./gradlew :vividus-tests:debugStories --project-prop 'vividus.configuration-set.active=integration' --project-prop 'vividus.allure.history-directory=output/history/integration-tests' --project-prop 'vividus.allure.executor.name="Github Actions (Vividus)"' --project-prop 'vividus.allure.executor.type=github' --project-prop 'vividus.allure.executor.url=https://github.com/vividus-framework/vividus/actions' --project-prop 'vividus.allure.executor.build-order=${GITHUB_RUN_ID}' --project-prop 'vividus.allure.executor.build-name="Integration Tests ${GITHUB_RUN_ID}"' --project-prop 'vividus.allure.executor.build-url=https://github.com/vividus-framework/vividus/actions/runs/${GITHUB_RUN_ID}' --project-prop 'vividus.allure.executor.report-url=https://github.com/vividus-framework/vividus/actions/runs/${GITHUB_RUN_ID}' --project-prop 'vividus.allure.executor.report-name="Integration tests report"' --project-prop "fileToSaveExitCode=$(pwd)/exitCode.txt" --no-daemon
- name: Publish integration tests report
if: (matrix.platform == 'ubuntu-latest' || matrix.platform == 'windows-latest') && always()
if: always()
uses: actions/upload-artifact@v3
with:
name: Integration Tests - Allure report - ${{ matrix.platform }}
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use, security is always extremely important.
Please do not open an issue or pull request as this makes the problem immediately visible to everyone
including malicious actors.

Security issues in this project can be safely reported via the the following address:
Security issues in this project can be safely reported via the following address:

[email protected]

Expand Down
60 changes: 60 additions & 0 deletions docs/modules/commons/pages/expressions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,66 @@ Finds the resource by its name and replaces the expression with the content of t
Given I initialize scenario variable `my-data` with value `#{resourceToBase64(/data/body.txt)}`
----

== URL parsing
:url-parameter: pass:quotes[*`$url`* - the URL to extract component from.]

=== `extractHostFromUrl`

Extracts host component from the given URL.

[source, subs="+quotes"]
----
#{extractHostFromUrl(*$url*)}
----

[subs="specialchars,attributes,quotes,replacements,macros,post_replacements"]
* {url-parameter}

.Validate host component from URL
[source,gherkin]
----
Then `#{extractHostFromUrl(file://server/folder/data.xml?id=123)}` is = `server`
Then `#{extractHostFromUrl(https://docs.vividus.dev/vividus/latest?page=2)}` is = `docs.vividus.dev`
----

=== `extractPathFromUrl`

Extracts decoded path component from the given URL.

[source, subs="+quotes"]
----
#{extractPathFromUrl(*$url*)}
----

[subs="specialchars,attributes,quotes,replacements,macros,post_replacements"]
* {url-parameter}

.Validate path component from URL
[source,gherkin]
----
Then `#{extractPathFromUrl(file://server/folder/data.xml?id=123)}` is = `/folder/data.xml`
Then `#{extractPathFromUrl(https://docs.vividus.dev/vividus/latest?page=2)}` is = `/vividus/latest`
----

=== `extractQueryFromUrl`

Extracts decoded query component from the given URL.

[source, subs="+quotes"]
----
#{extractQueryFromUrl(*$url*)}
----

[subs="specialchars,attributes,quotes,replacements,macros,post_replacements"]
* {url-parameter}

.Validate query component from URL
[source,gherkin]
----
Then `#{extractQueryFromUrl(file://server/folder/data.xml?id=123)}` is = `id=123`
Then `#{extractQueryFromUrl(https://docs.vividus.dev/vividus/latest?page=2)}` is = `page=2`
----

== Script evaluation

=== `eval`
Expand Down
30 changes: 27 additions & 3 deletions docs/modules/commons/pages/table-transformers.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,41 @@ at step execution stage, in other words the same placeholders will be replaced b
`SORTING` transformer is designed to sort the table rows by the values in
the columns.

[cols="1,3", options="header"]
[cols="2,3", options="header"]
|===
|Parameter
|Description

|`byColumns`
|column names ordered according to the priority of applying sorting (the column names are joined using `\|`)

|`order`
|the optional sorting order: ASCENDING or DESCENDING. By default - ASCENDING.
|===

.Usage of SORTING transformer with DESCENDING sorting. The following transformer:
[source,gherkin]
----
{transformer=SORTING, byColumns=key1|key2, order=DESCENDING}
|key1|key2|key3|
|bb |d |1 |
|ba |c |2 |
|bb |b |3 |
|aa |a |4 |
----

will result in the following xref:ROOT:glossary.adoc#_examplestable[ExamplesTable]:

[source,gherkin]
----
|key1|key2|key3|
|bb |d |1 |
|bb |b |3 |
|ba |c |2 |
|aa |a |4 |
----

.Usage of SORTING transformer
.Usage of SORTING transformer with sorting by default (ASCENDING)
[source,gherkin]
----
{transformer=SORTING, byColumns=key|key1}
Expand Down Expand Up @@ -480,7 +504,7 @@ Examples:
|===
|Parameter|Description

|`order`|The mandatory indedxing order: `ASCENDING` or `DESCENDING`.
|`order`|The mandatory indexing order: `ASCENDING` or `DESCENDING`.
|===

.ASCENDING order example
Expand Down
2 changes: 1 addition & 1 deletion vividus-plugin-azure-resource-manager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ dependencies {
testImplementation(group: 'org.junit.jupiter', name: 'junit-jupiter')
testImplementation platform(group: 'org.mockito', name: 'mockito-bom', version: '5.2.0')
testImplementation(group: 'org.mockito', name: 'mockito-junit-jupiter')
testImplementation(group: 'org.junit-pioneer', name: 'junit-pioneer', version: '2.0.0')
testImplementation(group: 'org.junit-pioneer', name: 'junit-pioneer', version: '2.0.1')
}
1 change: 0 additions & 1 deletion vividus-plugin-saucelabs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ dependencies {
testCompileOnly(group: 'junit', name: 'junit', version: '4.13.2')
testImplementation platform(group: 'org.mockito', name: 'mockito-bom', version: '5.2.0')
testImplementation(group: 'org.mockito', name: 'mockito-junit-jupiter')
testImplementation(group: 'org.mockito', name: 'mockito-inline')
testImplementation(group: 'com.github.powermock.powermock', name: 'powermock-api-mockito2', version: versions.powermock)
testImplementation(group: 'com.github.powermock.powermock', name: 'powermock-module-junit4', version: versions.powermock)
testImplementation(group: 'com.github.valfirst', name: 'slf4j-test', version: '2.9.0')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mock-maker-inline
2 changes: 1 addition & 1 deletion vividus-plugin-shell/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ dependencies {
testImplementation(group: 'org.junit.jupiter', name: 'junit-jupiter')
testImplementation platform(group: 'org.mockito', name: 'mockito-bom', version: '5.2.0')
testImplementation(group: 'org.mockito', name: 'mockito-junit-jupiter')
testImplementation(group: 'org.junit-pioneer', name: 'junit-pioneer', version: '2.0.0')
testImplementation(group: 'org.junit-pioneer', name: 'junit-pioneer', version: '2.0.1')
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,13 @@ Examples:

Scenario: Validate Data URL decoding expression for binary data
When I compare against baseline with name `black-pixel` from image `#{decodeDataUrl(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjYGBg+A8AAQQBAHAgZQsAAAAASUVORK5CYII=)}`

Scenario: Validate expressions parsing URLs
Then `#{<expression>}` is = `<expected>`
Examples:
|expression |expected |
|extractHostFromUrl(${vividus-test-site-url}/windows.html?query=test) |${vividus-test-site-host} |
|extractPathFromUrl(${vividus-test-site-url}/windows.html?query=test) |/windows.html |
|extractPathFromUrl(${vividus-test-site-url}/encoded%E2%82%AC/windows.html?query=test) |/encoded€/windows.html |
|extractQueryFromUrl(${vividus-test-site-url}/windows.html?query=test) |query=test |
|extractQueryFromUrl(${vividus-test-site-url}/windows.html?query=encoded%E2%82%AC) |query=encoded€ |
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,48 @@ Then `${innerJoinTable}` is equal to table:
|row13 |3 |row533 |row433 |row33 |row23 |
|row133 |3 |row53 |row43 |row333 |row233 |
|row133 |3 |row533 |row433 |row333 |row233 |

Scenario: Verify SORTING transformer with default order
When I initialize scenario variable `sortingTable` with values:
{transformer=SORTING, byColumns=key1|key2}
|key1|key2|key3|
|bb |d |1 |
|ba |c |2 |
|bb |b |3 |
|aa |a |4 |
Then `${sortingTable}` is equal to table:
|key1|key2|key3|
|aa |a |4 |
|ba |c |2 |
|bb |b |3 |
|bb |d |1 |

Scenario: Verify SORTING transformer with ASCENDING order
When I initialize scenario variable `sortingTable` with values:
{transformer=SORTING, byColumns=key1|key2, order=ASCENDING}
|key1|key2|key3|
|bb |d |1 |
|ba |c |2 |
|bb |b |3 |
|aa |a |4 |
Then `${sortingTable}` is equal to table:
|key1|key2|key3|
|aa |a |4 |
|ba |c |2 |
|bb |b |3 |
|bb |d |1 |

Scenario: Verify SORTING transformer with DESCENDING order
When I initialize scenario variable `sortingTable` with values:
{transformer=SORTING, byColumns=key1|key2, order=DESCENDING}
|key1|key2|key3|
|bb |d |1 |
|ba |c |2 |
|bb |b |3 |
|aa |a |4 |
Then `${sortingTable}` is equal to table:
|key1|key2|key3|
|bb |d |1 |
|bb |b |3 |
|ba |c |2 |
|aa |a |4 |
4 changes: 2 additions & 2 deletions vividus/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ dependencies {
testImplementation(group: 'org.junit.jupiter', name: 'junit-jupiter')
testImplementation platform(group: 'org.mockito', name: 'mockito-bom', version: '5.2.0')
testImplementation(group: 'org.mockito', name: 'mockito-junit-jupiter')
testImplementation(group: 'org.junit-pioneer', name: 'junit-pioneer', version: '2.0.0')
testImplementation(group: 'org.junit-pioneer', name: 'junit-pioneer', version: '2.0.1')
testImplementation(group: 'com.github.valfirst', name: 'slf4j-test', version: '2.9.0')
testImplementation(group: 'org.springframework', name: 'spring-test')

Expand All @@ -99,5 +99,5 @@ dependencies {
integrationTestImplementation project(':vividus-plugin-yaml')
integrationTestImplementation platform(group: 'org.junit', name: 'junit-bom', version: '5.9.2')
integrationTestImplementation(group: 'org.junit.jupiter', name: 'junit-jupiter')
integrationTestImplementation(group: 'org.junit-pioneer', name: 'junit-pioneer', version: '2.0.0')
integrationTestImplementation(group: 'org.junit-pioneer', name: 'junit-pioneer', version: '2.0.1')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2019-2023 the original author or authors.
*
* 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
*
* https://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 org.vividus.expression;

import java.util.List;

import org.jbehave.core.expressions.DelegatingExpressionProcessor;
import org.jbehave.core.expressions.SingleArgExpressionProcessor;
import org.vividus.util.UriUtils;

public class UrlExpressionProcessors extends DelegatingExpressionProcessor
{
public UrlExpressionProcessors()
{
super(List.of(
new SingleArgExpressionProcessor<>("extractHostFromUrl", url -> UriUtils.createUri(url).getHost()),
new SingleArgExpressionProcessor<>("extractPathFromUrl", url -> UriUtils.createUri(url).getPath()),
new SingleArgExpressionProcessor<>("extractQueryFromUrl", url -> UriUtils.createUri(url).getQuery())
));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,27 +47,4 @@ public String transform(String tableAsString, TableParsers tableParsers, TablePr
headers.add(INDEX);
return ExamplesTableProcessor.buildExamplesTable(headers, rows, properties);
}

private enum Order
{
ASCENDING
{
@Override
IntUnaryOperator getIndexer(List<?> rows)
{
return i -> i;
}
},
DESCENDING
{
@Override
IntUnaryOperator getIndexer(List<?> rows)
{
int size = rows.size();
return i -> size - i - 1;
}
};

abstract IntUnaryOperator getIndexer(List<?> rows);
}
}
57 changes: 57 additions & 0 deletions vividus/src/main/java/org/vividus/transformer/Order.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2019-2023 the original author or authors.
*
* 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
*
* https://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 org.vividus.transformer;

import java.util.List;
import java.util.function.IntUnaryOperator;

enum Order
{
ASCENDING
{
@Override
IntUnaryOperator getIndexer(List<?> rows)
{
return i -> i;
}

@Override
int getDirection()
{
return 1;
}
},
DESCENDING
{
@Override
IntUnaryOperator getIndexer(List<?> rows)
{
int size = rows.size();
return i -> size - i - 1;
}

@Override
int getDirection()
{
return -1;
}
};

abstract IntUnaryOperator getIndexer(List<?> rows);

abstract int getDirection();
}
Loading

0 comments on commit 9a78df0

Please sign in to comment.