yandex-qatools / htmlelements

Html Elements is a Java framework providing easy-to-use way of interaction with web-page elements in web-page tests.
Other
271 stars 116 forks source link

Fix array out of bounds #131

Closed iamanikeev closed 7 years ago

iamanikeev commented 8 years ago

The following code would fail in case if headings is less then row headers set:

return rows.stream()
                .map(row -> row.stream()
                        .collect(toMap(e -> headings.get(row.indexOf(e)), identity())))
artkoshelev commented 8 years ago

Can you please add some tests describing this issue?

iamanikeev commented 8 years ago

Done. Now if you revert changes in Table, you could see the same error.

java.lang.ArrayIndexOutOfBoundsException: 2

    at java.util.Arrays$ArrayList.get(Arrays.java:3841)
    at ru.yandex.qatools.htmlelements.element.Table.lambda$null$4(Table.java:157)
    at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
    at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    at ru.yandex.qatools.htmlelements.element.Table.lambda$getRowsMappedToHeadings$5(Table.java:157)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
artkoshelev commented 8 years ago

Indentations are broken in several places.

iamanikeev commented 8 years ago

Formatted both files with Idea, only 3 places were fixed (see last commit). Is that it, or I'm missing something else? Is there any linter I could use?

artkoshelev commented 7 years ago

LGTM now. Anyway, it looks that PR build is broken in our CI system, i need to fix it before we can merge it.

Can you please squash commits in one?

iamanikeev commented 7 years ago

Done.

artkoshelev commented 7 years ago

test this please

artkoshelev commented 7 years ago

Landed, thank you @iamanikeev !