Skip to content

Fixes #718#746

Merged
FridaTveit merged 2 commits into
exercism:masterfrom
matthewstyler:master
Aug 21, 2017
Merged

Fixes #718#746
FridaTveit merged 2 commits into
exercism:masterfrom
matthewstyler:master

Conversation

@matthewstyler
Copy link
Copy Markdown
Contributor

tighten access modifier and method invocations


Reviewer Resources:

Track Policies

Copy link
Copy Markdown
Contributor

@ilya-khadykin ilya-khadykin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should investigate why build has failed

.map(this::translateWord)
.collect(Collectors.toList());

return String.join(" ", translatedWords);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be even better to get rid of this line:

String.join(" ", translatedWords);

with

.collect(Collectors.joining(" "));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion @m-a-ge :) So @matthewstyler you could get rid of the last line and change this to

String translate(String sentence) {
        return Arrays.stream(sentence.split(" "))
                .map(this::translateWord)
                .collect(Collectors.joining(" "));
}

If you want to :) It's good as it is though, so don't feel like you have to! :)


String translate(String sentence) {
List<String> translatedWords = Arrays.stream(sentence.split(" "))
.map(this::translateWord)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably:

.map(PigLatinTranslator::translateWord)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an instance method not a static method so it should be this::translateWord :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, my bad :(

@matthewstyler
Copy link
Copy Markdown
Contributor Author

matthewstyler commented Aug 19, 2017

taking a look at the build logs, seems like the PigTranslator isn't the issue:

+./exercism --config .journey-test.exercism.json fetch java pig-latin
::1 - - [19/Aug/2017:03:00:47 +0000] "GET /v2/exercises/java/pig-latin HTTP/1.1" 200 4234 0.0103
Not Submitted:   1 problem
java (Pig Latin) /home/travis/build/exercism/java/build/exercism/java/pig-latin
New:             1 problem
java (Pig Latin) /home/travis/build/exercism/java/build/exercism/java/pig-latin
unchanged: 0, updated: 0, new: 1
+cp -R -H /home/travis/build/exercism/java/exercises/pig-latin/src/example/java/PigLatinTranslator.java /home/travis/build/exercism/java/build/exercism/java/pig-latin/src/main/java/
+pushd /home/travis/build/exercism/java/build/exercism/java/pig-latin
~/build/exercism/java/build/exercism/java/pig-latin ~/build/exercism/java/build/exercism ~/build/exercism/java
+/home/travis/build/exercism/java/gradlew compileTestJava
:compileJava
:processResources NO-SOURCE
:classes
:compileTestJava
BUILD SUCCESSFUL in 18s
2 actionable tasks: 2 executed
++find . -name '*Test.java'
+for testfile in '`find . -name "*Test.${TRACK_SRC_EXT}"`'
+sed 's/@Ignore\(\(.*\)\)\{0,1\}//' ./src/test/java/PigLatinTranslatorTest.java
+mv /tmp/journey-test.sh-unignore_all_tests.txt ./src/test/java/PigLatinTranslatorTest.java
+/home/travis/build/exercism/java/gradlew test
:compileJava UP-TO-DATE
:processResources NO-SOURCE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources NO-SOURCE
:testClasses UP-TO-DATE
:test
PigLatinTranslatorTest > test[0: expected "apple" to translate to the pig latin phrase "appleay"] PASSED
PigLatinTranslatorTest > test[1: expected "ear" to translate to the pig latin phrase "earay"] PASSED
PigLatinTranslatorTest > test[2: expected "igloo" to translate to the pig latin phrase "iglooay"] PASSED
PigLatinTranslatorTest > test[3: expected "object" to translate to the pig latin phrase "objectay"] PASSED
PigLatinTranslatorTest > test[4: expected "under" to translate to the pig latin phrase "underay"] PASSED
PigLatinTranslatorTest > test[5: expected "pig" to translate to the pig latin phrase "igpay"] PASSED
PigLatinTranslatorTest > test[6: expected "koala" to translate to the pig latin phrase "oalakay"] PASSED
PigLatinTranslatorTest > test[7: expected "yellow" to translate to the pig latin phrase "ellowyay"] PASSED
PigLatinTranslatorTest > test[8: expected "xenon" to translate to the pig latin phrase "enonxay"] PASSED
PigLatinTranslatorTest > test[9: expected "chair" to translate to the pig latin phrase "airchay"] PASSED
PigLatinTranslatorTest > test[10: expected "queen" to translate to the pig latin phrase "eenquay"] PASSED
PigLatinTranslatorTest > test[11: expected "square" to translate to the pig latin phrase "aresquay"] PASSED
PigLatinTranslatorTest > test[12: expected "therapy" to translate to the pig latin phrase "erapythay"] PASSED
PigLatinTranslatorTest > test[13: expected "thrush" to translate to the pig latin phrase "ushthray"] PASSED
PigLatinTranslatorTest > test[14: expected "school" to translate to the pig latin phrase "oolschay"] PASSED
PigLatinTranslatorTest > test[15: expected "yttria" to translate to the pig latin phrase "yttriaay"] PASSED
PigLatinTranslatorTest > test[16: expected "xray" to translate to the pig latin phrase "xrayay"] PASSED
PigLatinTranslatorTest > test[17: expected "quick fast run" to translate to the pig latin phrase "ickquay astfay unray"] PASSED
BUILD SUCCESSFUL in 16s

...
2 actionable tasks: 2 executed
++find . -name '*Test.java'
+for testfile in '`find . -name "*Test.${TRACK_SRC_EXT}"`'
+sed 's/@Ignore\(\(.*\)\)\{0,1\}//' ./src/test/java/ForthEvaluatorTest.java
+mv /tmp/journey-test.sh-unignore_all_tests.txt ./src/test/java/ForthEvaluatorTest.java
+/home/travis/build/exercism/java/gradlew test
:compileJava UP-TO-DATE
:processResources NO-SOURCE
:classes UP-TO-DATE
:compileTestJava
:processTestResources NO-SOURCE
:testClasses
:test
The job exceeded the maximum time limit for jobs, and has been terminated.

@stkent
Copy link
Copy Markdown
Contributor

stkent commented Aug 19, 2017

Yeah, that timeout was weird. Restarting the build to see what happens!

Copy link
Copy Markdown
Contributor

@FridaTveit FridaTveit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @matthewstyler, this looks great! :D

There's one further improvement that @m-a-ge suggested that you could address in this PR if you want to :) But if you don't want to then don't worry about it, I can open a new issue for it :)


String translate(String sentence) {
List<String> translatedWords = Arrays.stream(sentence.split(" "))
.map(this::translateWord)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an instance method not a static method so it should be this::translateWord :)

.map(this::translateWord)
.collect(Collectors.toList());

return String.join(" ", translatedWords);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion @m-a-ge :) So @matthewstyler you could get rid of the last line and change this to

String translate(String sentence) {
        return Arrays.stream(sentence.split(" "))
                .map(this::translateWord)
                .collect(Collectors.joining(" "));
}

If you want to :) It's good as it is though, so don't feel like you have to! :)

@matthewstyler
Copy link
Copy Markdown
Contributor Author

@m-a-ge & @FridaTveit made that change

Copy link
Copy Markdown
Contributor

@FridaTveit FridaTveit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant! Thank you @matthewstyler! :)

And thanks @m-a-ge for the suggested improvement :) The code looks much neater now thanks to you two :)

@FridaTveit FridaTveit merged commit 57227fb into exercism:master Aug 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants