Initial Development #1
@ -66,6 +66,12 @@
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.11.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-junit5</artifactId>
|
||||
|
@ -3,7 +3,7 @@ package solutions.bitbadger.documents.common
|
||||
/**
|
||||
* A comparison operator used for fields
|
||||
*/
|
||||
enum class Op(sql: String) {
|
||||
enum class Op(val sql: String) {
|
||||
/** Compare using equality */
|
||||
EQUAL("="),
|
||||
/** Compare using greater-than */
|
||||
|
17
src/common/src/test/kotlin/AutoIdTest.kt
Normal file
17
src/common/src/test/kotlin/AutoIdTest.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package solutions.bitbadger.documents.common
|
||||
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
class AutoIdTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("Generates a UUID string")
|
||||
fun testGenerateUUID() {
|
||||
val generated = AutoId.generateUUID()
|
||||
assertNotNull(generated, "The UUID string should not have been null")
|
||||
assertEquals(32, generated.length, "The UUID should have been a 32-character string")
|
||||
}
|
||||
}
|
20
src/common/src/test/kotlin/FieldTest.kt
Normal file
20
src/common/src/test/kotlin/FieldTest.kt
Normal file
@ -0,0 +1,20 @@
|
||||
package solutions.bitbadger.documents.common
|
||||
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
|
||||
class FieldTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("Equal constructs a field")
|
||||
fun equalCtor() {
|
||||
val field = Field.Equal("Test", 14)
|
||||
assertEquals("Test", field.name, "Field name not filled correctly")
|
||||
assertEquals(Op.EQUAL, field.comparison.op, "Field comparison operation not filled correctly")
|
||||
assertEquals(14, field.comparison.value, "Field comparison value not filled correctly")
|
||||
assertNull(field.parameterName, "The parameter name should have been null")
|
||||
assertNull(field.qualifier, "The qualifier should have been null")
|
||||
}
|
||||
}
|
74
src/common/src/test/kotlin/OpTest.kt
Normal file
74
src/common/src/test/kotlin/OpTest.kt
Normal file
@ -0,0 +1,74 @@
|
||||
package solutions.bitbadger.documents.common
|
||||
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class OpTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("EQUAL uses proper SQL")
|
||||
fun equalSQL() {
|
||||
assertEquals("=", Op.EQUAL.sql, "The SQL for equal is incorrect")
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("GREATER uses proper SQL")
|
||||
fun greaterSQL() {
|
||||
assertEquals(">", Op.GREATER.sql, "The SQL for greater is incorrect")
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("GREATER_OR_EQUAL uses proper SQL")
|
||||
fun greaterOrEqualSQL() {
|
||||
assertEquals(">=", Op.GREATER_OR_EQUAL.sql, "The SQL for greater-or-equal is incorrect")
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("LESS uses proper SQL")
|
||||
fun lessSQL() {
|
||||
assertEquals("<", Op.LESS.sql, "The SQL for less is incorrect")
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("LESS_OR_EQUAL uses proper SQL")
|
||||
fun lessOrEqualSQL() {
|
||||
assertEquals("<=", Op.LESS_OR_EQUAL.sql, "The SQL for less-or-equal is incorrect")
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("NOT_EQUAL uses proper SQL")
|
||||
fun notEqualSQL() {
|
||||
assertEquals("<>", Op.NOT_EQUAL.sql, "The SQL for not-equal is incorrect")
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("BETWEEN uses proper SQL")
|
||||
fun betweenSQL() {
|
||||
assertEquals("BETWEEN", Op.BETWEEN.sql, "The SQL for between is incorrect")
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("IN uses proper SQL")
|
||||
fun inSQL() {
|
||||
assertEquals("IN", Op.IN.sql, "The SQL for in is incorrect")
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("IN_ARRAY uses proper SQL")
|
||||
fun inArraySQL() {
|
||||
assertEquals("?|", Op.IN_ARRAY.sql, "The SQL for in-array is incorrect")
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("EXISTS uses proper SQL")
|
||||
fun existsSQL() {
|
||||
assertEquals("IS NOT NULL", Op.EXISTS.sql, "The SQL for exists is incorrect")
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("NOT_EXISTS uses proper SQL")
|
||||
fun notExistsSQL() {
|
||||
assertEquals("IS NULL", Op.NOT_EXISTS.sql, "The SQL for not-exists is incorrect")
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user