Skip to content

Commit

Permalink
#413 - Fixed and enabled tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
vzurauskas committed Jun 5, 2020
1 parent 233d9d0 commit 88f57d0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 44 deletions.
11 changes: 8 additions & 3 deletions src/main/java/org/jpeek/graph/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final class Simple implements Node {
/**
* Node name.
*/
private final String nme;
private final String name;

/**
* Nodes connected to this node.
Expand All @@ -64,18 +64,23 @@ final class Simple implements Node {
* @param name Node name
*/
public Simple(final String name) {
this.nme = name;
this.name = name;
this.connect = new HashSet<Node>(1);
}

@Override
public String name() {
return this.nme;
return this.name;
}

@Override
public Set<Node> connections() {
return this.connect;
}

@Override
public String toString() {
return this.name;
}
}
}
3 changes: 1 addition & 2 deletions src/main/java/org/jpeek/graph/XmlGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ public final class XmlGraph implements Graph {
/**
* Ctor.
* @param skeleton XMl representation on whiwh to build the graph
* @throws IOException If fails
*/
public XmlGraph(final Skeleton skeleton) throws IOException {
public XmlGraph(final Skeleton skeleton) {
this.nds = new Unchecked<>(
new Sticky<>(
() -> XmlGraph.build(skeleton)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jpeek/graph/XmlMethodCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public final class XmlMethodCall implements Text {
@Override
public String asString() throws IOException {
return new Joined(
"", this.call.xpath("op/name/text()").get(0),
".", new XmlMethodArgs(this.call.nodes("op").get(0)).asString()
"", this.call.xpath("name/text()").get(0),
".", new XmlMethodArgs(this.call).asString()
).asString();
}
}
58 changes: 22 additions & 36 deletions src/test/java/org/jpeek/graph/XmlGraphTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.jpeek.graph;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.cactoos.list.ListOf;
Expand All @@ -32,54 +31,51 @@
import org.hamcrest.core.AllOf;
import org.jpeek.FakeBase;
import org.jpeek.skeleton.Skeleton;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.HasValues;
import org.llorllale.cactoos.matchers.HasValuesMatching;

/**
* Test case for {@link XmlGraph}.
* @since 0.30.9
* @todo #413:30min In #413 we evolved graph connection building to take into account overloaded
* method differentiation as stated in #403. Wait until #403 is fully resolved (for now, it still
* has the puzzle #437) and then activate back the 2 tests in this class.
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
public final class XmlGraphTest {
final class XmlGraphTest {

/**
* First method name.
*/
private static final String METHOD_ONE = "MethodMethodCalls.methodOne";
private static final String METHOD_ONE = "MethodMethodCalls.methodOne.";

/**
* Second method name.
*/
private static final String METHOD_TWO = "MethodMethodCalls.methodTwo";
private static final String METHOD_TWO = "MethodMethodCalls.methodTwo.";

/**
* Third method name.
*/
private static final String METHOD_THREE = "MethodMethodCalls.methodThree";
private static final String METHOD_THREE = "MethodMethodCalls.methodThree.";

/**
* Fourth method name.
*/
private static final String METHOD_FOUR = "MethodMethodCalls.methodFour";
private static final String METHOD_FOUR = "MethodMethodCalls.methodFour.";

/**
* Fifth method name.
*/
private static final String METHOD_FIVE = "MethodMethodCalls.methodFive";
private static final String METHOD_FIVE = "MethodMethodCalls.methodFive.";

/**
* Class name.
*/
private static final String CLASS_NAME = "MethodMethodCalls";

@Disabled
@SuppressWarnings("unchecked")
public void buildsMethodsAsNodes() throws IOException {
@Test
void buildsMethodsAsNodes() {
final List<Node> nodes = new XmlGraph(
new Skeleton(new FakeBase(XmlGraphTest.CLASS_NAME))
).nodes();
Expand All @@ -89,39 +85,29 @@ public void buildsMethodsAsNodes() throws IOException {
new AllOf<Iterable<Node>>(
new ListOf<>(
new HasValuesMatching<>(
node -> {
return node.name().equals(XmlGraphTest.METHOD_ONE);
}
node -> node.name().equals(XmlGraphTest.METHOD_ONE)
),
new HasValuesMatching<>(
node -> {
return node.name().equals(XmlGraphTest.METHOD_TWO);
}
node -> node.name().equals(XmlGraphTest.METHOD_TWO)
),
new HasValuesMatching<>(
node -> {
return node.name().equals(XmlGraphTest.METHOD_THREE);
}
node -> node.name().equals(XmlGraphTest.METHOD_THREE)
),
new HasValuesMatching<>(
node -> {
return node.name().equals(XmlGraphTest.METHOD_FOUR);
}
node -> node.name().equals(XmlGraphTest.METHOD_FOUR)
),
new HasValuesMatching<>(
node -> {
return node.name().equals(XmlGraphTest.METHOD_FIVE);
}
node -> node.name().equals(XmlGraphTest.METHOD_FIVE)
)
)
)
).affirm();
}

@Disabled
public void buildsConnections() throws IOException {
@Test
void buildsConnections() {
final Map<String, Node> byname = new MapOf<>(
node -> node.name(),
Node::name,
node -> node,
new XmlGraph(
new Skeleton(new FakeBase(XmlGraphTest.CLASS_NAME))
Expand All @@ -135,27 +121,27 @@ public void buildsConnections() throws IOException {
new Assertion<>(
"Must build nodes connections when called",
one.connections(),
new HasValues<Node>(two)
new HasValues<>(two)
).affirm();
new Assertion<>(
"Must build nodes connections when called or calling",
two.connections(),
new HasValues<Node>(one, four)
new HasValues<>(one, four)
).affirm();
new Assertion<>(
"Must build nodes connections when neither called nor calling",
three.connections(),
new IsEmptyCollection<Node>()
new IsEmptyCollection<>()
).affirm();
new Assertion<>(
"Must build nodes connections when calling",
four.connections(),
new HasValues<Node>(two)
new HasValues<>(two)
).affirm();
new Assertion<>(
"Must build nodes connections when throwing",
five.connections(),
new IsEmptyCollection<Node>()
new IsEmptyCollection<>()
).affirm();
}
}
2 changes: 1 addition & 1 deletion src/test/java/org/jpeek/graph/XmlMethodCallTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void hasClassMethodAndArgs() throws IOException {
" </args>",
"</op>"
).asString()
)
).nodes("//op").get(0)
).asString(),
new IsEqual<>(
"OverloadMethods.methodOne.Ljava/lang/String:Z"
Expand Down

5 comments on commit 88f57d0

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 88f57d0 Jun 29, 2020

Choose a reason for hiding this comment

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

Puzzle 413-b264bb98 disappeared from src/test/java/org/jpeek/graph/XmlGraphTest.java, that's why I closed #441. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 88f57d0 Jun 29, 2020

Choose a reason for hiding this comment

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

Puzzle 445-b9bbd966 disappeared from src/main/java/org/jpeek/graph/XmlGraph.java, that's why I closed #472. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 88f57d0 Jun 29, 2020

Choose a reason for hiding this comment

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

Puzzle 437-e6b95171 disappeared from src/test/java/org/jpeek/metrics/LormTest.java, that's why I closed #470. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 88f57d0 Jun 29, 2020

Choose a reason for hiding this comment

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

Puzzle 449-96cd40b8 discovered in src/main/java/org/jpeek/calculus/Calculus.java and submitted as #481. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 88f57d0 Jun 29, 2020

Choose a reason for hiding this comment

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

Puzzle 449-dd12396b discovered in src/main/java/org/jpeek/calculus/java/Ccm.java and submitted as #482. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.