Skip to content

Commit

Permalink
#443 Made XmlMethodCall public and added a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
vzurauskas committed Apr 17, 2020
1 parent 94b2e98 commit 285401a
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/main/java/org/jpeek/graph/XmlMethodArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
7 changes: 2 additions & 5 deletions src/main/java/org/jpeek/graph/XmlMethodCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();
}
Expand Down
62 changes: 62 additions & 0 deletions src/test/java/org/jpeek/graph/XmlMethodCallTest.java
Original file line number Diff line number Diff line change
@@ -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(
"",
"<op code=\"call\">",
" <name>OverloadMethods.methodOne</name>",
" <args>",
" <arg type=\"Ljava/lang/String\">?</arg>",
" <arg type=\"Z\">?</arg>",
" </args>",
"</op>"
).asString()
)
).asString(),
new IsEqual<>(
"OverloadMethods.methodOne.Ljava/lang/String:Z"
)
).affirm();
}
}

0 comments on commit 285401a

Please sign in to comment.