From 54e152048132644476f3bd29c56f740b6e2e8952 Mon Sep 17 00:00:00 2001 From: HDouss Date: Fri, 28 Feb 2020 15:29:29 +0100 Subject: [PATCH 1/7] #397 graph infrastructure --- src/main/java/org/jpeek/Calculus.java | 8 +- src/main/java/org/jpeek/graph/Graph.java | 39 +++++++++ src/main/java/org/jpeek/graph/Node.java | 81 ++++++++++++++++++ src/main/java/org/jpeek/graph/XmlGraph.java | 80 ++++++++++++++++++ .../java/org/jpeek/graph/package-info.java | 30 +++++++ .../java/org/jpeek/graph/NodeSimpleTest.java | 48 +++++++++++ .../java/org/jpeek/graph/XmlGraphTest.java | 82 +++++++++++++++++++ .../java/org/jpeek/graph/package-info.java | 30 +++++++ 8 files changed, 394 insertions(+), 4 deletions(-) create mode 100644 src/main/java/org/jpeek/graph/Graph.java create mode 100644 src/main/java/org/jpeek/graph/Node.java create mode 100644 src/main/java/org/jpeek/graph/XmlGraph.java create mode 100644 src/main/java/org/jpeek/graph/package-info.java create mode 100644 src/test/java/org/jpeek/graph/NodeSimpleTest.java create mode 100644 src/test/java/org/jpeek/graph/XmlGraphTest.java create mode 100644 src/test/java/org/jpeek/graph/package-info.java diff --git a/src/main/java/org/jpeek/Calculus.java b/src/main/java/org/jpeek/Calculus.java index bc37e832..00f2a5fc 100644 --- a/src/main/java/org/jpeek/Calculus.java +++ b/src/main/java/org/jpeek/Calculus.java @@ -30,10 +30,10 @@ /** * Metrics calculus interface. * @since 0.30.9 - * @todo #390:30min We have a separate interface to calculate XML metrics. - * We should continue to the goal defined in #296 where we should have a java - * implementation to calculate metrics. The motivation is to be able to make - * calculations impossible or too difficult to implement in xsl, like LCOM4. + * @todo #397:30min We start having the infrastructure for graph building from skeleton. + * The graph have just nodes for now without any connection between them. + * We should continue to build nodes connections to reflect methods (inter-)calls. + * After that, we should continue to implement an LCOM4 metrics calculus based on the graph. */ public interface Calculus { diff --git a/src/main/java/org/jpeek/graph/Graph.java b/src/main/java/org/jpeek/graph/Graph.java new file mode 100644 index 00000000..474e6483 --- /dev/null +++ b/src/main/java/org/jpeek/graph/Graph.java @@ -0,0 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017-2019 Yegor Bugayenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.jpeek.graph; + +import java.util.List; + +/** + * Graph containing list of nodes. + * @since 0.30.9 + */ +public interface Graph { + + /** + * Nodes composing this graph. + * @return List of the nodes belonging to this graph + */ + List nodes(); +} diff --git a/src/main/java/org/jpeek/graph/Node.java b/src/main/java/org/jpeek/graph/Node.java new file mode 100644 index 00000000..e988dec3 --- /dev/null +++ b/src/main/java/org/jpeek/graph/Node.java @@ -0,0 +1,81 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017-2019 Yegor Bugayenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.jpeek.graph; + +import java.util.ArrayList; +import java.util.List; + +/** + * Graph node description. It should at least provide its name and its neighbors. + * @since 0.30.9 + */ +public interface Node { + + /** + * Node name. + * @return A identifier for the node + */ + String name(); + + /** + * Calculates ingoing and outgoing connected nodes. + * @return List of nodes connected to this node. + */ + List connected(); + + /** + * Simple implementation. + * @since 0.30.9 + */ + final class Simple implements Node { + /** + * Node name. + */ + private final String nme; + + /** + * Nodes connected to this node. + */ + private final List connect; + + /** + * Ctor. + * @param name Node name + */ + public Simple(final String name) { + this.nme = name; + this.connect = new ArrayList(1); + } + + @Override + public String name() { + return this.nme; + } + + @Override + public List connected() { + return this.connect; + } + } +} diff --git a/src/main/java/org/jpeek/graph/XmlGraph.java b/src/main/java/org/jpeek/graph/XmlGraph.java new file mode 100644 index 00000000..463f268b --- /dev/null +++ b/src/main/java/org/jpeek/graph/XmlGraph.java @@ -0,0 +1,80 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017-2019 Yegor Bugayenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.jpeek.graph; + +import com.jcabi.xml.XML; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.cactoos.text.Joined; +import org.jpeek.skeleton.Skeleton; + +/** + * Graph implementation built on skeleton. + * @since 0.30.9 + */ +public final class XmlGraph implements Graph { + + /** + * List of the nodes of this graph. + */ + private final List nds; + + /** + * Ctor. + * @param skeleton XMl representation on whiwh to build the graph + * @throws IOException If fails + */ + public XmlGraph(final Skeleton skeleton) throws IOException { + this.nds = XmlGraph.build(skeleton); + } + + @Override + public List nodes() { + return this.nds; + } + + /** + * Builds the graph from the skeleton. + * @param skeleton XML representation on whiwh to build the graph + * @return List of nodes + * @throws IOException If fails + */ + private static List build(final Skeleton skeleton) throws IOException { + final List methods = skeleton.xml().nodes( + "//methods/method[@ctor='false' and @abstract='false']" + ); + final List result = new ArrayList<>(methods.size()); + for (final XML method:methods) { + result.add( + new Node.Simple( + new Joined( + "", method.xpath("@name").get(0), method.xpath("@desc").get(0) + ).asString() + ) + ); + } + return result; + } +} diff --git a/src/main/java/org/jpeek/graph/package-info.java b/src/main/java/org/jpeek/graph/package-info.java new file mode 100644 index 00000000..08f3ba1c --- /dev/null +++ b/src/main/java/org/jpeek/graph/package-info.java @@ -0,0 +1,30 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017-2019 Yegor Bugayenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + * JPeek graphs. + * + * @since 0.30.9 + */ +package org.jpeek.graph; diff --git a/src/test/java/org/jpeek/graph/NodeSimpleTest.java b/src/test/java/org/jpeek/graph/NodeSimpleTest.java new file mode 100644 index 00000000..91c8b030 --- /dev/null +++ b/src/test/java/org/jpeek/graph/NodeSimpleTest.java @@ -0,0 +1,48 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017-2019 Yegor Bugayenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.jpeek.graph; + +import java.io.IOException; +import org.hamcrest.core.IsEqual; +import org.junit.jupiter.api.Test; +import org.llorllale.cactoos.matchers.Assertion; + +/** + * Test case for {@link Node.Simple}. + * @since 0.30.9 + */ +public final class NodeSimpleTest { + + @Test + public void givesName() throws IOException { + final String name = "name"; + final Node.Simple node = new Node.Simple(name); + new Assertion<>( + "Must be more the 2 files", + node.name(), + new IsEqual<>(name) + ).affirm(); + } + +} diff --git a/src/test/java/org/jpeek/graph/XmlGraphTest.java b/src/test/java/org/jpeek/graph/XmlGraphTest.java new file mode 100644 index 00000000..a2fc71ea --- /dev/null +++ b/src/test/java/org/jpeek/graph/XmlGraphTest.java @@ -0,0 +1,82 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017-2019 Yegor Bugayenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.jpeek.graph; + +import java.io.IOException; +import java.util.List; +import org.cactoos.list.ListOf; +import org.hamcrest.core.AllOf; +import org.jpeek.FakeBase; +import org.jpeek.skeleton.Skeleton; +import org.junit.jupiter.api.Test; +import org.llorllale.cactoos.matchers.Assertion; +import org.llorllale.cactoos.matchers.HasValuesMatching; + +/** + * Test case for {@link XmlGraph}. + * @since 0.30.9 + */ +public final class XmlGraphTest { + + @Test + public void buildsMethodsAsNodes() throws IOException { + final List nodes = new XmlGraph( + new Skeleton(new FakeBase("MethodMethodCalls")) + ).nodes(); + new Assertion<>( + "Must build nodes representing methods", + nodes, + new AllOf>( + new ListOf<>( + new HasValuesMatching<>( + node -> { + return node.name().equals("methodOne()I"); + } + ), + new HasValuesMatching<>( + node -> { + return node.name().equals("methodTwo()I"); + } + ), + new HasValuesMatching<>( + node -> { + return node.name().equals("methodThree()I"); + } + ), + new HasValuesMatching<>( + node -> { + return node.name().equals("methodFour()I"); + } + ), + new HasValuesMatching<>( + node -> { + return node.name().equals("methodFive()I"); + } + ) + ) + ) + ).affirm(); + } + +} diff --git a/src/test/java/org/jpeek/graph/package-info.java b/src/test/java/org/jpeek/graph/package-info.java new file mode 100644 index 00000000..14399c0f --- /dev/null +++ b/src/test/java/org/jpeek/graph/package-info.java @@ -0,0 +1,30 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017-2019 Yegor Bugayenko + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + * Tests for graphs. + * + * @since 0.30.9 + */ +package org.jpeek.graph; From 6fb71346a73511137cbb654de8f6453e367893a7 Mon Sep 17 00:00:00 2001 From: HDouss Date: Fri, 28 Feb 2020 15:48:09 +0100 Subject: [PATCH 2/7] #397 fix warnings --- src/test/java/org/jpeek/graph/XmlGraphTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/org/jpeek/graph/XmlGraphTest.java b/src/test/java/org/jpeek/graph/XmlGraphTest.java index a2fc71ea..0bd87a9c 100644 --- a/src/test/java/org/jpeek/graph/XmlGraphTest.java +++ b/src/test/java/org/jpeek/graph/XmlGraphTest.java @@ -40,6 +40,7 @@ public final class XmlGraphTest { @Test + @SuppressWarnings({"unchecked"}) public void buildsMethodsAsNodes() throws IOException { final List nodes = new XmlGraph( new Skeleton(new FakeBase("MethodMethodCalls")) From 0720b3be6a58b30a23ec5d5855f387b9f3e5f534 Mon Sep 17 00:00:00 2001 From: HDouss Date: Fri, 28 Feb 2020 16:05:59 +0100 Subject: [PATCH 3/7] #397 fix qulice --- src/test/java/org/jpeek/graph/XmlGraphTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jpeek/graph/XmlGraphTest.java b/src/test/java/org/jpeek/graph/XmlGraphTest.java index 0bd87a9c..7203fa7c 100644 --- a/src/test/java/org/jpeek/graph/XmlGraphTest.java +++ b/src/test/java/org/jpeek/graph/XmlGraphTest.java @@ -40,7 +40,7 @@ public final class XmlGraphTest { @Test - @SuppressWarnings({"unchecked"}) + @SuppressWarnings("unchecked") public void buildsMethodsAsNodes() throws IOException { final List nodes = new XmlGraph( new Skeleton(new FakeBase("MethodMethodCalls")) From cefd42bca9dc0ba9fa5d24f1091c05b79909ea14 Mon Sep 17 00:00:00 2001 From: Hamdi Douss Date: Sat, 29 Feb 2020 23:03:41 +0100 Subject: [PATCH 4/7] #397 CR --- src/main/java/org/jpeek/graph/Node.java | 4 ++-- src/main/java/org/jpeek/graph/XmlGraph.java | 23 ++++++++------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/jpeek/graph/Node.java b/src/main/java/org/jpeek/graph/Node.java index e988dec3..ed36550d 100644 --- a/src/main/java/org/jpeek/graph/Node.java +++ b/src/main/java/org/jpeek/graph/Node.java @@ -42,7 +42,7 @@ public interface Node { * Calculates ingoing and outgoing connected nodes. * @return List of nodes connected to this node. */ - List connected(); + List connections(); /** * Simple implementation. @@ -74,7 +74,7 @@ public String name() { } @Override - public List connected() { + public List connections() { return this.connect; } } diff --git a/src/main/java/org/jpeek/graph/XmlGraph.java b/src/main/java/org/jpeek/graph/XmlGraph.java index 463f268b..6b7dc299 100644 --- a/src/main/java/org/jpeek/graph/XmlGraph.java +++ b/src/main/java/org/jpeek/graph/XmlGraph.java @@ -25,8 +25,8 @@ import com.jcabi.xml.XML; import java.io.IOException; -import java.util.ArrayList; import java.util.List; +import org.cactoos.list.Mapped; import org.cactoos.text.Joined; import org.jpeek.skeleton.Skeleton; @@ -62,19 +62,14 @@ public List nodes() { * @throws IOException If fails */ private static List build(final Skeleton skeleton) throws IOException { - final List methods = skeleton.xml().nodes( - "//methods/method[@ctor='false' and @abstract='false']" + return new Mapped( + method -> new Node.Simple( + new Joined( + "", method.xpath("@name").get(0), method.xpath("@desc").get(0) + ).asString() + ), skeleton.xml().nodes( + "//methods/method[@ctor='false' and @abstract='false']" + ) ); - final List result = new ArrayList<>(methods.size()); - for (final XML method:methods) { - result.add( - new Node.Simple( - new Joined( - "", method.xpath("@name").get(0), method.xpath("@desc").get(0) - ).asString() - ) - ); - } - return result; } } From 1f9878096f1f5006d7dc4f65c3da5d8aa76ee435 Mon Sep 17 00:00:00 2001 From: Hamdi Douss Date: Sat, 29 Feb 2020 23:27:40 +0100 Subject: [PATCH 5/7] #397 --- src/main/java/org/jpeek/graph/XmlGraph.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jpeek/graph/XmlGraph.java b/src/main/java/org/jpeek/graph/XmlGraph.java index 6b7dc299..dc257224 100644 --- a/src/main/java/org/jpeek/graph/XmlGraph.java +++ b/src/main/java/org/jpeek/graph/XmlGraph.java @@ -26,7 +26,9 @@ import com.jcabi.xml.XML; import java.io.IOException; import java.util.List; +import org.cactoos.Scalar; import org.cactoos.list.Mapped; +import org.cactoos.scalar.Unchecked; import org.cactoos.text.Joined; import org.jpeek.skeleton.Skeleton; @@ -39,7 +41,7 @@ public final class XmlGraph implements Graph { /** * List of the nodes of this graph. */ - private final List nds; + private final Unchecked> nds; /** * Ctor. @@ -47,12 +49,16 @@ public final class XmlGraph implements Graph { * @throws IOException If fails */ public XmlGraph(final Skeleton skeleton) throws IOException { - this.nds = XmlGraph.build(skeleton); + this.nds = new Unchecked<>( + (Scalar>) () -> { + return XmlGraph.build(skeleton); + } + ); } @Override public List nodes() { - return this.nds; + return this.nds.value(); } /** From 38cd220e87bfa1b02f74d900b7585915e2be1d33 Mon Sep 17 00:00:00 2001 From: Hamdi Douss Date: Sat, 29 Feb 2020 23:57:46 +0100 Subject: [PATCH 6/7] #397 CR --- src/main/java/org/jpeek/graph/XmlGraph.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jpeek/graph/XmlGraph.java b/src/main/java/org/jpeek/graph/XmlGraph.java index dc257224..07896c1a 100644 --- a/src/main/java/org/jpeek/graph/XmlGraph.java +++ b/src/main/java/org/jpeek/graph/XmlGraph.java @@ -26,8 +26,8 @@ import com.jcabi.xml.XML; import java.io.IOException; import java.util.List; -import org.cactoos.Scalar; import org.cactoos.list.Mapped; +import org.cactoos.scalar.Sticky; import org.cactoos.scalar.Unchecked; import org.cactoos.text.Joined; import org.jpeek.skeleton.Skeleton; @@ -50,9 +50,9 @@ public final class XmlGraph implements Graph { */ public XmlGraph(final Skeleton skeleton) throws IOException { this.nds = new Unchecked<>( - (Scalar>) () -> { - return XmlGraph.build(skeleton); - } + new Sticky<>( + () -> XmlGraph.build(skeleton) + ) ); } From d4fd607eb83c5e427570a08cc00bb4e0c632d30c Mon Sep 17 00:00:00 2001 From: Hamdi Douss Date: Sun, 1 Mar 2020 15:19:20 +0100 Subject: [PATCH 7/7] #397 code review --- src/test/java/org/jpeek/graph/NodeSimpleTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jpeek/graph/NodeSimpleTest.java b/src/test/java/org/jpeek/graph/NodeSimpleTest.java index 91c8b030..2439d12e 100644 --- a/src/test/java/org/jpeek/graph/NodeSimpleTest.java +++ b/src/test/java/org/jpeek/graph/NodeSimpleTest.java @@ -39,7 +39,7 @@ public void givesName() throws IOException { final String name = "name"; final Node.Simple node = new Node.Simple(name); new Assertion<>( - "Must be more the 2 files", + "Must returns name", node.name(), new IsEqual<>(name) ).affirm();