diff --git a/src/main/java/org/jpeek/graph/XmlMethodArgs.java b/src/main/java/org/jpeek/graph/XmlMethodArgs.java index ea6236ff..4fc4e9f9 100644 --- a/src/main/java/org/jpeek/graph/XmlMethodArgs.java +++ b/src/main/java/org/jpeek/graph/XmlMethodArgs.java @@ -54,6 +54,9 @@ final class XmlMethodArgs implements Text { @Override public String asString() throws IOException { - return new Joined(":", this.method.xpath("args/arg/@type")).asString(); + return new Joined( + ":", + this.method.xpath("op/args/arg/@type") + ).asString(); } } diff --git a/src/main/java/org/jpeek/graph/XmlMethodCall.java b/src/main/java/org/jpeek/graph/XmlMethodCall.java index 34d80f43..ea9714d1 100644 --- a/src/main/java/org/jpeek/graph/XmlMethodCall.java +++ b/src/main/java/org/jpeek/graph/XmlMethodCall.java @@ -32,11 +32,8 @@ * Serialize method call to a string. * * @since 1.0 - * @todo #440:30min This class XmlMethodCall should be made public - * and a test class named XmlMethodCallTest should be added to - * verify its behaviour. */ -final class XmlMethodCall implements Text { +public final class XmlMethodCall implements Text { /** * XML Call operation. @@ -55,7 +52,7 @@ final class XmlMethodCall implements Text { @Override public String asString() throws IOException { return new Joined( - "", this.call.xpath("name/text()").get(0), + "", this.call.xpath("op/name/text()").get(0), ".", new XmlMethodArgs(this.call).asString() ).asString(); } diff --git a/src/test/java/org/jpeek/graph/XmlMethodCallTest.java b/src/test/java/org/jpeek/graph/XmlMethodCallTest.java new file mode 100644 index 00000000..12981803 --- /dev/null +++ b/src/test/java/org/jpeek/graph/XmlMethodCallTest.java @@ -0,0 +1,62 @@ +/* + * 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.XMLDocument; +import java.io.IOException; +import org.cactoos.text.Joined; +import org.hamcrest.core.IsEqual; +import org.junit.jupiter.api.Test; +import org.llorllale.cactoos.matchers.Assertion; + +/** + * Test case for {@link XmlMethodCall}. + * @since 0.44 + */ +final class XmlMethodCallTest { + + @Test + void hasClassMethodAndArgs() throws IOException { + new Assertion<>( + "Must have class name, method name and args.", + new XmlMethodCall( + new XMLDocument( + new Joined( + "", + "", + " OverloadMethods.methodOne", + " ", + " ?", + " ?", + " ", + "" + ).asString() + ) + ).asString(), + new IsEqual<>( + "OverloadMethods.methodOne.Ljava/lang/String:Z" + ) + ).affirm(); + } +}