Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start doing Behavior Test Driven Design for Version 2 #46

Open
wants to merge 18 commits into
base: use-cases-docs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.10.4] - 2019-07-17

Fix issed where occurences of XML elements containing text weren't being validated (https://github.com/ShopRunner/baleen/pull/51)

## [1.10.3] - 2019-07-16

Fix line aware handler for xml of occurrences (https://github.com/ShopRunner/baleen/pull/50)

## [1.10.2] - 2019-06-13

Add JCenter to the gradle repositories to fix Dokka dependency.
Expand Down Expand Up @@ -62,4 +70,3 @@ Dependencies bump
## [1.0] - 2018-06-12

* Initial Release

Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import com.shoprunner.baleen.types.StringConstantType
import com.shoprunner.baleen.types.StringType
import com.shoprunner.baleen.types.TimestampMillisType
import com.shoprunner.baleen.types.UnionType
import java.io.File
import java.nio.file.Path
import org.apache.avro.JsonProperties
import org.apache.avro.LogicalTypes
import org.apache.avro.Schema
import java.io.File
import java.nio.file.Path

object AvroGenerator {

Expand Down Expand Up @@ -111,4 +111,4 @@ object AvroGenerator {
out.append(this.toString(true))
return out
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,4 @@ object BaleenGenerator {
.addType(processSchema(schema))
.build()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ import com.shoprunner.baleen.types.LongType
import com.shoprunner.baleen.types.MapType
import com.shoprunner.baleen.types.OccurrencesType
import com.shoprunner.baleen.types.StringCoercibleToFloat
import com.shoprunner.baleen.types.StringCoercibleToLong
import com.shoprunner.baleen.types.StringCoercibleToInstant
import com.shoprunner.baleen.types.StringCoercibleToLong
import com.shoprunner.baleen.types.StringConstantType
import com.shoprunner.baleen.types.StringType
import com.shoprunner.baleen.types.TimestampMillisType
import com.shoprunner.baleen.types.UnionType
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.PrintStream
import org.apache.avro.LogicalTypes
import org.apache.avro.Schema
import org.assertj.core.api.Assertions
Expand All @@ -31,9 +34,6 @@ import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.PrintStream

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class AvroGeneratorTest {
Expand Down Expand Up @@ -724,4 +724,4 @@ class AvroGeneratorTest {
assertThat(outputStream.toString()).isEqualToIgnoringWhitespace(schemaWithDefaultStr)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import com.shoprunner.baleen.avro.BaleenGenerator.encode
import com.squareup.kotlinpoet.CodeBlock
import com.squareup.kotlinpoet.FileSpec
import com.squareup.kotlinpoet.PropertySpec
import java.io.File
import java.net.URLClassLoader
import java.util.logging.Logger
import org.apache.avro.JsonProperties
import org.apache.avro.LogicalType
import org.apache.avro.Schema
Expand All @@ -19,9 +22,6 @@ import org.jetbrains.kotlin.config.Services
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import java.io.File
import java.net.URLClassLoader
import java.util.logging.Logger

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class BaleenGeneratorTest {
Expand Down Expand Up @@ -324,4 +324,4 @@ internal class BaleenGeneratorTest {
Assertions.assertThat(packDescription).isEqualTo(DataDescription::class.java)
}
}
}
}
2 changes: 1 addition & 1 deletion baleen-csv/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
api project(':baleen')
api 'io.reactivex.rxjava2:rxjava:2.2.9'
api 'io.reactivex.rxjava2:rxjava:2.2.10'
implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
implementation 'com.opencsv:opencsv:4.6'
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ object FlowableUtil {
.tag("line", lineNumber.toString()))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ fun main(args: Array<String>) {

val duration = System.nanoTime() - startTime
println("Took ${duration / 1000_000} ms")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import com.shoprunner.baleen.types.LongType
import com.shoprunner.baleen.types.StringCoercibleToLong
import com.shoprunner.baleen.types.StringType
import io.reactivex.rxkotlin.toFlowable
import java.io.StringReader
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import java.io.StringReader

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class FlowableUtilTest {
Expand Down Expand Up @@ -92,4 +92,4 @@ internal class FlowableUtilTest {
)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ object PrintUtil {
onError = { println(it) }
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ object JsonSchemaGenerator {
}
return out
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,4 @@ object JsonSchemaGenerator {
}
return out
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import com.shoprunner.baleen.types.StringConstantType
import com.shoprunner.baleen.types.StringType
import com.shoprunner.baleen.types.TimestampMillisType
import com.shoprunner.baleen.types.UnionType
import java.io.ByteArrayOutputStream
import java.io.PrintStream
import org.assertj.core.api.Assertions
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import java.io.ByteArrayOutputStream
import java.io.PrintStream

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class JsonSchemaGeneratorTest {
Expand Down Expand Up @@ -430,4 +430,4 @@ internal class JsonSchemaGeneratorTest {
Assertions.assertThat(outputStream.toString()).isEqualToIgnoringWhitespace(schemaStr)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import com.shoprunner.baleen.types.StringConstantType
import com.shoprunner.baleen.types.StringType
import com.shoprunner.baleen.types.TimestampMillisType
import com.shoprunner.baleen.types.UnionType
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.PrintStream
import org.assertj.core.api.Assertions
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.PrintStream

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class JsonSchemaGeneratorTest {
Expand Down Expand Up @@ -1489,4 +1489,4 @@ internal class JsonSchemaGeneratorTest {
Assertions.assertThat(content).isEqualToIgnoringWhitespace(schemaStr)
}
}
}
}
29 changes: 29 additions & 0 deletions baleen-v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Preparation for version 2

Do test driven development for version 2

```bash
./gradlew build -Pversion2
./gradlew :baleen-v2:build -Pversion2

```

## Use Case 1 - Given we have the data, we define the schema manually and validate the data

[UseCase1Test.kt](baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase1Test.kt)

## Use Case 2 - Given we have the data, we learn the schema and validate the data

[UseCase2Test.kt](baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase2Test.kt)

## Use Case 3 - Given a external schema (Avro, XSD, Json-Schema, Kotlin data class), build Baleen schema and validate the data

[UseCase3Test.kt](baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase3Test.kt)

## Use Case 4 - Given a Baleen schema, create external schema (Avro, XSD, Json-Schema, Kotlin data class) and validate the data with the external schema

[UseCase4Test.kt](baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt)

## Use Case 5 - Baleen is multiplatform and can be run on JVM, in Javascript from node and from the browser, and from Python via Cinteropt

[baleen-v2/build.gradle](baleen-v2/build.gradle)
31 changes: 31 additions & 0 deletions baleen-v2/baleen-v2-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
dependencies {
api project(':baleen')
api project(':baleen-csv')
api project(':baleen-xml')
api project(':baleen-xsd-generator')
api project(':jsonschema-baleen-generator')
api project(':baleen-jsonschema-generator')
api project(':baleen-avro-generator')
api "org.apache.avro:avro:1.9.0"
implementation 'org.jetbrains.kotlin:kotlin-reflect'

// For Json schema validation tests
testImplementation 'com.github.everit-org.json-schema:org.everit.json.schema:1.11.1'

// Just to get some test helpers. Promote those test helpers to top-level module.
testImplementation files(project(":baleen").sourceSets.test.output)
}

repositories {
maven { url "https://jitpack.io" }
}

test {
ignoreFailures = true
}

if (!project.hasProperty("version2")) {
project.tasks.each {
it.onlyIf { false }
}
}
Loading