Skip to content

Commit

Permalink
Merge branch 'master' of github.com:serenity-bdd/serenity-core
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Sep 6, 2017
2 parents 2ae6b9c + 771d27b commit 8125014
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 47 deletions.
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ commonsLang3Version = 3.4
commonsCodecVersion = 1.10
xstreamVersion = 1.4.9
jodaTimeVersion = 2.7
lambdajVersion = 2.3.3
gsonVersion = 2.8.0
typesafeConfigVersion = 1.3.1
freemarkerVersion = 2.3.23
Expand Down
5 changes: 0 additions & 5 deletions serenity-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ dependencies {
exclude group: 'commons-logging', module: 'commons-logging'
}

compile("com.googlecode.lambdaj:lambdaj:${lambdajVersion}") {
exclude group: 'org.hamcrest', module: 'hamcrest-all'
exclude group: 'cglib', module: 'cglib-nodep'
exclude group: 'org.objenesis', module: 'objenesis'
}
compile "joda-time:joda-time:${jodaTimeVersion}"
compile "com.thoughtworks.xstream:xstream:${xstreamVersion}"
compile "org.apache.commons:commons-lang3:${commonsLang3Version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ private void ensureHostIsAvailableAt(URL remoteUrl) throws UnknownHostException
}

private boolean hostIsAvailableAt(URL remoteUrl) {
try (Socket socket = new Socket()) {
int port = (remoteUrl.getPort() > 0) ? remoteUrl.getPort() : remoteUrl.getDefaultPort();
socket.connect(new InetSocketAddress(remoteUrl.getHost(), port), WITHIN_THREE_SECONDS);
try {
URLConnection urlConnection = remoteUrl.openConnection();
urlConnection.connect();
return true;
} catch (IOException e) {
return false; // Either timeout or unreachable or failed DNS lookup.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.thucydides.core.reports.adaptors.specflow;

import ch.lambdaj.function.convert.Converter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import net.thucydides.core.model.*;
Expand All @@ -11,8 +10,7 @@
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.List;

import static ch.lambdaj.Lambda.convert;
import java.util.stream.Collectors;

/**
* Loads TestOutcomes from a specflow output file
Expand Down Expand Up @@ -42,31 +40,25 @@ public List<TestOutcome> loadOutcomesFrom(File source) throws IOException {

private List<TestOutcome> outcomesFromFile(File outputFile) throws IOException {
List<String> outputLines = Files.readAllLines(outputFile.toPath(), Charset.defaultCharset());
return convert(scenarioOutputsFrom(outputLines), toTestOutcomes());
return scenarioOutputsFrom(outputLines).stream().map(this::toTestOutcome).collect(Collectors.toList());
}

private Converter<List<String>, TestOutcome> toTestOutcomes() {
return new Converter<List<String>, TestOutcome>() {

@Override
public TestOutcome convert(List<String> outputLines) {
SpecflowScenarioTitleLine titleLine = new SpecflowScenarioTitleLine(outputLines.get(0));
Story story = Story.called(titleLine.getStoryTitle()).withPath(titleLine.getStoryPath());
TestOutcome outcome = TestOutcome.forTestInStory(titleLine.getScenarioTitle(), story);

for(SpecflowScenario scenario : ScenarioSplitter.on(outputLines).split()) {
if (scenario.usesDataTable()) {
DataTable dataTable = DataTable.withHeaders(headersFrom(titleLine)).build();
outcome.useExamplesFrom(dataTable);
recordRowSteps(outcome, scenario);
} else {
outcome.recordSteps(stepsFrom(scenario.getSteps()));
}
}

return outcome;
private TestOutcome toTestOutcome(List<String> outputLines) {
SpecflowScenarioTitleLine titleLine = new SpecflowScenarioTitleLine(outputLines.get(0));
Story story = Story.called(titleLine.getStoryTitle()).withPath(titleLine.getStoryPath());
TestOutcome outcome = TestOutcome.forTestInStory(titleLine.getScenarioTitle(), story);

for(SpecflowScenario scenario : ScenarioSplitter.on(outputLines).split()) {
if (scenario.usesDataTable()) {
DataTable dataTable = DataTable.withHeaders(headersFrom(titleLine)).build();
outcome.useExamplesFrom(dataTable);
recordRowSteps(outcome, scenario);
} else {
outcome.recordSteps(stepsFrom(scenario.getSteps()));
}
};
}

return outcome;
}

private void recordRowSteps(TestOutcome outcome, SpecflowScenario scenario) {
Expand Down Expand Up @@ -131,12 +123,6 @@ private boolean isTitle(String line) {
}

private List<TestResult> getTestResults(List<TestStep> testSteps) {
return convert(testSteps, new ExtractTestResultsConverter());
}

private static class ExtractTestResultsConverter implements Converter<TestStep, TestResult> {
public TestResult convert(final TestStep step) {
return step.getResult();
}
return testSteps.stream().map(TestStep::getResult).collect(Collectors.toList());
}
}
1 change: 0 additions & 1 deletion serenity-smoketests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ dependencies {
compile 'org.slf4j:slf4j-simple:1.7.7'
compile 'org.codehaus.groovy:groovy-all:2.4.11'
compile 'junit:junit:4.11'
compile 'com.googlecode.lambdaj:lambdaj:2.3.3'
compile 'org.assertj:assertj-core:1.7.0'
compile 'org.hamcrest:hamcrest-all:1.3'
}
Expand Down
5 changes: 0 additions & 5 deletions serenity-smoketests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@
<artifactId>assertj-core</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
Expand Down

0 comments on commit 8125014

Please sign in to comment.