Skip to content

Commit

Permalink
Updating remaining unit tests to use more accurate+concise assertions
Browse files Browse the repository at this point in the history
Fixes #9314
  • Loading branch information
ycombinator committed Apr 4, 2018
1 parent cf16429 commit f1b6d7c
Showing 1 changed file with 26 additions and 33 deletions.
Expand Up @@ -62,8 +62,10 @@ public void testIfWithOneTrueStatement() throws InvalidIRException {

@Test
public void testIfWithOneFalseStatement() throws InvalidIRException {
PluginDefinition pluginDef = testPluginDefinition();
Statement trueStatement = new NoopStatement(randMeta());
Statement falseStatement = new PluginStatement(randMeta(), testPluginDefinition());
Statement falseStatement = new PluginStatement(randMeta(), pluginDef);
BooleanExpression ifExpression = createTestExpression();
IfStatement ifStatement = new IfStatement(
randMeta(),
createTestExpression(),
Expand All @@ -74,27 +76,22 @@ public void testIfWithOneFalseStatement() throws InvalidIRException {
Graph ifStatementGraph = ifStatement.toGraph();
assertFalse(ifStatementGraph.isEmpty());

Stream<Vertex> trueVertices = ifStatementGraph
.edges()
.filter(e -> e instanceof BooleanEdge)
.map(e -> (BooleanEdge) e)
.filter(e -> e.getEdgeType() == true)
.map(e -> e.getTo());
assertEquals(0, trueVertices.count());

Stream<Vertex> falseVertices = ifStatementGraph
.edges()
.filter(e -> e instanceof BooleanEdge)
.map(e -> (BooleanEdge) e)
.filter(e -> e.getEdgeType() == false)
.map(e -> e.getTo());
assertEquals(1, falseVertices.count());
Graph expected = new Graph();
IfVertex expectedIf = DSL.gIf(randMeta(), ifExpression);
expected.addVertex(expectedIf);

PluginVertex expectedF = DSL.gPlugin(randMeta(), pluginDef);
expected.chainVertices(false, expectedIf, expectedF);

assertSyntaxEquals(expected, ifStatementGraph);
}

@Test
public void testIfWithOneTrueOneFalseStatement() throws InvalidIRException {
Statement trueStatement = new PluginStatement(randMeta(), testPluginDefinition());
Statement falseStatement = new PluginStatement(randMeta(), testPluginDefinition());
PluginDefinition pluginDef = testPluginDefinition();
Statement trueStatement = new PluginStatement(randMeta(), pluginDef);
Statement falseStatement = new PluginStatement(randMeta(), pluginDef);
BooleanExpression ifExpression = createTestExpression();
IfStatement ifStatement = new IfStatement(
randMeta(),
createTestExpression(),
Expand All @@ -105,20 +102,16 @@ public void testIfWithOneTrueOneFalseStatement() throws InvalidIRException {
Graph ifStatementGraph = ifStatement.toGraph();
assertFalse(ifStatementGraph.isEmpty());

Stream<Vertex> trueVertices = ifStatementGraph
.edges()
.filter(e -> e instanceof BooleanEdge)
.map(e -> (BooleanEdge) e)
.filter(e -> e.getEdgeType() == true)
.map(e -> e.getTo());
assertEquals(1, trueVertices.count());

Stream<Vertex> falseVertices = ifStatementGraph
.edges()
.filter(e -> e instanceof BooleanEdge)
.map(e -> (BooleanEdge) e)
.filter(e -> e.getEdgeType() == false)
.map(e -> e.getTo());
assertEquals(1, falseVertices.count());
Graph expected = new Graph();
IfVertex expectedIf = DSL.gIf(randMeta(), ifExpression);
expected.addVertex(expectedIf);

PluginVertex expectedT = DSL.gPlugin(randMeta(), pluginDef);
expected.chainVertices(true, expectedIf, expectedT);

PluginVertex expectedF = DSL.gPlugin(randMeta(), pluginDef);
expected.chainVertices(false, expectedIf, expectedF);

assertSyntaxEquals(expected, ifStatementGraph);
}
}

0 comments on commit f1b6d7c

Please sign in to comment.