Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server log report extension #230

Merged
merged 12 commits into from
Dec 17, 2019

Conversation

xsmrcek
Copy link
Contributor

@xsmrcek xsmrcek commented Nov 18, 2019

Server log report extension updated

@xsmrcek
Copy link
Contributor Author

xsmrcek commented Nov 18, 2019

If anyone want to start review feel free :) Except serverLogXmlRep.xslt, I will work on it a little more.

…/SshReportType.java

Co-Authored-By: Pavel Jandejsek <43804753+paveljandejsek@users.noreply.github.com>
@AfterScenario
public void after() {
scenarioEnd = ZonedDateTime.now();
if (serverLogXmlReporterExtension != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This sanity check occurs quite often, consider implementing Null Object Design Pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now it occurs only once and throws assertion error.

public void afterFailedScenario() {
if (serverLogXmlReporterExtension != null) {
if (serverLogXmlReporterExtension.getSshReportType() != SshReportType.TEMPLATE &&
serverLogXmlReporterExtension.isLoggingOnFailure()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

From javadoc of this class:

This class implements steps for testing ssh

All these methods @AfterScenario has nothing to do with testing ssh, rather reporting content of what ssh handler delivers. Therefore this place for such behavior looks inappropriate to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved a lot of stuff elsewhere :)

}
printEnd(writer, SYSTEM);
}
);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you insist on lambdas: logContents.forEach((MultiKey k, String v) -> {
Otherwise plain old java would still love you: for (Map.Entry<MultiKey<? extends MultiKey>, String> multiKeyStringEntry : logContents.entrySet()) {
++multiple occurrence

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using forEach on entrySet now :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Changed - even on your sshTemplates merger ultra code 😛

Comment on lines 325 to 337
sshTemplatesArray.entrySet()
.stream()
.forEach(entry -> {
List<SshTemplate> flattenedSshTemplatesArray = entry.getValue()
.stream()
.flatMap(Arrays::stream)
.collect(Collectors.toList());
if (sshTemplates.get(entry.getKey()) != null) {
sshTemplates.get(entry.getKey()).addAll(flattenedSshTemplatesArray);
} else {
sshTemplates.put(entry.getKey(), flattenedSshTemplatesArray);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

sshTemplatesArray.entrySet().stream()
            .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().stream().flatMap(Arrays::stream).collect(Collectors.toList())))
            .forEach((k, v) -> sshTemplates.merge(k, v, (v1, v2) -> {
                v2.addAll(v1);
                return v2;
            }));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

v1, v2 >> list

Copy link
Contributor

Choose a reason for hiding this comment

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

Variables renamed + changed to use biconsumer foreach.

@xsmrcek xsmrcek marked this pull request as ready for review December 2, 2019 09:14
…/SshSteps.java

Co-Authored-By: Pavel Jandejsek <43804753+paveljandejsek@users.noreply.github.com>
@paveljandejsek
Copy link
Contributor

sshTemplatesArray.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().stream().flatMap(Arrays::stream).collect(Collectors.toList()))) .forEach((k, v) -> sshTemplates.merge(k, v, (v1, v2) -> { v2.addAll(v1); return v2; }));

@AmyKosinova

Co-Authored-By: Pavel Jandejsek <43804753+paveljandejsek@users.noreply.github.com>
paveljandejsek and others added 8 commits December 13, 2019 10:16
…/SshReportType.java

Co-Authored-By: Pavel Jandejsek <43804753+paveljandejsek@users.noreply.github.com>
…/SshSteps.java

Co-Authored-By: Pavel Jandejsek <43804753+paveljandejsek@users.noreply.github.com>
Co-Authored-By: Pavel Jandejsek <43804753+paveljandejsek@users.noreply.github.com>
@paveljandejsek paveljandejsek merged commit 44ca4d1 into EmbedITCZ:master Dec 17, 2019
@xsmrcek xsmrcek deleted the SshReportExtensionRewriten branch January 20, 2020 08:56
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.

3 participants