-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#15: prepared tests for classes with duplicated code
- Loading branch information
1 parent
3fab9d5
commit 17ff20b
Showing
5 changed files
with
209 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/java/com/exasol/adapter/sql/SqlPredicateEqualTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.exasol.adapter.sql; | ||
|
||
import com.exasol.adapter.AdapterException; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class SqlPredicateEqualTest { | ||
private SqlPredicateEqual sqlPredicateEqual; | ||
private SqlLiteralDouble sqlLiteralDoubleLeft; | ||
private SqlLiteralDouble sqlLiteralDoubleRight; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
this.sqlLiteralDoubleLeft = new SqlLiteralDouble(20.5); | ||
this.sqlLiteralDoubleRight = new SqlLiteralDouble(20.5); | ||
this.sqlPredicateEqual = | ||
new SqlPredicateEqual(this.sqlLiteralDoubleLeft, this.sqlLiteralDoubleRight); | ||
} | ||
|
||
@Test | ||
void testToSimpleSql() { | ||
assertThat(this.sqlPredicateEqual.toSimpleSql(), equalTo("20.5 = 20.5")); | ||
} | ||
|
||
@Test | ||
void testGetType() { | ||
assertThat(this.sqlPredicateEqual.getType(), equalTo(SqlNodeType.PREDICATE_EQUAL)); | ||
} | ||
|
||
@Test | ||
void testAccept() throws AdapterException { | ||
final SqlNodeVisitor<SqlPredicateEqual> visitor = mock(SqlNodeVisitor.class); | ||
when(visitor.visit(this.sqlPredicateEqual)).thenReturn(this.sqlPredicateEqual); | ||
assertThat(this.sqlPredicateEqual.accept(visitor), equalTo(this.sqlPredicateEqual)); | ||
} | ||
|
||
@Test | ||
void testGetLeft() { | ||
assertThat(this.sqlPredicateEqual.getLeft(), equalTo(this.sqlLiteralDoubleLeft)); | ||
} | ||
|
||
@Test | ||
void testGetRight() { | ||
assertThat(this.sqlPredicateEqual.getRight(), equalTo(this.sqlLiteralDoubleRight)); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/test/java/com/exasol/adapter/sql/SqlPredicateLessEqualTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.exasol.adapter.sql; | ||
|
||
import com.exasol.adapter.AdapterException; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class SqlPredicateLessEqualTest { | ||
private SqlPredicateLessEqual sqlPredicateLessEqual; | ||
private SqlLiteralDouble sqlLiteralDoubleLeft; | ||
private SqlLiteralDouble sqlLiteralDoubleRight; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
this.sqlLiteralDoubleLeft = new SqlLiteralDouble(20.5); | ||
this.sqlLiteralDoubleRight = new SqlLiteralDouble(21.5); | ||
this.sqlPredicateLessEqual = | ||
new SqlPredicateLessEqual(this.sqlLiteralDoubleLeft, this.sqlLiteralDoubleRight); | ||
} | ||
|
||
@Test | ||
void testToSimpleSql() { | ||
assertThat(this.sqlPredicateLessEqual.toSimpleSql(), equalTo("20.5 <= 21.5")); | ||
} | ||
|
||
@Test | ||
void testGetType() { | ||
assertThat(this.sqlPredicateLessEqual.getType(), equalTo(SqlNodeType.PREDICATE_LESSEQUAL)); | ||
} | ||
|
||
@Test | ||
void testAccept() throws AdapterException { | ||
final SqlNodeVisitor<SqlPredicateLessEqual> visitor = mock(SqlNodeVisitor.class); | ||
when(visitor.visit(this.sqlPredicateLessEqual)).thenReturn(this.sqlPredicateLessEqual); | ||
assertThat(this.sqlPredicateLessEqual.accept(visitor), equalTo(this.sqlPredicateLessEqual)); | ||
} | ||
|
||
@Test | ||
void testGetLeft() { | ||
assertThat(this.sqlPredicateLessEqual.getLeft(), equalTo(this.sqlLiteralDoubleLeft)); | ||
} | ||
|
||
@Test | ||
void testGetRight() { | ||
assertThat(this.sqlPredicateLessEqual.getRight(), equalTo(this.sqlLiteralDoubleRight)); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
src/test/java/com/exasol/adapter/sql/SqlPredicateLessTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.exasol.adapter.sql; | ||
|
||
import com.exasol.adapter.AdapterException; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class SqlPredicateLessTest { | ||
private SqlPredicateLess sqlPredicateLess; | ||
private SqlLiteralDouble sqlLiteralDoubleLeft; | ||
private SqlLiteralDouble sqlLiteralDoubleRight; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
this.sqlLiteralDoubleLeft = new SqlLiteralDouble(20.5); | ||
this.sqlLiteralDoubleRight = new SqlLiteralDouble(21.5); | ||
this.sqlPredicateLess = | ||
new SqlPredicateLess(this.sqlLiteralDoubleLeft, this.sqlLiteralDoubleRight); | ||
} | ||
|
||
@Test | ||
void testToSimpleSql() { | ||
assertThat(this.sqlPredicateLess.toSimpleSql(), equalTo("20.5 < 21.5")); | ||
} | ||
|
||
@Test | ||
void testGetType() { | ||
assertThat(this.sqlPredicateLess.getType(), equalTo(SqlNodeType.PREDICATE_LESS)); | ||
} | ||
|
||
@Test | ||
void testAccept() throws AdapterException { | ||
final SqlNodeVisitor<SqlPredicateLess> visitor = mock(SqlNodeVisitor.class); | ||
when(visitor.visit(this.sqlPredicateLess)).thenReturn(this.sqlPredicateLess); | ||
assertThat(this.sqlPredicateLess.accept(visitor), equalTo(this.sqlPredicateLess)); | ||
} | ||
|
||
@Test | ||
void testGetLeft() { | ||
assertThat(this.sqlPredicateLess.getLeft(), equalTo(this.sqlLiteralDoubleLeft)); | ||
} | ||
|
||
@Test | ||
void testGetRight() { | ||
assertThat(this.sqlPredicateLess.getRight(), equalTo(this.sqlLiteralDoubleRight)); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/test/java/com/exasol/adapter/sql/SqlPredicateNotEqualTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.exasol.adapter.sql; | ||
|
||
import com.exasol.adapter.AdapterException; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class SqlPredicateNotEqualTest { | ||
private SqlPredicateNotEqual sqlPredicateNotEqual; | ||
private SqlLiteralDouble sqlLiteralDoubleLeft; | ||
private SqlLiteralDouble sqlLiteralDoubleRight; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
this.sqlLiteralDoubleLeft = new SqlLiteralDouble(21.5); | ||
this.sqlLiteralDoubleRight = new SqlLiteralDouble(20.5); | ||
this.sqlPredicateNotEqual = | ||
new SqlPredicateNotEqual(this.sqlLiteralDoubleLeft, this.sqlLiteralDoubleRight); | ||
} | ||
|
||
@Test | ||
void testToSimpleSql() { | ||
assertThat(this.sqlPredicateNotEqual.toSimpleSql(), equalTo("21.5 != 20.5")); | ||
} | ||
|
||
@Test | ||
void testGetType() { | ||
assertThat(this.sqlPredicateNotEqual.getType(), equalTo(SqlNodeType.PREDICATE_NOTEQUAL)); | ||
} | ||
|
||
@Test | ||
void testAccept() throws AdapterException { | ||
final SqlNodeVisitor<SqlPredicateNotEqual> visitor = mock(SqlNodeVisitor.class); | ||
when(visitor.visit(this.sqlPredicateNotEqual)).thenReturn(this.sqlPredicateNotEqual); | ||
assertThat(this.sqlPredicateNotEqual.accept(visitor), equalTo(this.sqlPredicateNotEqual)); | ||
} | ||
|
||
@Test | ||
void testGetLeft() { | ||
assertThat(this.sqlPredicateNotEqual.getLeft(), equalTo(this.sqlLiteralDoubleLeft)); | ||
} | ||
|
||
@Test | ||
void testGetRight() { | ||
assertThat(this.sqlPredicateNotEqual.getRight(), equalTo(this.sqlLiteralDoubleRight)); | ||
} | ||
} |