From 82076362664c7e142f3631bc2d2b1745f83379c0 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" Date: Thu, 20 Jun 2019 10:44:36 +0000 Subject: [PATCH 01/18] Bump org.jetbrains.kotlin.jvm from 1.3.31 to 1.3.40 (#44) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 16dfd190..26cc6b12 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { id 'idea' id "org.jetbrains.dokka" version "0.9.18" apply false - id 'org.jetbrains.kotlin.jvm' version '1.3.31' apply false + id 'org.jetbrains.kotlin.jvm' version '1.3.40' apply false id 'org.jmailen.kotlinter' version '1.26.0' apply false } From 3a012656cbee45600c628c9bc77f152c994646ac Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 21 Jun 2019 14:33:20 +0000 Subject: [PATCH 02/18] Bump rxjava from 2.2.9 to 2.2.10 (#45) --- baleen-csv/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baleen-csv/build.gradle b/baleen-csv/build.gradle index 91120716..3d8eb603 100644 --- a/baleen-csv/build.gradle +++ b/baleen-csv/build.gradle @@ -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' } From 423a4bf131014cbdaa706752ec2b5f692f4a270d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2019 13:54:40 +0000 Subject: [PATCH 03/18] Bump junit-jupiter-engine from 5.4.2 to 5.5.0 (#47) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 26cc6b12..9dc3285b 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ subprojects { implementation "org.jetbrains.kotlin:kotlin-stdlib" testImplementation 'org.assertj:assertj-core:3.12.2' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2' - testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.4.2' + testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.5.0' } test { From 8759d583b2ee23429263b879cf60ce7166891f0a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2019 13:57:58 +0000 Subject: [PATCH 04/18] Bump junit-jupiter-api from 5.4.2 to 5.5.0 (#48) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9dc3285b..a8f682ba 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ subprojects { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib" testImplementation 'org.assertj:assertj-core:3.12.2' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.0' testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.5.0' } From 83a38e665970833bfeb2468449ae710480a60f82 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2019 14:01:04 +0000 Subject: [PATCH 05/18] Bump org.jetbrains.kotlin.jvm from 1.3.40 to 1.3.41 (#49) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a8f682ba..61f51144 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { id 'idea' id "org.jetbrains.dokka" version "0.9.18" apply false - id 'org.jetbrains.kotlin.jvm' version '1.3.40' apply false + id 'org.jetbrains.kotlin.jvm' version '1.3.41' apply false id 'org.jmailen.kotlinter' version '1.26.0' apply false } From 8be43e50e451967da7c029433de82ead8e206bcf Mon Sep 17 00:00:00 2001 From: Ken Dallmeyer Date: Tue, 16 Jul 2019 11:03:21 -0500 Subject: [PATCH 06/18] Fix issue where occurrences of elements in XML weren't being validated (#50) The last occurrance was the only one returned to the validator --- .../shoprunner/baleen/xml/LineAwareHandler.kt | 16 +++++- .../com/shoprunner/baleen/xml/XmlUtilTest.kt | 54 +++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt b/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt index 474c5ef2..618f93ab 100644 --- a/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt +++ b/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt @@ -65,11 +65,25 @@ internal class LineAwareHandler : DefaultHandler() { } } - parent.hash[localName] = currentNode + pushParent(parent, localName, currentNode) elementStack.push(currentNode) } + private fun pushParent(parent: XmlDataNode, key: String, value: XmlDataNode) { + // If the key is present + if (parent.containsKey(key)) { + val existing = parent.hash[key] + if (existing is XmlDataLeaf && existing.value is Iterable<*>) { + parent.hash[key] = XmlDataLeaf(existing.value + value, existing.line, existing.column) + } else { + parent.hash[key] = XmlDataLeaf(listOf(existing, value), existing?.line, existing?.column) + } + } else { + parent.hash[key] = value + } + } + /** * Triggered when an end tag is seen or its the end of single element tag. Ex: or * diff --git a/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/XmlUtilTest.kt b/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/XmlUtilTest.kt index da943556..17d22737 100644 --- a/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/XmlUtilTest.kt +++ b/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/XmlUtilTest.kt @@ -4,6 +4,8 @@ import com.shoprunner.baleen.Baleen import com.shoprunner.baleen.Context import com.shoprunner.baleen.Data import com.shoprunner.baleen.DataValue +import com.shoprunner.baleen.ValidationInfo +import com.shoprunner.baleen.ValidationSuccess import com.shoprunner.baleen.dataTrace import com.shoprunner.baleen.datawrappers.HashData import com.shoprunner.baleen.types.OccurrencesType @@ -103,6 +105,58 @@ internal class XmlUtilTest { assertThat(packContainer.validate(context)).isValid() } + @Test + fun `returned data validation returns the nested list`() { + val inputStream = multipleOccurrences.byteInputStream() + val context = XmlUtil.fromXmlToContext(dataTrace("example.xml"), inputStream) + + val fidoLeaf = XmlDataLeaf(value = "Fido", line = 3, column = 15) + val fidoNameNode = XmlDataNode(2, 10).apply { hash["name"] = fidoLeaf } + val dougLeaf = XmlDataLeaf(value = "Doug", line = 6, column = 15) + val dougNameNode = XmlDataNode(5, 10).apply { hash["name"] = dougLeaf } + val dogLeaf = XmlDataLeaf(value = listOf(fidoNameNode, dougNameNode), line = 2, column = 10) + + val packNode = XmlDataNode(1, 7).apply { hash["dog"] = dogLeaf } + + val rootNode = XmlDataNode().apply { hash["pack"] = packNode } + + val validation = packContainer.validate(context) + val results = validation.results.toList() + + assertThat(validation.context).isEqualTo(context) + + assertThat(results).hasSize(5) + + assertThat(results[0]).isEqualTo(ValidationInfo( + dataTrace = dataTrace("example.xml"), + message = "has attribute \"pack\"", + value = rootNode + )) + + assertThat(results[1]).isEqualTo(ValidationInfo( + dataTrace = dataTrace("example.xml", "attribute \"pack\"").tag("line", "1").tag("column", "7"), + message = "has attribute \"dog\"", + value = packNode + )) + + assertThat(results[2]).isEqualTo(ValidationInfo( + dataTrace = dataTrace("example.xml", "attribute \"pack\"", "attribute \"dog\"", "index 0").tag("line", "2").tag("column", "10"), + message = "has attribute \"name\"", + value = fidoNameNode + )) + + assertThat(results[3]).isEqualTo(ValidationInfo( + dataTrace = dataTrace("example.xml", "attribute \"pack\"", "attribute \"dog\"", "index 1").tag("line", "2").tag("column", "10"), + message = "has attribute \"name\"", + value = dougNameNode + )) + + assertThat(results[4]).isEqualTo(ValidationSuccess( + dataTrace = dataTrace("example.xml"), + value = rootNode + )) + } + @Test fun `data trace for root is correct`() { val inputStream = multipleOccurrences.byteInputStream() From 03a371f48550434dce8824fa5f7d96667a62264c Mon Sep 17 00:00:00 2001 From: "Michael R. Maletich" Date: Tue, 16 Jul 2019 11:06:30 -0500 Subject: [PATCH 07/18] Version 1.10.3 --- CHANGELOG.md | 5 ++++- gradle.properties | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a1c1a81..1268bc28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [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. @@ -62,4 +66,3 @@ Dependencies bump ## [1.0] - 2018-06-12 * Initial Release - diff --git a/gradle.properties b/gradle.properties index 1e4a84cd..54876120 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=1.10.2 +version=1.10.3 group=com.shoprunner sonatypeUsername= From 4d96a4da4d51c203257e805ca48895d44b7875c0 Mon Sep 17 00:00:00 2001 From: Ken Dallmeyer Date: Wed, 17 Jul 2019 10:57:15 -0500 Subject: [PATCH 08/18] Fix issed where occurences of XML elements containing text weren't being validated (#51) --- .../shoprunner/baleen/xml/LineAwareHandler.kt | 14 ++++- .../com/shoprunner/baleen/xml/XmlUtilTest.kt | 56 +++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt b/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt index 618f93ab..2b1bd2f2 100644 --- a/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt +++ b/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt @@ -96,7 +96,19 @@ internal class LineAwareHandler : DefaultHandler() { elementStack.pop() val current = elementStack.peek() val old = current.hash[localName]!! - current.hash[localName] = XmlDataLeaf(value = textBuffer.trim(), line = old.line, column = old.column) + + if (old is XmlDataLeaf && old.value is Iterable<*>) { + val head = old.value.flatMap { + when (it) { + is XmlDataLeaf -> listOf(it.value) + is String -> listOf(it) + else -> emptyList() + } + } + current.hash[localName] = XmlDataLeaf(head + textBuffer.trim(), old.line, old.column) + } else { + current.hash[localName] = XmlDataLeaf(value = textBuffer.trim(), line = old.line, column = old.column) + } textBuffer.clear() } else -> elementStack.pop() diff --git a/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/XmlUtilTest.kt b/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/XmlUtilTest.kt index 17d22737..ef597dc2 100644 --- a/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/XmlUtilTest.kt +++ b/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/XmlUtilTest.kt @@ -4,6 +4,7 @@ import com.shoprunner.baleen.Baleen import com.shoprunner.baleen.Context import com.shoprunner.baleen.Data import com.shoprunner.baleen.DataValue +import com.shoprunner.baleen.ValidationError import com.shoprunner.baleen.ValidationInfo import com.shoprunner.baleen.ValidationSuccess import com.shoprunner.baleen.dataTrace @@ -157,6 +158,61 @@ internal class XmlUtilTest { )) } + @Test + fun `can validate a list of strings`() { + val pack = Baleen.describe("Pack") { p -> + p.attr(name = "dog", + type = OccurrencesType(StringType(max = 3)), + required = true) + } + val packContainer = Baleen.describe("PackContainer") { p -> + p.attr(name = "pack", + type = pack, + required = true) + } + + val multipleOccurrences = """ + + Dug + Fido + Bo + + """.trimIndent() + + val dogLeaf = XmlDataLeaf(value = listOf("Dug", "Fido", "Bo"), line = 2, column = 7) + + val packNode = XmlDataNode(1, 7).apply { hash["dog"] = dogLeaf } + val rootNode = XmlDataNode().apply { hash["pack"] = packNode } + + val inputStream = multipleOccurrences.byteInputStream() + val context = XmlUtil.fromXmlToContext(dataTrace("example.xml"), inputStream) + + val validation = packContainer.validate(context) + val results = validation.results.toList() + + assertThat(validation.context).isEqualTo(context) + + assertThat(results).hasSize(3) + + assertThat(results[0]).isEqualTo(ValidationInfo( + dataTrace = dataTrace("example.xml"), + message = "has attribute \"pack\"", + value = rootNode + )) + + assertThat(results[1]).isEqualTo(ValidationInfo( + dataTrace = dataTrace("example.xml", "attribute \"pack\"").tag("line", "1").tag("column", "7"), + message = "has attribute \"dog\"", + value = packNode + )) + + assertThat(results[2]).isEqualTo(ValidationError( + dataTrace = dataTrace("example.xml", "attribute \"pack\"", "attribute \"dog\"", "index 1").tag("line", "2").tag("column", "10"), + message = "is more than 3 characters", + value = "Fido" + )) + } + @Test fun `data trace for root is correct`() { val inputStream = multipleOccurrences.byteInputStream() From 50b5c04ed8ee1ade4e41856615e220f5c09fefb3 Mon Sep 17 00:00:00 2001 From: "Michael R. Maletich" Date: Wed, 17 Jul 2019 11:01:40 -0500 Subject: [PATCH 09/18] Version 1.10.4 --- CHANGELOG.md | 4 ++++ gradle.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1268bc28..ba98664e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ 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) diff --git a/gradle.properties b/gradle.properties index 54876120..7f49e790 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=1.10.3 +version=1.10.4 group=com.shoprunner sonatypeUsername= From 1763447370528d9bc5dd2cf2dfa0dda56feb55d3 Mon Sep 17 00:00:00 2001 From: "Michael R. Maletich" Date: Tue, 23 Jul 2019 06:31:57 -0500 Subject: [PATCH 10/18] Upgrade to Kotlinter 2.1 This has a fix for the version of kotlinter 2.0 which dependabot has a pull request today. --- .../com/shoprunner/baleen/avro/AvroGenerator.kt | 6 +++--- .../com/shoprunner/baleen/avro/BaleenGenerator.kt | 2 +- .../shoprunner/baleen/avro/AvroGeneratorTest.kt | 10 +++++----- .../shoprunner/baleen/avro/BaleenGeneratorTest.kt | 8 ++++---- .../com/shoprunner/baleen/csv/FlowableUtil.kt | 2 +- .../kotlin/com/shoprunner/baleen/csv/Example.kt | 2 +- .../com/shoprunner/baleen/csv/FlowableUtilTest.kt | 4 ++-- .../kotlin/com/shoprunner/baleen/csv/PrintUtil.kt | 2 +- .../baleen/jsonschema/v3/JsonSchemaGenerator.kt | 2 +- .../baleen/jsonschema/v4/JsonSchemaGenerator.kt | 2 +- .../jsonschema/v3/JsonSchemaGeneratorTest.kt | 6 +++--- .../jsonschema/v4/JsonSchemaGeneratorTest.kt | 8 ++++---- .../com/shoprunner/baleen/xml/LineAwareHandler.kt | 4 ++-- .../com/shoprunner/baleen/xml/XmlDataNode.kt | 2 +- .../kotlin/com/shoprunner/baleen/xml/XmlUtil.kt | 2 +- .../com/shoprunner/baleen/xml/ValidationAssert.kt | 2 +- .../com/shoprunner/baleen/xml/XmlUtilTest.kt | 2 +- .../com/shoprunner/baleen/xsd/TypeDetails.kt | 2 +- .../kotlin/com/shoprunner/baleen/xsd/TypeMapper.kt | 2 +- .../com/shoprunner/baleen/xsd/XsdGenerator.kt | 2 +- .../com/shoprunner/baleen/xsd/xml/Annotation.kt | 2 +- .../com/shoprunner/baleen/xsd/xml/ComplexType.kt | 2 +- .../com/shoprunner/baleen/xsd/xml/Element.kt | 2 +- .../com/shoprunner/baleen/xsd/xml/Enumeration.kt | 2 +- .../com/shoprunner/baleen/xsd/xml/MaxInclusive.kt | 2 +- .../com/shoprunner/baleen/xsd/xml/MaxLength.kt | 2 +- .../com/shoprunner/baleen/xsd/xml/MinInclusive.kt | 2 +- .../com/shoprunner/baleen/xsd/xml/MinLength.kt | 2 +- .../com/shoprunner/baleen/xsd/xml/Restriction.kt | 2 +- .../kotlin/com/shoprunner/baleen/xsd/xml/Schema.kt | 2 +- .../com/shoprunner/baleen/xsd/xml/Sequence.kt | 2 +- .../com/shoprunner/baleen/xsd/xml/SimpleType.kt | 2 +- .../com/shoprunner/baleen/xsd/XsdGeneratorTest.kt | 8 ++++---- .../com/shoprunner/baleen/AttributeDescription.kt | 2 +- .../kotlin/com/shoprunner/baleen/BaleenType.kt | 2 +- .../main/kotlin/com/shoprunner/baleen/Context.kt | 2 +- .../com/shoprunner/baleen/DataDescription.kt | 2 +- .../main/kotlin/com/shoprunner/baleen/DataTrace.kt | 2 +- .../main/kotlin/com/shoprunner/baleen/DataValue.kt | 2 +- .../main/kotlin/com/shoprunner/baleen/NoDefault.kt | 2 +- .../kotlin/com/shoprunner/baleen/Validation.kt | 2 +- .../com/shoprunner/baleen/ValidationError.kt | 2 +- .../kotlin/com/shoprunner/baleen/ValidationInfo.kt | 2 +- .../com/shoprunner/baleen/ValidationResult.kt | 2 +- .../com/shoprunner/baleen/ValidationSuccess.kt | 2 +- .../com/shoprunner/baleen/ValidationWarning.kt | 2 +- .../main/kotlin/com/shoprunner/baleen/Validator.kt | 2 +- .../com/shoprunner/baleen/datawrappers/HashData.kt | 2 +- .../com/shoprunner/baleen/types/AllowsNull.kt | 2 +- .../com/shoprunner/baleen/types/BooleanType.kt | 2 +- .../com/shoprunner/baleen/types/CoercibleType.kt | 2 +- .../com/shoprunner/baleen/types/DoubleType.kt | 2 +- .../kotlin/com/shoprunner/baleen/types/EnumType.kt | 2 +- .../shoprunner/baleen/types/ErrorsAreWarnings.kt | 2 +- .../com/shoprunner/baleen/types/FloatType.kt | 2 +- .../com/shoprunner/baleen/types/InstantType.kt | 2 +- .../kotlin/com/shoprunner/baleen/types/IntType.kt | 2 +- .../baleen/types/LongCoercibleToInstant.kt | 2 +- .../shoprunner/baleen/types/LongCoercibleToType.kt | 2 +- .../kotlin/com/shoprunner/baleen/types/LongType.kt | 2 +- .../kotlin/com/shoprunner/baleen/types/MapType.kt | 2 +- .../com/shoprunner/baleen/types/OccurrencesType.kt | 2 +- .../baleen/types/StringCoercibleToBoolean.kt | 2 +- .../baleen/types/StringCoercibleToFloat.kt | 2 +- .../baleen/types/StringCoercibleToInstant.kt | 2 +- .../baleen/types/StringCoercibleToLong.kt | 2 +- .../baleen/types/StringCoercibleToTimestamp.kt | 2 +- .../baleen/types/StringCoercibleToType.kt | 2 +- .../shoprunner/baleen/types/StringConstantType.kt | 2 +- .../com/shoprunner/baleen/types/StringType.kt | 2 +- .../shoprunner/baleen/types/TimestampMillisType.kt | 2 +- .../kotlin/com/shoprunner/baleen/BaleenTest.kt | 2 +- .../kotlin/com/shoprunner/baleen/SequenceAssert.kt | 2 +- .../com/shoprunner/baleen/ValidationAssert.kt | 2 +- .../com/shoprunner/baleen/types/AllowsNullTest.kt | 2 +- .../com/shoprunner/baleen/types/BooleanTypeTest.kt | 2 +- .../com/shoprunner/baleen/types/DoubleTypeTest.kt | 2 +- .../com/shoprunner/baleen/types/EnumTypeTest.kt | 2 +- .../com/shoprunner/baleen/types/FloatTypeTest.kt | 2 +- .../com/shoprunner/baleen/types/InstantTypeTest.kt | 4 ++-- .../com/shoprunner/baleen/types/IntTypeTest.kt | 2 +- .../baleen/types/LongCoercibleToInstantTest.kt | 4 ++-- .../com/shoprunner/baleen/types/LongTypeTest.kt | 2 +- .../com/shoprunner/baleen/types/MapTypeTest.kt | 2 +- .../shoprunner/baleen/types/OccurrencesTypeTest.kt | 2 +- .../baleen/types/StringCoercibleToFloatTest.kt | 2 +- .../baleen/types/StringCoercibleToInstantTest.kt | 2 +- .../baleen/types/StringCoercibleToLongTest.kt | 2 +- .../baleen/types/StringConstantTypeTest.kt | 2 +- .../com/shoprunner/baleen/types/StringTypeTest.kt | 2 +- .../com/shoprunner/baleen/types/UnionTypeTest.kt | 2 +- build.gradle | 4 ++-- .../baleen/jsonschema/v4/BaleenGenerator.kt | 2 +- .../baleen/jsonschema/v4/BaleenGeneratorTest.kt | 14 +++++++------- .../com/shoprunner/baleen/jsonschema/v4/AllOf.kt | 2 +- .../com/shoprunner/baleen/jsonschema/v4/AnyOf.kt | 2 +- .../shoprunner/baleen/jsonschema/v4/ArraySchema.kt | 2 +- .../baleen/jsonschema/v4/BooleanSchema.kt | 2 +- .../baleen/jsonschema/v4/DateTimeSchema.kt | 2 +- .../baleen/jsonschema/v4/IntegerSchema.kt | 2 +- .../shoprunner/baleen/jsonschema/v4/JsonSchema.kt | 2 +- .../baleen/jsonschema/v4/JsonSchemaDeserializer.kt | 2 +- .../shoprunner/baleen/jsonschema/v4/JsonType.kt | 2 +- .../shoprunner/baleen/jsonschema/v4/MapSchema.kt | 2 +- .../com/shoprunner/baleen/jsonschema/v4/Not.kt | 2 +- .../com/shoprunner/baleen/jsonschema/v4/Null.kt | 2 +- .../baleen/jsonschema/v4/NullJsonSerializer.kt | 2 +- .../shoprunner/baleen/jsonschema/v4/NullSchema.kt | 2 +- .../baleen/jsonschema/v4/NumberSchema.kt | 2 +- .../baleen/jsonschema/v4/ObjectReference.kt | 2 +- .../baleen/jsonschema/v4/ObjectSchema.kt | 2 +- .../com/shoprunner/baleen/jsonschema/v4/OneOf.kt | 2 +- .../baleen/jsonschema/v4/RootJsonSchema.kt | 2 +- .../baleen/jsonschema/v4/SelfDescribing.kt | 2 +- .../baleen/jsonschema/v4/StringFormats.kt | 2 +- .../baleen/jsonschema/v4/StringSchema.kt | 2 +- .../shoprunner/baleen/jsonschema/v4/UnionSchema.kt | 2 +- 117 files changed, 145 insertions(+), 145 deletions(-) diff --git a/baleen-avro-generator/src/main/kotlin/com/shoprunner/baleen/avro/AvroGenerator.kt b/baleen-avro-generator/src/main/kotlin/com/shoprunner/baleen/avro/AvroGenerator.kt index 5b940c94..df451636 100644 --- a/baleen-avro-generator/src/main/kotlin/com/shoprunner/baleen/avro/AvroGenerator.kt +++ b/baleen-avro-generator/src/main/kotlin/com/shoprunner/baleen/avro/AvroGenerator.kt @@ -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 { @@ -111,4 +111,4 @@ object AvroGenerator { out.append(this.toString(true)) return out } -} \ No newline at end of file +} diff --git a/baleen-avro-generator/src/main/kotlin/com/shoprunner/baleen/avro/BaleenGenerator.kt b/baleen-avro-generator/src/main/kotlin/com/shoprunner/baleen/avro/BaleenGenerator.kt index 6b539440..1a1b0d25 100644 --- a/baleen-avro-generator/src/main/kotlin/com/shoprunner/baleen/avro/BaleenGenerator.kt +++ b/baleen-avro-generator/src/main/kotlin/com/shoprunner/baleen/avro/BaleenGenerator.kt @@ -197,4 +197,4 @@ object BaleenGenerator { .addType(processSchema(schema)) .build() } -} \ No newline at end of file +} diff --git a/baleen-avro-generator/src/test/kotlin/com/shoprunner/baleen/avro/AvroGeneratorTest.kt b/baleen-avro-generator/src/test/kotlin/com/shoprunner/baleen/avro/AvroGeneratorTest.kt index 23157449..04eaf2de 100644 --- a/baleen-avro-generator/src/test/kotlin/com/shoprunner/baleen/avro/AvroGeneratorTest.kt +++ b/baleen-avro-generator/src/test/kotlin/com/shoprunner/baleen/avro/AvroGeneratorTest.kt @@ -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 @@ -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 { @@ -724,4 +724,4 @@ class AvroGeneratorTest { assertThat(outputStream.toString()).isEqualToIgnoringWhitespace(schemaWithDefaultStr) } } -} \ No newline at end of file +} diff --git a/baleen-avro-generator/src/test/kotlin/com/shoprunner/baleen/avro/BaleenGeneratorTest.kt b/baleen-avro-generator/src/test/kotlin/com/shoprunner/baleen/avro/BaleenGeneratorTest.kt index a189ef2a..ec5a8d36 100644 --- a/baleen-avro-generator/src/test/kotlin/com/shoprunner/baleen/avro/BaleenGeneratorTest.kt +++ b/baleen-avro-generator/src/test/kotlin/com/shoprunner/baleen/avro/BaleenGeneratorTest.kt @@ -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 @@ -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 { @@ -324,4 +324,4 @@ internal class BaleenGeneratorTest { Assertions.assertThat(packDescription).isEqualTo(DataDescription::class.java) } } -} \ No newline at end of file +} diff --git a/baleen-csv/src/main/kotlin/com/shoprunner/baleen/csv/FlowableUtil.kt b/baleen-csv/src/main/kotlin/com/shoprunner/baleen/csv/FlowableUtil.kt index 711764d9..4bd3ebd1 100644 --- a/baleen-csv/src/main/kotlin/com/shoprunner/baleen/csv/FlowableUtil.kt +++ b/baleen-csv/src/main/kotlin/com/shoprunner/baleen/csv/FlowableUtil.kt @@ -69,4 +69,4 @@ object FlowableUtil { .tag("line", lineNumber.toString())) } } -} \ No newline at end of file +} diff --git a/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/Example.kt b/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/Example.kt index 9b119346..fef8312d 100644 --- a/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/Example.kt +++ b/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/Example.kt @@ -55,4 +55,4 @@ fun main(args: Array) { val duration = System.nanoTime() - startTime println("Took ${duration / 1000_000} ms") -} \ No newline at end of file +} diff --git a/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/FlowableUtilTest.kt b/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/FlowableUtilTest.kt index 01b21fe4..9d877111 100644 --- a/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/FlowableUtilTest.kt +++ b/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/FlowableUtilTest.kt @@ -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 { @@ -92,4 +92,4 @@ internal class FlowableUtilTest { ) ) } -} \ No newline at end of file +} diff --git a/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/PrintUtil.kt b/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/PrintUtil.kt index f88c6e59..f33f30e2 100644 --- a/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/PrintUtil.kt +++ b/baleen-csv/src/test/kotlin/com/shoprunner/baleen/csv/PrintUtil.kt @@ -33,4 +33,4 @@ object PrintUtil { onError = { println(it) } ) } -} \ No newline at end of file +} diff --git a/baleen-jsonschema-generator/src/main/kotlin/com/shoprunner/baleen/jsonschema/v3/JsonSchemaGenerator.kt b/baleen-jsonschema-generator/src/main/kotlin/com/shoprunner/baleen/jsonschema/v3/JsonSchemaGenerator.kt index 5a5c7e34..4d9f29e4 100644 --- a/baleen-jsonschema-generator/src/main/kotlin/com/shoprunner/baleen/jsonschema/v3/JsonSchemaGenerator.kt +++ b/baleen-jsonschema-generator/src/main/kotlin/com/shoprunner/baleen/jsonschema/v3/JsonSchemaGenerator.kt @@ -150,4 +150,4 @@ object JsonSchemaGenerator { } return out } -} \ No newline at end of file +} diff --git a/baleen-jsonschema-generator/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaGenerator.kt b/baleen-jsonschema-generator/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaGenerator.kt index 2fc0ecee..cd22cf68 100644 --- a/baleen-jsonschema-generator/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaGenerator.kt +++ b/baleen-jsonschema-generator/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaGenerator.kt @@ -188,4 +188,4 @@ object JsonSchemaGenerator { } return out } -} \ No newline at end of file +} diff --git a/baleen-jsonschema-generator/src/test/kotlin/com/shoprunner/baleen/jsonschema/v3/JsonSchemaGeneratorTest.kt b/baleen-jsonschema-generator/src/test/kotlin/com/shoprunner/baleen/jsonschema/v3/JsonSchemaGeneratorTest.kt index 7ac7c656..1d834270 100644 --- a/baleen-jsonschema-generator/src/test/kotlin/com/shoprunner/baleen/jsonschema/v3/JsonSchemaGeneratorTest.kt +++ b/baleen-jsonschema-generator/src/test/kotlin/com/shoprunner/baleen/jsonschema/v3/JsonSchemaGeneratorTest.kt @@ -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 { @@ -430,4 +430,4 @@ internal class JsonSchemaGeneratorTest { Assertions.assertThat(outputStream.toString()).isEqualToIgnoringWhitespace(schemaStr) } } -} \ No newline at end of file +} diff --git a/baleen-jsonschema-generator/src/test/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaGeneratorTest.kt b/baleen-jsonschema-generator/src/test/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaGeneratorTest.kt index 01732743..6e530150 100644 --- a/baleen-jsonschema-generator/src/test/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaGeneratorTest.kt +++ b/baleen-jsonschema-generator/src/test/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaGeneratorTest.kt @@ -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 { @@ -1489,4 +1489,4 @@ internal class JsonSchemaGeneratorTest { Assertions.assertThat(content).isEqualToIgnoringWhitespace(schemaStr) } } -} \ No newline at end of file +} diff --git a/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt b/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt index 2b1bd2f2..a9af46f9 100644 --- a/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt +++ b/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/LineAwareHandler.kt @@ -1,9 +1,9 @@ package com.shoprunner.baleen.xml +import java.util.Stack import org.xml.sax.Attributes import org.xml.sax.Locator import org.xml.sax.helpers.DefaultHandler -import java.util.Stack /** * SAX Parser Handler to create the LineAware data from XML @@ -121,4 +121,4 @@ internal class LineAwareHandler : DefaultHandler() { override fun characters(ch: CharArray, start: Int, length: Int) { textBuffer.append(ch, start, length) } -} \ No newline at end of file +} diff --git a/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/XmlDataNode.kt b/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/XmlDataNode.kt index 406c77b1..c8f7204a 100644 --- a/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/XmlDataNode.kt +++ b/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/XmlDataNode.kt @@ -54,4 +54,4 @@ internal class XmlDataNode(line: Int? = null, column: Int? = null) : Data, XmlDa override fun hashCode(): Int { return hash.hashCode() } -} \ No newline at end of file +} diff --git a/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/XmlUtil.kt b/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/XmlUtil.kt index 4d5c18ef..90da0e7d 100644 --- a/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/XmlUtil.kt +++ b/baleen-xml/src/main/kotlin/com/shoprunner/baleen/xml/XmlUtil.kt @@ -57,4 +57,4 @@ object XmlUtil { validateFromRoot(description, this) } } -} \ No newline at end of file +} diff --git a/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/ValidationAssert.kt b/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/ValidationAssert.kt index 2f0fb3d9..c2968dae 100644 --- a/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/ValidationAssert.kt +++ b/baleen-xml/src/test/kotlin/com/shoprunner/baleen/xml/ValidationAssert.kt @@ -22,4 +22,4 @@ class ValidationAssert(actual: Validation) : AbstractAssert TypeDetails \ No newline at end of file +typealias TypeMapper = (BaleenType) -> TypeDetails diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/XsdGenerator.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/XsdGenerator.kt index 98c32f46..a037e8ab 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/XsdGenerator.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/XsdGenerator.kt @@ -152,4 +152,4 @@ object XsdGenerator { jaxbMarshaller.marshal(schema, outputStream) } -} \ No newline at end of file +} diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Annotation.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Annotation.kt index 6f5a3405..30653b66 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Annotation.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Annotation.kt @@ -5,4 +5,4 @@ import javax.xml.bind.annotation.XmlElement data class Annotation( @get:XmlElement(namespace = "http://www.w3.org/2001/XMLSchema") val documentation: String? = null -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/ComplexType.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/ComplexType.kt index 17dd2401..1ad98355 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/ComplexType.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/ComplexType.kt @@ -12,4 +12,4 @@ data class ComplexType( @get:XmlElement(namespace = "http://www.w3.org/2001/XMLSchema") val sequence: Sequence? = null -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Element.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Element.kt index af473a5c..0c1fa8c2 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Element.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Element.kt @@ -24,4 +24,4 @@ data class Element( @get:XmlAttribute val default: String? = null -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Enumeration.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Enumeration.kt index 3b66eece..5530736f 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Enumeration.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Enumeration.kt @@ -5,4 +5,4 @@ import javax.xml.bind.annotation.XmlAttribute data class Enumeration( @get:XmlAttribute val value: String? = null -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MaxInclusive.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MaxInclusive.kt index 226f8cc3..4567f026 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MaxInclusive.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MaxInclusive.kt @@ -6,4 +6,4 @@ import javax.xml.bind.annotation.XmlAttribute data class MaxInclusive( @get:XmlAttribute val value: BigDecimal? = null -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MaxLength.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MaxLength.kt index e5a0274f..baef6717 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MaxLength.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MaxLength.kt @@ -5,4 +5,4 @@ import javax.xml.bind.annotation.XmlAttribute data class MaxLength( @get:XmlAttribute val value: Int? = null -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MinInclusive.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MinInclusive.kt index d26401fe..46d2b76f 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MinInclusive.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MinInclusive.kt @@ -6,4 +6,4 @@ import javax.xml.bind.annotation.XmlAttribute data class MinInclusive( @get:XmlAttribute val value: BigDecimal? = null -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MinLength.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MinLength.kt index 8601ebe4..ce34081b 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MinLength.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/MinLength.kt @@ -5,4 +5,4 @@ import javax.xml.bind.annotation.XmlAttribute data class MinLength( @get:XmlAttribute val value: Int? = null -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Restriction.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Restriction.kt index fba98eb1..363c6322 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Restriction.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Restriction.kt @@ -21,4 +21,4 @@ data class Restriction( @get:XmlElement(namespace = "http://www.w3.org/2001/XMLSchema") val enumeration: List = emptyList() -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Schema.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Schema.kt index 395af4f9..9a59be0a 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Schema.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Schema.kt @@ -14,4 +14,4 @@ data class Schema( @get:XmlElement(name = "complexType", namespace = "http://www.w3.org/2001/XMLSchema") val complexTypes: List = emptyList() -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Sequence.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Sequence.kt index f91ce072..9552a217 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Sequence.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/Sequence.kt @@ -6,4 +6,4 @@ data class Sequence( @get:XmlElement(name = "element", namespace = "http://www.w3.org/2001/XMLSchema") val elements: List = mutableListOf() -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/SimpleType.kt b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/SimpleType.kt index 1559d353..cbc173d4 100644 --- a/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/SimpleType.kt +++ b/baleen-xsd-generator/src/main/kotlin/com/shoprunner/baleen/xsd/xml/SimpleType.kt @@ -5,4 +5,4 @@ import javax.xml.bind.annotation.XmlElement data class SimpleType( @get:XmlElement(namespace = "http://www.w3.org/2001/XMLSchema") val restriction: Restriction? = null -) \ No newline at end of file +) diff --git a/baleen-xsd-generator/src/test/kotlin/com/shoprunner/baleen/xsd/XsdGeneratorTest.kt b/baleen-xsd-generator/src/test/kotlin/com/shoprunner/baleen/xsd/XsdGeneratorTest.kt index ee1bbe3c..d4ef770a 100644 --- a/baleen-xsd-generator/src/test/kotlin/com/shoprunner/baleen/xsd/XsdGeneratorTest.kt +++ b/baleen-xsd-generator/src/test/kotlin/com/shoprunner/baleen/xsd/XsdGeneratorTest.kt @@ -16,13 +16,13 @@ import com.shoprunner.baleen.xsd.XsdGenerator.encode import com.shoprunner.baleen.xsd.xml.MinInclusive import com.shoprunner.baleen.xsd.xml.Restriction import com.shoprunner.baleen.xsd.xml.SimpleType +import java.io.ByteArrayOutputStream +import java.io.PrintStream +import java.math.BigDecimal import org.assertj.core.api.Assertions.assertThat 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 -import java.math.BigDecimal @TestInstance(TestInstance.Lifecycle.PER_CLASS) class XsdGeneratorTest { @@ -422,4 +422,4 @@ class XsdGeneratorTest { |""".trimMargin()) } } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/AttributeDescription.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/AttributeDescription.kt index 419b93a3..2c821da5 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/AttributeDescription.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/AttributeDescription.kt @@ -17,4 +17,4 @@ class AttributeDescription( fun describe(block: (AttributeDescription) -> Unit) { block(this) } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/BaleenType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/BaleenType.kt index 242f24fb..69961c29 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/BaleenType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/BaleenType.kt @@ -4,4 +4,4 @@ interface BaleenType { fun name(): String fun validate(dataTrace: DataTrace, value: Any?): Sequence -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/Context.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/Context.kt index 3b9e323b..288815c6 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/Context.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/Context.kt @@ -1,4 +1,4 @@ package com.shoprunner.baleen // TODO add parent -data class Context(val data: Data, val dataTrace: DataTrace) \ No newline at end of file +data class Context(val data: Data, val dataTrace: DataTrace) diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/DataDescription.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/DataDescription.kt index a0600576..4dd6f165 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/DataDescription.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/DataDescription.kt @@ -83,4 +83,4 @@ class DataDescription( fun test(validation: Validator) { tests.add(validation) } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/DataTrace.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/DataTrace.kt index 12ee80fc..8f0de336 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/DataTrace.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/DataTrace.kt @@ -52,4 +52,4 @@ class DataTrace private constructor( } /** wrapper method for legacy generation of DataTrace objects */ -fun dataTrace(vararg trace: String) = DataTrace(*trace) \ No newline at end of file +fun dataTrace(vararg trace: String) = DataTrace(*trace) diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/DataValue.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/DataValue.kt index fe075a8e..ef4e32b3 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/DataValue.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/DataValue.kt @@ -1,3 +1,3 @@ package com.shoprunner.baleen -data class DataValue(val value: Any?, val dataTrace: DataTrace) \ No newline at end of file +data class DataValue(val value: Any?, val dataTrace: DataTrace) diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/NoDefault.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/NoDefault.kt index ef6f1b1f..ff1f3279 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/NoDefault.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/NoDefault.kt @@ -3,4 +3,4 @@ package com.shoprunner.baleen /** * Container for no defaults */ -object NoDefault \ No newline at end of file +object NoDefault diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/Validation.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/Validation.kt index 4521ab5a..2feba2cf 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/Validation.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/Validation.kt @@ -2,4 +2,4 @@ package com.shoprunner.baleen data class Validation(val context: Context, val results: Iterable) { fun isValid() = results.none { it is ValidationError } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationError.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationError.kt index 2bdacf94..468ffd97 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationError.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationError.kt @@ -1,3 +1,3 @@ package com.shoprunner.baleen -data class ValidationError(val dataTrace: DataTrace, val message: String, val value: Any?) : ValidationResult() \ No newline at end of file +data class ValidationError(val dataTrace: DataTrace, val message: String, val value: Any?) : ValidationResult() diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationInfo.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationInfo.kt index f802bcb4..107384e3 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationInfo.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationInfo.kt @@ -1,3 +1,3 @@ package com.shoprunner.baleen -data class ValidationInfo(val dataTrace: DataTrace, val message: String, val value: Any?) : ValidationResult() \ No newline at end of file +data class ValidationInfo(val dataTrace: DataTrace, val message: String, val value: Any?) : ValidationResult() diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationResult.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationResult.kt index f317d25b..904be61c 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationResult.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationResult.kt @@ -1,3 +1,3 @@ package com.shoprunner.baleen -open class ValidationResult \ No newline at end of file +open class ValidationResult diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationSuccess.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationSuccess.kt index ed2202af..86321b5d 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationSuccess.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationSuccess.kt @@ -1,3 +1,3 @@ package com.shoprunner.baleen -data class ValidationSuccess(val dataTrace: DataTrace, val value: Any?) : ValidationResult() \ No newline at end of file +data class ValidationSuccess(val dataTrace: DataTrace, val value: Any?) : ValidationResult() diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationWarning.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationWarning.kt index 34b8d0c2..635b7b75 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationWarning.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/ValidationWarning.kt @@ -1,3 +1,3 @@ package com.shoprunner.baleen -data class ValidationWarning(val dataTrace: DataTrace, val message: String, val value: Any?) : ValidationResult() \ No newline at end of file +data class ValidationWarning(val dataTrace: DataTrace, val message: String, val value: Any?) : ValidationResult() diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/Validator.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/Validator.kt index 368c9846..3cdec43b 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/Validator.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/Validator.kt @@ -1,3 +1,3 @@ package com.shoprunner.baleen -typealias Validator = (DataTrace, Data) -> Sequence \ No newline at end of file +typealias Validator = (DataTrace, Data) -> Sequence diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/datawrappers/HashData.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/datawrappers/HashData.kt index 35e9307c..6b939746 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/datawrappers/HashData.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/datawrappers/HashData.kt @@ -19,4 +19,4 @@ class HashData(private val hash: Map) : Data { override fun toString(): String { return "HashData{ $hash }" } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/AllowsNull.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/AllowsNull.kt index 3a4f4ddb..f667f092 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/AllowsNull.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/AllowsNull.kt @@ -12,4 +12,4 @@ class AllowsNull(val type: T) : BaleenType { null -> emptySequence() else -> type.validate(dataTrace, value) } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/BooleanType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/BooleanType.kt index ad2c4a1d..5d719742 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/BooleanType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/BooleanType.kt @@ -14,4 +14,4 @@ class BooleanType : BaleenType { !is Boolean -> sequenceOf(ValidationError(dataTrace, "is not a boolean", value)) else -> emptySequence() } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/CoercibleType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/CoercibleType.kt index 1e865c95..f0e3f046 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/CoercibleType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/CoercibleType.kt @@ -2,4 +2,4 @@ package com.shoprunner.baleen.types import com.shoprunner.baleen.BaleenType -abstract class CoercibleType(val type: BaleenType) : BaleenType \ No newline at end of file +abstract class CoercibleType(val type: BaleenType) : BaleenType diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/DoubleType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/DoubleType.kt index 8faf0b78..1998c911 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/DoubleType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/DoubleType.kt @@ -16,4 +16,4 @@ class DoubleType(val min: Double = Double.NEGATIVE_INFINITY, val max: Double = D value > max -> sequenceOf(ValidationError(dataTrace, "is greater than $max", value)) else -> emptySequence() } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/EnumType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/EnumType.kt index 1180f871..98223dfb 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/EnumType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/EnumType.kt @@ -28,4 +28,4 @@ class EnumType(val enumName: String, val enum: List) : BaleenType { value)) else -> emptySequence() } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/ErrorsAreWarnings.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/ErrorsAreWarnings.kt index 81fd9d35..063aeadd 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/ErrorsAreWarnings.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/ErrorsAreWarnings.kt @@ -15,4 +15,4 @@ class ErrorsAreWarnings(val type: T) : BaleenType { else -> it } } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/FloatType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/FloatType.kt index 95932af3..3333fa9a 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/FloatType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/FloatType.kt @@ -16,4 +16,4 @@ class FloatType(val min: Float = Float.NEGATIVE_INFINITY, val max: Float = Float value > max -> sequenceOf(ValidationError(dataTrace, "is greater than $max", value)) else -> emptySequence() } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/InstantType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/InstantType.kt index ee36319c..6577a1fb 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/InstantType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/InstantType.kt @@ -17,4 +17,4 @@ class InstantType(val before: Instant = Instant.MAX, val after: Instant = Instan !value.isAfter(after) -> sequenceOf(ValidationError(dataTrace, "is after $after", value)) else -> emptySequence() } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/IntType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/IntType.kt index ba66e47f..b0a79da0 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/IntType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/IntType.kt @@ -16,4 +16,4 @@ class IntType(val min: Int = Int.MIN_VALUE, val max: Int = Int.MAX_VALUE) : Bale value > max -> sequenceOf(ValidationError(dataTrace, "is greater than $max", value)) else -> sequenceOf() } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongCoercibleToInstant.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongCoercibleToInstant.kt index 43ed42be..887e6595 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongCoercibleToInstant.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongCoercibleToInstant.kt @@ -13,4 +13,4 @@ class LongCoercibleToInstant(instantType: InstantType, precision: Precision = Pr millis // TODO: Add nanos, since Avro supports nano resolution } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongCoercibleToType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongCoercibleToType.kt index 95da0a97..77521c9b 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongCoercibleToType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongCoercibleToType.kt @@ -21,4 +21,4 @@ open class LongCoercibleToType(type: T, private val converte } } } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongType.kt index 8c0f8b73..9ebe64d4 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/LongType.kt @@ -16,4 +16,4 @@ class LongType(val min: Long = Long.MIN_VALUE, val max: Long = Long.MAX_VALUE) : value > max -> sequenceOf(ValidationError(dataTrace, "is greater than $max", value)) else -> sequenceOf() } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/MapType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/MapType.kt index d5cbaea7..0b3aa3df 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/MapType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/MapType.kt @@ -19,4 +19,4 @@ class MapType(val keyType: BaleenType, val valueType: BaleenType) : BaleenType { } else -> emptySequence() } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/OccurrencesType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/OccurrencesType.kt index 6402d8e2..7c0bd669 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/OccurrencesType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/OccurrencesType.kt @@ -19,4 +19,4 @@ class OccurrencesType(val memberType: BaleenType) : BaleenType { memberType.validate(dataTrace.plus("index 0"), value) } } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToBoolean.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToBoolean.kt index 9a05bb06..fd7d891a 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToBoolean.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToBoolean.kt @@ -1,4 +1,4 @@ package com.shoprunner.baleen.types class StringCoercibleToBoolean(booleanType: BooleanType = BooleanType()) : - StringCoercibleToType(booleanType, { it.toBoolean() }) \ No newline at end of file + StringCoercibleToType(booleanType, { it.toBoolean() }) diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToFloat.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToFloat.kt index e0afef33..ac65a4a3 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToFloat.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToFloat.kt @@ -1,4 +1,4 @@ package com.shoprunner.baleen.types class StringCoercibleToFloat(floatType: FloatType) : - StringCoercibleToType(floatType, { it.toFloatOrNull() }) \ No newline at end of file + StringCoercibleToType(floatType, { it.toFloatOrNull() }) diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToInstant.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToInstant.kt index 7b687656..d58cd3c4 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToInstant.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToInstant.kt @@ -14,4 +14,4 @@ class StringCoercibleToInstant( } catch (ex: DateTimeParseException) { null } - }) \ No newline at end of file + }) diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToLong.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToLong.kt index 2b34685e..4e12f7bf 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToLong.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToLong.kt @@ -1,4 +1,4 @@ package com.shoprunner.baleen.types class StringCoercibleToLong(longType: LongType) : - StringCoercibleToType(longType, { it.toLongOrNull() }) \ No newline at end of file + StringCoercibleToType(longType, { it.toLongOrNull() }) diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToTimestamp.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToTimestamp.kt index 6ff76c84..31e40e19 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToTimestamp.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToTimestamp.kt @@ -14,4 +14,4 @@ class StringCoercibleToTimestamp( } catch (ex: DateTimeParseException) { null } - }) \ No newline at end of file + }) diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToType.kt index 3e6b07f6..09db777a 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringCoercibleToType.kt @@ -21,4 +21,4 @@ open class StringCoercibleToType(type: T, private val conver } } } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringConstantType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringConstantType.kt index 9f8bbba1..4e77d869 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringConstantType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringConstantType.kt @@ -13,4 +13,4 @@ class StringConstantType(val constant: String) : BaleenType { value -> emptySequence() else -> sequenceOf(ValidationError(dataTrace, "value is not '$constant'", value)) } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringType.kt index 08818c65..2295d9e5 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/StringType.kt @@ -16,4 +16,4 @@ class StringType(val min: Int = 0, val max: Int = Int.MAX_VALUE) : BaleenType { value.length > max -> sequenceOf(ValidationError(dataTrace, "is more than $max characters", value)) else -> emptySequence() } -} \ No newline at end of file +} diff --git a/baleen/src/main/kotlin/com/shoprunner/baleen/types/TimestampMillisType.kt b/baleen/src/main/kotlin/com/shoprunner/baleen/types/TimestampMillisType.kt index ef4ff481..2ac4179a 100644 --- a/baleen/src/main/kotlin/com/shoprunner/baleen/types/TimestampMillisType.kt +++ b/baleen/src/main/kotlin/com/shoprunner/baleen/types/TimestampMillisType.kt @@ -15,4 +15,4 @@ class TimestampMillisType : BaleenType { !is LocalDateTime -> sequenceOf(ValidationError(dataTrace, "is not a a localDateTime", value)) else -> emptySequence() } -} \ No newline at end of file +} diff --git a/baleen/src/test/kotlin/com/shoprunner/baleen/BaleenTest.kt b/baleen/src/test/kotlin/com/shoprunner/baleen/BaleenTest.kt index 625aa06a..35d807fa 100644 --- a/baleen/src/test/kotlin/com/shoprunner/baleen/BaleenTest.kt +++ b/baleen/src/test/kotlin/com/shoprunner/baleen/BaleenTest.kt @@ -215,4 +215,4 @@ internal class BaleenTest { assertThat(dataDesc.validate(dataOf("favorite number" to 42))).isValid() assertThat(dataDesc.validate(dataOf("favorite number" to 41))).isNotValid() } -} \ No newline at end of file +} diff --git a/baleen/src/test/kotlin/com/shoprunner/baleen/SequenceAssert.kt b/baleen/src/test/kotlin/com/shoprunner/baleen/SequenceAssert.kt index 5051949a..2abcaf7c 100644 --- a/baleen/src/test/kotlin/com/shoprunner/baleen/SequenceAssert.kt +++ b/baleen/src/test/kotlin/com/shoprunner/baleen/SequenceAssert.kt @@ -21,4 +21,4 @@ class SequenceAssert(actual: Sequence) : AbstractAssert, } return this } -} \ No newline at end of file +} diff --git a/baleen/src/test/kotlin/com/shoprunner/baleen/ValidationAssert.kt b/baleen/src/test/kotlin/com/shoprunner/baleen/ValidationAssert.kt index df9f1c74..44b4366f 100644 --- a/baleen/src/test/kotlin/com/shoprunner/baleen/ValidationAssert.kt +++ b/baleen/src/test/kotlin/com/shoprunner/baleen/ValidationAssert.kt @@ -21,4 +21,4 @@ class ValidationAssert(actual: Validation) : AbstractAssert -) : JsonSchema() \ No newline at end of file +) : JsonSchema() diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/AnyOf.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/AnyOf.kt index 97c996bd..b7450013 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/AnyOf.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/AnyOf.kt @@ -5,4 +5,4 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize data class AnyOf( @JsonDeserialize(contentUsing = JsonSchemaDeserializer::class) val anyOf: List -) : JsonSchema() \ No newline at end of file +) : JsonSchema() diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ArraySchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ArraySchema.kt index 7587cb5c..e0170757 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ArraySchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ArraySchema.kt @@ -7,4 +7,4 @@ data class ArraySchema( val items: JsonSchema ) : JsonSchema() { var type = JsonType.array -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/BooleanSchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/BooleanSchema.kt index ad2e2ad1..6dfa34e7 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/BooleanSchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/BooleanSchema.kt @@ -2,4 +2,4 @@ package com.shoprunner.baleen.jsonschema.v4 object BooleanSchema : JsonSchema() { var type = JsonType.boolean -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/DateTimeSchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/DateTimeSchema.kt index 4e7eb75d..1f9bac00 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/DateTimeSchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/DateTimeSchema.kt @@ -1,3 +1,3 @@ package com.shoprunner.baleen.jsonschema.v4 -fun DateTimeSchema() = StringSchema(format = StringFormats.`date-time`) \ No newline at end of file +fun DateTimeSchema() = StringSchema(format = StringFormats.`date-time`) diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/IntegerSchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/IntegerSchema.kt index fb3b0b41..2e68e2e9 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/IntegerSchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/IntegerSchema.kt @@ -5,4 +5,4 @@ data class IntegerSchema( val minimum: Long? = null ) : JsonSchema() { val type = JsonType.integer -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchema.kt index d90e085d..a4983489 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchema.kt @@ -1,3 +1,3 @@ package com.shoprunner.baleen.jsonschema.v4 -abstract class JsonSchema(var description: String? = null, var default: Any? = null) \ No newline at end of file +abstract class JsonSchema(var description: String? = null, var default: Any? = null) diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaDeserializer.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaDeserializer.kt index 71de81aa..7f6e42f4 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaDeserializer.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonSchemaDeserializer.kt @@ -51,4 +51,4 @@ class JsonSchemaDeserializer : StdDeserializer(JsonSchema::class.jav } } } -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonType.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonType.kt index a41d490f..7a6a5017 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonType.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/JsonType.kt @@ -2,4 +2,4 @@ package com.shoprunner.baleen.jsonschema.v4 enum class JsonType() { array, `object`, integer, number, string, boolean, `null` -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/MapSchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/MapSchema.kt index 60bcb5d9..fbcd0784 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/MapSchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/MapSchema.kt @@ -7,4 +7,4 @@ data class MapSchema( val additionalProperties: JsonSchema ) : JsonSchema() { val type = JsonType.`object` -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/Not.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/Not.kt index 578de4c6..93b63782 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/Not.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/Not.kt @@ -5,4 +5,4 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize data class Not( @JsonDeserialize(using = JsonSchemaDeserializer::class) val not: JsonSchema -) : JsonSchema() \ No newline at end of file +) : JsonSchema() diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/Null.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/Null.kt index 8f57c9a0..29b71dca 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/Null.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/Null.kt @@ -7,4 +7,4 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize * absence of value. When representing null, use this object. */ @JsonSerialize(using = NullJsonSerializer::class) -object Null \ No newline at end of file +object Null diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NullJsonSerializer.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NullJsonSerializer.kt index 970f9359..a7559a6f 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NullJsonSerializer.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NullJsonSerializer.kt @@ -11,4 +11,4 @@ class NullJsonSerializer : JsonSerializer() { override fun serialize(value: Null?, gen: JsonGenerator?, serializers: SerializerProvider?) { gen?.writeNull() } -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NullSchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NullSchema.kt index c3c509ba..be080f89 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NullSchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NullSchema.kt @@ -2,4 +2,4 @@ package com.shoprunner.baleen.jsonschema.v4 class NullSchema : JsonSchema() { val type = JsonType.`null` -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NumberSchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NumberSchema.kt index aa125014..37fad606 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NumberSchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/NumberSchema.kt @@ -5,4 +5,4 @@ data class NumberSchema( val minimum: Double? = null ) : JsonSchema() { val type = JsonType.number -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ObjectReference.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ObjectReference.kt index d7065245..2383ac70 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ObjectReference.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ObjectReference.kt @@ -1,3 +1,3 @@ package com.shoprunner.baleen.jsonschema.v4 -data class ObjectReference(val `$ref`: String) : JsonSchema() \ No newline at end of file +data class ObjectReference(val `$ref`: String) : JsonSchema() diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ObjectSchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ObjectSchema.kt index cf54c67c..35b1b66e 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ObjectSchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/ObjectSchema.kt @@ -10,4 +10,4 @@ data class ObjectSchema( ) : JsonSchema() { val type = JsonType.`object` -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/OneOf.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/OneOf.kt index cd18bef2..85f6cbe2 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/OneOf.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/OneOf.kt @@ -5,4 +5,4 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize data class OneOf( @JsonDeserialize(contentUsing = JsonSchemaDeserializer::class) val oneOf: List -) : JsonSchema() \ No newline at end of file +) : JsonSchema() diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/RootJsonSchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/RootJsonSchema.kt index 4b5b5e7b..a63edb23 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/RootJsonSchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/RootJsonSchema.kt @@ -15,4 +15,4 @@ class RootJsonSchema( @JsonDeserialize(contentUsing = JsonSchemaDeserializer::class) val properties: Map? = null, val type: JsonType? = null -) : JsonSchema() \ No newline at end of file +) : JsonSchema() diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/SelfDescribing.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/SelfDescribing.kt index b3a2723d..0adba0a1 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/SelfDescribing.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/SelfDescribing.kt @@ -5,4 +5,4 @@ data class SelfDescribing( val name: String, val version: String, val format: String = "jsonschema" -) \ No newline at end of file +) diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/StringFormats.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/StringFormats.kt index ae81c471..10e3894c 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/StringFormats.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/StringFormats.kt @@ -2,4 +2,4 @@ package com.shoprunner.baleen.jsonschema.v4 enum class StringFormats { `date-time`, date, time, `utc-millisec`, regex, color, style, phone, uri, email, `ip-address`, ipv6, `host-name` -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/StringSchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/StringSchema.kt index 428b97c7..0293f655 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/StringSchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/StringSchema.kt @@ -7,4 +7,4 @@ data class StringSchema( val format: StringFormats? = null ) : JsonSchema() { val type = JsonType.string -} \ No newline at end of file +} diff --git a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/UnionSchema.kt b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/UnionSchema.kt index 9ebac1b0..62007359 100644 --- a/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/UnionSchema.kt +++ b/jsonschema-model/src/main/kotlin/com/shoprunner/baleen/jsonschema/v4/UnionSchema.kt @@ -5,4 +5,4 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize data class UnionSchema( @JsonDeserialize(contentUsing = JsonSchemaDeserializer::class) val type: List -) : JsonSchema() \ No newline at end of file +) : JsonSchema() From 4e241aced18e6b18ea1e90bb4cc0329bd1a1e991 Mon Sep 17 00:00:00 2001 From: Ken Dallmeyer Date: Mon, 17 Jun 2019 17:31:03 -0500 Subject: [PATCH 11/18] Create USE-CASES.md What use cases does Baleen solve? What use cases are _not_ the right fit? --- USE-CASES.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 USE-CASES.md diff --git a/USE-CASES.md b/USE-CASES.md new file mode 100644 index 00000000..498c51fc --- /dev/null +++ b/USE-CASES.md @@ -0,0 +1,24 @@ +# Baleen Use Cases + +## What does Baleen _Not_ do? + +* Does not do binary serialization of its own + +## What does Baleen not do _Yet_? (PRs Welcome!) + +* Does not work outside of JVM (aka multiplatform: JavaScript, etc). +* Is not a stand-alone app. + +## What does Baleen _Do_? + +### 1. Validating existing data + +Given a data source written in XML or CSV or transformed into a Map, write tests against the data and validate it. + +### 2. Defining and validating new data + +#### Generating schema definitions in different languages + +### 3. Create model classes off of data shapes + +#### Generating model classes in different languages From 8d83b463f095ecd8397490ac47e9ee6369bb662c Mon Sep 17 00:00:00 2001 From: "Michael R. Maletich" Date: Tue, 18 Jun 2019 12:12:34 -0500 Subject: [PATCH 12/18] Moved to a potentially more permantent location. --- USE-CASES.md | 24 ------------------- doc/useCases.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 24 deletions(-) delete mode 100644 USE-CASES.md create mode 100644 doc/useCases.md diff --git a/USE-CASES.md b/USE-CASES.md deleted file mode 100644 index 498c51fc..00000000 --- a/USE-CASES.md +++ /dev/null @@ -1,24 +0,0 @@ -# Baleen Use Cases - -## What does Baleen _Not_ do? - -* Does not do binary serialization of its own - -## What does Baleen not do _Yet_? (PRs Welcome!) - -* Does not work outside of JVM (aka multiplatform: JavaScript, etc). -* Is not a stand-alone app. - -## What does Baleen _Do_? - -### 1. Validating existing data - -Given a data source written in XML or CSV or transformed into a Map, write tests against the data and validate it. - -### 2. Defining and validating new data - -#### Generating schema definitions in different languages - -### 3. Create model classes off of data shapes - -#### Generating model classes in different languages diff --git a/doc/useCases.md b/doc/useCases.md new file mode 100644 index 00000000..832f00a1 --- /dev/null +++ b/doc/useCases.md @@ -0,0 +1,62 @@ +# Vision + +I'm given an XML/CSV/JSON... source that I don't control but if I can detect and provide feedback quickly when +the data format changes for the worse, I can prevent the data format changes from becoming permanent. + +Baleen should provide + + - Tell good data from bad data. + - Fine grain control to ignore existing bad data that has been grandfathered in. + - Allow for ratcheting data from bad formats to good formats. + - Be unobtrusive to existing code. + - Tests are great + There are a lot of great libraries for testing code. We should use those same concepts for testing + data. + - Performance and streaming are important + A data validation library should be able to handle large amounts of data quickly. + - Invalid data is also important + Warnings and Errors need to be treated as first class objects. + - Data Traces + Similar to a stack trace being used to debug a code path, a data trace can be used to debug a + path through data. + - Don't map data to Types too early. + Type safe code is great but if the data has not been sanitized then it isn't really typed. + - Don't Repeat Yourself + - If you have described the schema in baleen, you should be able to reuse that schema in other tools for + - Published schemas JSON Schema, Avro, XSL... + + - If you have described the schema in another format, you can reuse it but also extend the validation with baleen + - Kotlin data class, Avro, JSON Schema, XSL... + - Don't be a serialization/deserialization library + Baleen will need to do some deserialization in order to validate but developers should be free to pick a deserialization library independently. + TODO: how do we verify that these other serialization libraries work after Baleen is validated + + +## Use Cases + +### 1. Validating existing data format + + 1. Create baleen schema or auto-generate from sample data + 1. Run validate before ingesting data + 1. Send validation errors to some alarm + 1. Generate ignore list + 1. Early return if validation fails before rest of the pipeline. + +### 2. Defining and validating new data format + + 1. Generate a Kotlin data class + 1. Extend the data class with baleen tests + 1. Use the Kotlin data class with the serialization/deserialization library of your choice + + +## Other Ideas that are not Flushed Out + - Web interface / UI + - storage format for errors + - storage format for errors to ignore + - Should we have one schema for different formats + - codegen, compile time, runtime + - Platform Agnostic (Kotlin JVM, Kotlin Javascript, Kotlin Native) + - Language Agnostic? (Python, Typescript) + - Create model classes off of data shapes + - Generating model classes in different languages + \ No newline at end of file From f99eec1630063217ce9f4e396fb2171b2d5225a2 Mon Sep 17 00:00:00 2001 From: Ken Dallmeyer Date: Wed, 26 Jun 2019 08:23:02 -0500 Subject: [PATCH 13/18] Added the usecases to write tests for --- baleen-v2-tests/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 baleen-v2-tests/README.md diff --git a/baleen-v2-tests/README.md b/baleen-v2-tests/README.md new file mode 100644 index 00000000..0d082e3b --- /dev/null +++ b/baleen-v2-tests/README.md @@ -0,0 +1,19 @@ +# Preparation for version 2 + +Do test driven development for version 2 + +## Use Case 1 - Given we have the data, we define the schema manually and validate the data + +[UseCase1Test.kt](./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](./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](./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 + +[UseCase4Test.kt](./src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt) \ No newline at end of file From fedd37d842e8f5a9b1ec0edfc3b776a8c38480e9 Mon Sep 17 00:00:00 2001 From: Ken Dallmeyer Date: Wed, 26 Jun 2019 08:26:03 -0500 Subject: [PATCH 14/18] Add test for Use case 1 "Given we have the data, we define the Baleen schema manually and validate the data" --- baleen-v2-tests/build.gradle | 14 + .../baleen/version2/BaleenImprovements.kt | 88 +++++++ .../baleen/version2/UseCase1Test.kt | 247 ++++++++++++++++++ settings.gradle | 1 + 4 files changed, 350 insertions(+) create mode 100644 baleen-v2-tests/build.gradle create mode 100644 baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt create mode 100644 baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase1Test.kt diff --git a/baleen-v2-tests/build.gradle b/baleen-v2-tests/build.gradle new file mode 100644 index 00000000..3ba3a5a9 --- /dev/null +++ b/baleen-v2-tests/build.gradle @@ -0,0 +1,14 @@ +dependencies { + api project(':baleen') + api project(':baleen-csv') + api project(':baleen-xml') + api "org.apache.avro:avro:1.9.0" + implementation 'org.jetbrains.kotlin:kotlin-reflect' + + // Just to get some test helpers. Promote those test helpers to top-level module. + testImplementation files(project(":baleen").sourceSets.test.output) +} + +test { + ignoreFailures = true +} diff --git a/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt b/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt new file mode 100644 index 00000000..6506380a --- /dev/null +++ b/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt @@ -0,0 +1,88 @@ +package com.shoprunner.baleen.version2 + +import com.shoprunner.baleen.Context +import com.shoprunner.baleen.Data +import com.shoprunner.baleen.DataDescription +import com.shoprunner.baleen.DataTrace +import com.shoprunner.baleen.Validation +import com.shoprunner.baleen.csv.FlowableUtil +import com.shoprunner.baleen.dataTrace +import com.shoprunner.baleen.datawrappers.HashData +import com.shoprunner.baleen.xml.XmlUtil +import org.apache.avro.Schema +import org.apache.avro.generic.GenericRecord +import java.io.InputStream +import kotlin.reflect.KClass + +// API Improvements, that we may want to add to the Baleen API + +fun Map.validate(schema: DataDescription, dataTrace: DataTrace = dataTrace()): Validation { + return schema.validate(Context(HashData(this), dataTrace)) +} + +fun Iterable>.validate(schema: DataDescription, dataTrace: DataTrace = dataTrace()): Validation { + val results = this.asSequence().mapIndexed { index, map -> + map.validate(schema, dataTrace + "index $index").results.asSequence() + }.flatten() + + return Validation(Context(HashData(emptyMap()), dataTrace), results.asIterable()) +} + +typealias DataHandler = (InputStream, DataTrace) -> Iterable + +class CsvDataHandler( + private val delimiter: Char = ',', + private val quote: Char = '"', + private val escape: Char = '\\' +) : DataHandler { + override fun invoke(inputStream: InputStream, dataTrace: DataTrace): Iterable { + return FlowableUtil.fromCsvWithHeader(dataTrace, { inputStream.bufferedReader() }, delimiter, quote, escape).blockingIterable() + } +} + +val XmlDataHandler: DataHandler = { inputStream: InputStream, dataTrace: DataTrace -> + sequenceOf(XmlUtil.fromXmlToContext(dataTrace, inputStream)).asIterable() +} + +val JsonDataHandler: DataHandler = { inputStream: InputStream, dataTrace: DataTrace -> + throw NotImplementedError() +} + +val JsonPerLineDataHandler: DataHandler = { inputStream: InputStream, dataTrace: DataTrace -> + throw NotImplementedError() +} + +val JsonArrayDataHandler: DataHandler = { inputStream: InputStream, dataTrace: DataTrace -> + throw NotImplementedError() +} + +val AvroDataHandler: DataHandler = { inputStream: InputStream, dataTrace: DataTrace -> + throw NotImplementedError() +} + +fun InputStream.validate(schema: DataDescription, dataHandler: DataHandler, dataTrace: DataTrace = dataTrace()): Validation { + val results = dataHandler(this, dataTrace).asSequence().flatMap { ctx -> + schema.validate(ctx).results.asSequence() + } + + return Validation(Context(HashData(emptyMap()), dataTrace), results.asIterable()) +} + +class AvroData(val record: GenericRecord) : Data { + override fun containsKey(key: String): Boolean { + return record.schema.getField(key) != null + } + + // returns null if value does not exist + override operator fun get(key: String): Any? = record.get(key) + + override val keys: Set = record.schema.fields.map { it.name() }.toSet() +} + +fun GenericRecord.validate(schema: DataDescription, dataTrace: DataTrace = dataTrace()): Validation { + return schema.validate(Context(AvroData(this), dataTrace)) +} + +fun T.validate(schema: DataDescription, dataTrace: DataTrace = dataTrace()): Validation { + throw NotImplementedError() +} \ No newline at end of file diff --git a/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase1Test.kt b/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase1Test.kt new file mode 100644 index 00000000..47d1bd70 --- /dev/null +++ b/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase1Test.kt @@ -0,0 +1,247 @@ +package com.shoprunner.baleen.version2 + +import com.shoprunner.baleen.Baleen.describeAs +import com.shoprunner.baleen.ValidationAssert.Companion.assertThat +import com.shoprunner.baleen.types.AllowsNull +import com.shoprunner.baleen.types.IntType +import com.shoprunner.baleen.types.OccurrencesType +import com.shoprunner.baleen.types.StringType +import org.apache.avro.Schema +import org.apache.avro.generic.GenericDatumWriter +import org.apache.avro.generic.GenericRecord +import org.apache.avro.generic.GenericRecordBuilder +import org.apache.avro.io.EncoderFactory +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream + +/** + * Given we have the data, we define the schema manually and validate the data + */ +class UseCase1Test { + + data class Dog(var name: String, var numLegs: Int?) + + @Nested + inner class `Start with the data and and manually define the schema` { + + @Nested + inner class `then with existing map data` { + + val data = listOf( + mapOf("name" to "Fido", "numLegs" to 4), + mapOf("name" to "Dug", "numLegs" to 4) + ) + + val schema = "Dog".describeAs { + attr("name", StringType()) + attr("numLegs", AllowsNull(IntType())) + } + + @Test + fun `the data can be validated`() { + assertThat(data.validate(schema)).isValid() + } + } + + @Nested + inner class `then with existing csv data` { + + val data = """ + "Fido",4 + "Dug",4 + """.trimIndent() + + val schema = "Dog".describeAs { + attr("name", StringType()) + attr("numLegs", AllowsNull(IntType())) + } + + @Test + fun `the data can be validated`() { + assertThat(data.byteInputStream().validate(schema, CsvDataHandler())).isValid() + } + } + + @Nested + inner class `then with existing xml data` { + + val data = """ + + + Fido + 4 + + + Dug + 4 + + + """.trimIndent() + + val schema = "dog".describeAs { + attr("name", StringType()) + attr("numLegs", AllowsNull(IntType())) + } + + val root = "pack".describeAs { + attr("dog", OccurrencesType(schema)) + } + + @Test + fun `the data can be validated`() { + assertThat(data.byteInputStream().validate(root, XmlDataHandler)).isValid() + } + } + + @Nested + inner class `then with existing json data` { + + @Nested + inner class `as a single json object` { + val data = """ + { + "name": "Fido", + "numLegs": 4 + } + """.trimIndent() + + val schema = "Dog".describeAs { + attr("name", StringType()) + attr("numLegs", AllowsNull(IntType())) + } + + @Test + fun `the data can be validated`() { + assertThat(data.byteInputStream().validate(schema, JsonDataHandler)).isValid() + } + } + + @Nested + inner class `as one json object per line` { + val data = """ + { "name": "Fido", "numLegs": 4 } + { "name": "Dug", "numLegs": 4 } + """.trimIndent() + + val schema = "Dog".describeAs { + attr("name", StringType()) + attr("numLegs", AllowsNull(IntType())) + } + + @Test + fun `the data can be validated`() { + assertThat(data.byteInputStream().validate(schema, JsonPerLineDataHandler)).isValid() + } + } + + @Nested + inner class `as a json array` { + val data = """ + [ + { "name": "Fido", "numLegs": 4 }, + { "name": "Dug", "numLegs": 4 } + ] + """.trimIndent() + + val schema = "Dog".describeAs { + attr("name", StringType()) + attr("numLegs", AllowsNull(IntType())) + } + + @Test + fun `the data can be validated`() { + assertThat(data.byteInputStream().validate(schema, JsonArrayDataHandler)).isValid() + } + } + } + + @Nested + inner class `then with existing avro data` { + val parser = Schema.Parser() + val avroSchemaStr = """ + { + "type": "record", + "name": "Dog", + "fields": [ + { "name": "name", "type": "string" }, + { "name": "numLegs", "type": ["null", "int"], "default": null } + ] + } + """.trimIndent() + val avroSchema = parser.parse(avroSchemaStr) + + @Nested + inner class `from a GenericRecord` { + + val data = GenericRecordBuilder(avroSchema) + .set("name", "Fido") + .set("numLegs", 4) + .build() + + val schema = "Dog".describeAs { + attr("name", StringType()) + attr("numLegs", AllowsNull(IntType())) + } + + @Test + fun `the data can be validated`() { + assertThat(data.validate(schema)).isValid() + } + } + + @Nested + inner class `from an Avro InputStream` { + val data = with(ByteArrayOutputStream()) { + val record = GenericRecordBuilder(avroSchema) + .set("name", "Fido") + .set("numLegs", 4) + .build() + + val writer = GenericDatumWriter(avroSchema) + val encoder = EncoderFactory().directBinaryEncoder(this, null) + writer.write(record, encoder) + encoder.flush() + ByteArrayInputStream(this.toByteArray()) + } + + val schema = "Dog".describeAs { + attr("name", StringType()) + attr("numLegs", AllowsNull(IntType())) + } + + @Test + fun `the data can be validated`() { + assertThat(data.validate(schema, AvroDataHandler)).isValid() + } + } + } + + @Nested + inner class `then with existing kotlin data object` { + + val data = Dog("Fido", 4) + + val dataList = listOf( + data, + Dog("Dug", 4) + ) + + val schema = "Dog".describeAs { + attr("name", StringType()) + attr("numLegs", AllowsNull(IntType())) + } + + @Test + fun `the data can be validated`() { + assertThat(data.validate(schema)).isValid() + } + + @Test + fun `the data list can be validated`() { + assertThat(dataList.validate(schema)).isValid() + } + } + } +} diff --git a/settings.gradle b/settings.gradle index de01a8e6..075c00e5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,5 +6,6 @@ include 'baleen-jsonschema-generator' include 'jsonschema-baleen-generator' include 'baleen-xml' include 'baleen-xsd-generator' +include 'baleen-v2-tests' rootProject.name = 'baleen' From f256e98e1d328807c00e12453fee17c712aa522a Mon Sep 17 00:00:00 2001 From: Ken Dallmeyer Date: Wed, 26 Jun 2019 08:27:14 -0500 Subject: [PATCH 15/18] Add tests for Use case 2 "Given we have the data, we learn the Baleen schema and validate the data" --- .../baleen/version2/BaleenImprovements.kt | 24 +++ .../baleen/version2/UseCase2Test.kt | 204 ++++++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase2Test.kt diff --git a/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt b/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt index 6506380a..6cbcb227 100644 --- a/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt +++ b/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt @@ -16,6 +16,30 @@ import kotlin.reflect.KClass // API Improvements, that we may want to add to the Baleen API +fun KClass.learnSchema(): DataDescription { + throw NotImplementedError() +} + +fun T.learnSchema(): DataDescription { + return this::class.learnSchema() +} + +fun Iterable>.learnSchema(): DataDescription { + throw NotImplementedError() +} + +fun InputStream.learnSchema(dataHandler: DataHandler): DataDescription { + throw NotImplementedError() +} + +fun Schema.learnSchema(): DataDescription { + throw NotImplementedError() +} + +fun GenericRecord.learnSchema(): DataDescription { + return this.schema.learnSchema() +} + fun Map.validate(schema: DataDescription, dataTrace: DataTrace = dataTrace()): Validation { return schema.validate(Context(HashData(this), dataTrace)) } diff --git a/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase2Test.kt b/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase2Test.kt new file mode 100644 index 00000000..1b79025b --- /dev/null +++ b/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase2Test.kt @@ -0,0 +1,204 @@ +package com.shoprunner.baleen.version2 + +import com.shoprunner.baleen.ValidationAssert.Companion.assertThat +import org.apache.avro.Schema +import org.apache.avro.generic.GenericDatumWriter +import org.apache.avro.generic.GenericRecord +import org.apache.avro.generic.GenericRecordBuilder +import org.apache.avro.io.EncoderFactory +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream + +/** + * Given we have the data, we learn the schema and validate the data + */ +class UseCase2Test { + + data class Dog(var name: String, var numLegs: Int?) + + @Nested + inner class `Start with the data and learn the schema` { + + @Nested + inner class `then with existing map data` { + + val data = listOf( + mapOf("name" to "Fido", "numLegs" to 4), + mapOf("name" to "Dug", "numLegs" to 4) + ) + + @Test + fun `the data can be validated`() { + val schema = data.learnSchema() + assertThat(data.validate(schema)).isValid() + } + } + + @Nested + inner class `then with existing csv data` { + + val data = """ + "Fido",4 + "Dug",4 + """.trimIndent() + + @Test + fun `the data can be validated`() { + val dataHandler = CsvDataHandler() + val schema = data.byteInputStream().learnSchema(dataHandler) + assertThat(data.byteInputStream().validate(schema, dataHandler)).isValid() + } + } + + @Nested + inner class `then with existing xml data` { + + val data = """ + + + Fido + 4 + + + Dug + 4 + + + """.trimIndent() + + @Test + fun `the data can be validated`() { + val schema = data.byteInputStream().learnSchema(XmlDataHandler) + assertThat(data.byteInputStream().validate(schema, XmlDataHandler)).isValid() + } + } + + @Nested + inner class `then with existing json data` { + + @Nested + inner class `as a single json object` { + val data = """ + { + "name": "Fido", + "numLegs": 4 + } + """.trimIndent() + + @Test + fun `the data can be validated`() { + val schema = data.byteInputStream().learnSchema(JsonDataHandler) + assertThat(data.byteInputStream().validate(schema, JsonDataHandler)).isValid() + } + } + + @Nested + inner class `as one json object per line` { + val data = """ + { "name": "Fido", "numLegs": 4 } + { "name": "Dug", "numLegs": 4 } + """.trimIndent() + + @Test + fun `the data can be validated`() { + val schema = data.byteInputStream().learnSchema(JsonPerLineDataHandler) + assertThat(data.byteInputStream().validate(schema, JsonPerLineDataHandler)).isValid() + } + } + + @Nested + inner class `as a json array` { + val data = """ + [ + { "name": "Fido", "numLegs": 4 }, + { "name": "Dug", "numLegs": 4 } + ] + """.trimIndent() + + @Test + fun `the data can be validated`() { + val schema = data.byteInputStream().learnSchema(JsonArrayDataHandler) + assertThat(data.byteInputStream().validate(schema, JsonArrayDataHandler)).isValid() + } + } + } + + @Nested + inner class `then with existing avro data` { + val parser = Schema.Parser() + val avroSchemaStr = """ + { + "type": "record", + "name": "Dog", + "fields": [ + { "name": "name", "type": "string" }, + { "name": "numLegs", "type": ["null", "int"], "default": null } + ] + } + """.trimIndent() + val avroSchema = parser.parse(avroSchemaStr) + + @Nested + inner class `from a GenericRecord` { + + val data = GenericRecordBuilder(avroSchema) + .set("name", "Fido") + .set("numLegs", 4) + .build() + + @Test + fun `the data can be validated`() { + val schema = data.learnSchema() + assertThat(data.validate(schema)).isValid() + } + } + + @Nested + inner class `from an Avro InputStream` { + val data = with(ByteArrayOutputStream()) { + val record = GenericRecordBuilder(avroSchema) + .set("name", "Fido") + .set("numLegs", 4) + .build() + + val writer = GenericDatumWriter(avroSchema) + val encoder = EncoderFactory().directBinaryEncoder(this, null) + writer.write(record, encoder) + encoder.flush() + ByteArrayInputStream(this.toByteArray()) + } + + @Test + fun `the data can be validated`() { + val schema = data.learnSchema(AvroDataHandler) + assertThat(data.validate(schema, AvroDataHandler)).isValid() + } + } + } + + @Nested + inner class `then with existing kotlin data object` { + + val data = Dog("Fido", 4) + + val dataList = listOf( + data, + Dog("Dug", 4) + ) + + @Test + fun `the data can be validated`() { + val schema = data.learnSchema() + assertThat(data.validate(schema)).isValid() + } + + @Test + fun `the data list can be validated`() { + val schema = dataList.learnSchema() + assertThat(dataList.validate(schema)).isValid() + } + } + } +} From 913a79c103c26044bb4383eb1c43998ec0d428b6 Mon Sep 17 00:00:00 2001 From: Ken Dallmeyer Date: Wed, 26 Jun 2019 09:25:50 -0500 Subject: [PATCH 16/18] Add tests for Use case 3 "Given a external schema (Avro, XSD, Json-Schema, Kotlin data class), build Baleen schema and validate the data" --- baleen-v2-tests/build.gradle | 3 + .../baleen/version2/BaleenImprovements.kt | 29 +++- .../baleen/version2/UseCase3Test.kt | 141 ++++++++++++++++++ 3 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase3Test.kt diff --git a/baleen-v2-tests/build.gradle b/baleen-v2-tests/build.gradle index 3ba3a5a9..360ae71e 100644 --- a/baleen-v2-tests/build.gradle +++ b/baleen-v2-tests/build.gradle @@ -2,6 +2,9 @@ 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-avro-generator') api "org.apache.avro:avro:1.9.0" implementation 'org.jetbrains.kotlin:kotlin-reflect' diff --git a/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt b/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt index 6cbcb227..7476a2a3 100644 --- a/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt +++ b/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt @@ -8,11 +8,15 @@ import com.shoprunner.baleen.Validation import com.shoprunner.baleen.csv.FlowableUtil import com.shoprunner.baleen.dataTrace import com.shoprunner.baleen.datawrappers.HashData +import com.shoprunner.baleen.jsonschema.v4.BaleenGenerator +import com.shoprunner.baleen.jsonschema.v4.JsonSchema import com.shoprunner.baleen.xml.XmlUtil -import org.apache.avro.Schema +import org.apache.avro.Schema as AvroSchema import org.apache.avro.generic.GenericRecord import java.io.InputStream import kotlin.reflect.KClass +import com.shoprunner.baleen.xsd.xml.Schema as XSD +import com.shoprunner.baleen.jsonschema.v4.BaleenGenerator.parseJsonSchema // API Improvements, that we may want to add to the Baleen API @@ -32,7 +36,15 @@ fun InputStream.learnSchema(dataHandler: DataHandler): DataDescription { throw NotImplementedError() } -fun Schema.learnSchema(): DataDescription { +fun AvroSchema.learnSchema(): DataDescription { + throw NotImplementedError() +} + +fun XSD.learnSchema(): DataDescription { + throw NotImplementedError() +} + +fun JsonSchema.learnSchema(): DataDescription { throw NotImplementedError() } @@ -109,4 +121,17 @@ fun GenericRecord.validate(schema: DataDescription, dataTrace: DataTrace = dataT fun T.validate(schema: DataDescription, dataTrace: DataTrace = dataTrace()): Validation { throw NotImplementedError() +} + +fun String.asXSD(): XSD { + throw NotImplementedError() +} + +fun String.asJsonSchema(): JsonSchema { + return this.parseJsonSchema() +} + +fun String.asAvroSchema(): AvroSchema { + val parser = AvroSchema.Parser() + return parser.parse(this) } \ No newline at end of file diff --git a/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase3Test.kt b/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase3Test.kt new file mode 100644 index 00000000..564f76f7 --- /dev/null +++ b/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase3Test.kt @@ -0,0 +1,141 @@ +package com.shoprunner.baleen.version2 + +import com.shoprunner.baleen.ValidationAssert.Companion.assertThat +import org.apache.avro.generic.GenericRecordBuilder +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test + +/** + * Given a external schema (Avro, XSD, Json-Schema, Kotlin data class), build Baleen schema and validate the data + */ +class UseCase3Test { + data class Dog(var name: String, var numLegs: Int?) + + @Nested + inner class `Given an external` { + + @Nested + inner class XSD { + val xsd = """ + + + + + Type of dog. + + + + + Name of the dog. + + + + + + The number of legs. + + + + + + + + Type of dog. + + + + """.trimIndent() + + val data = """ + + Fido + 4 + + """.trimIndent() + + @Test + fun `then generate Baleen schema and validate the data`() { + val schema = xsd.asXSD().learnSchema() + assertThat(data.byteInputStream().validate(schema, XmlDataHandler)).isValid() + } + } + + @Nested + inner class `json schema` { + val jsonSchema = """ + { + "id" : "com.shoprunner.data.dogs.Dog", + "definitions" : { + "record:com.shoprunner.data.dogs.Dog" : { + "description" : "It's a dog. Ruff Ruff!", + "type" : "object", + "required" : [ "name" ], + "additionalProperties" : false, + "properties" : { + "name" : { + "description" : "The name of the dog", + "type" : "string" + }, + "numLegs" : { + "description" : "The number of legs the dog has", + "type" : "integer" + } + } + } + }, + "${'$'}ref" : "#/definitions/record:com.shoprunner.data.dogs.Dog", + "${'$'}schema" : "http://json-schema.org/draft-04/schema" + } + """.trimIndent() + + val data = """ + { + "name": "Fido", + "numLegs": 4 + } + """.trimIndent() + + @Test + fun `then generate Baleen schema and validate the data`() { + val schema = jsonSchema.asJsonSchema().learnSchema() + assertThat(data.byteInputStream().validate(schema, JsonDataHandler)).isValid() + } + } + + @Nested + inner class `Avro schema` { + val avroSchema = """ + { + "type": "record", + "name": "Dog", + "fields": [ + { "name": "name", "type": "string" }, + { "name": "numLegs", "type": ["null", "int"], "default": null } + ] + } + """.trimIndent().asAvroSchema() + + val data = GenericRecordBuilder(avroSchema) + .set("name", "Fido") + .set("numLegs", 4) + .build() + + @Test + fun `then generate Baleen schema and validate the data`() { + val schema = avroSchema.learnSchema() + assertThat(data.validate(schema)).isValid() + } + } + + @Nested + inner class `Kotlin data class` { + val data = Dog("Fido", 4) + + @Test + fun `then generate Baleen schema and validate the data`() { + val schema = Dog::class.learnSchema() + assertThat(data.validate(schema)).isValid() + } + } + } +} \ No newline at end of file From 7c92888503ef925e7bd2b78e83007d2817761e62 Mon Sep 17 00:00:00 2001 From: Ken Dallmeyer Date: Wed, 26 Jun 2019 15:03:45 -0500 Subject: [PATCH 17/18] Add tests for 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" --- baleen-v2-tests/README.md | 2 +- baleen-v2-tests/build.gradle | 8 + .../baleen/version2/BaleenImprovements.kt | 35 +++- .../baleen/version2/UseCase4Test.kt | 158 ++++++++++++++++++ 4 files changed, 200 insertions(+), 3 deletions(-) create mode 100644 baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt diff --git a/baleen-v2-tests/README.md b/baleen-v2-tests/README.md index 0d082e3b..8d093724 100644 --- a/baleen-v2-tests/README.md +++ b/baleen-v2-tests/README.md @@ -14,6 +14,6 @@ Do test driven development for version 2 [UseCase3Test.kt](./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 +## 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](./src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt) \ No newline at end of file diff --git a/baleen-v2-tests/build.gradle b/baleen-v2-tests/build.gradle index 360ae71e..e38f0622 100644 --- a/baleen-v2-tests/build.gradle +++ b/baleen-v2-tests/build.gradle @@ -4,14 +4,22 @@ dependencies { 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 } diff --git a/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt b/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt index 7476a2a3..837b5932 100644 --- a/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt +++ b/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt @@ -5,10 +5,12 @@ import com.shoprunner.baleen.Data import com.shoprunner.baleen.DataDescription import com.shoprunner.baleen.DataTrace import com.shoprunner.baleen.Validation +import com.shoprunner.baleen.avro.AvroGenerator.encode as encodeAvroSchema import com.shoprunner.baleen.csv.FlowableUtil import com.shoprunner.baleen.dataTrace import com.shoprunner.baleen.datawrappers.HashData -import com.shoprunner.baleen.jsonschema.v4.BaleenGenerator +import com.shoprunner.baleen.jsonschema.v4.JsonSchemaGenerator.encode as encodeJsonSchema +import com.shoprunner.baleen.jsonschema.v4.JsonSchemaGenerator.writeTo as writeJsonSchemaTo import com.shoprunner.baleen.jsonschema.v4.JsonSchema import com.shoprunner.baleen.xml.XmlUtil import org.apache.avro.Schema as AvroSchema @@ -17,6 +19,10 @@ import java.io.InputStream import kotlin.reflect.KClass import com.shoprunner.baleen.xsd.xml.Schema as XSD import com.shoprunner.baleen.jsonschema.v4.BaleenGenerator.parseJsonSchema +import com.shoprunner.baleen.xsd.XsdGenerator.encode as encodeXsd +import java.io.ByteArrayOutputStream +import java.io.PrintStream +import kotlin.reflect.full.primaryConstructor // API Improvements, that we may want to add to the Baleen API @@ -134,4 +140,29 @@ fun String.asJsonSchema(): JsonSchema { fun String.asAvroSchema(): AvroSchema { val parser = AvroSchema.Parser() return parser.parse(this) -} \ No newline at end of file +} + +fun DataDescription.toXSD(): String { + val outputStream = ByteArrayOutputStream() + this.encodeXsd(PrintStream(outputStream)) + return outputStream.toString() +} + +fun DataDescription.toJsonSchema(): String { + val outputStream = ByteArrayOutputStream() + val schema = encodeJsonSchema(this) + schema.writeJsonSchemaTo(PrintStream(outputStream)) + return outputStream.toString() +} + +fun DataDescription.toAvroSchema(): AvroSchema { + return encodeAvroSchema(this) +} + +fun DataDescription.toDataClass(): KClass<*> { + throw NotImplementedError() +} + +fun DataDescription.toDataClassInstance(vararg attrs: Any?): Any { + return this.toDataClass().primaryConstructor!!.call(*attrs) +} diff --git a/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt b/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt new file mode 100644 index 00000000..fa418c21 --- /dev/null +++ b/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt @@ -0,0 +1,158 @@ +package com.shoprunner.baleen.version2 + +import com.shoprunner.baleen.Baleen.describeAs +import com.shoprunner.baleen.ValidationAssert.Companion.assertThat +import com.shoprunner.baleen.types.AllowsNull +import com.shoprunner.baleen.types.IntType +import com.shoprunner.baleen.types.StringType +import org.apache.avro.generic.GenericDatumReader +import org.apache.avro.generic.GenericDatumWriter +import org.apache.avro.generic.GenericRecord +import org.apache.avro.generic.GenericRecordBuilder +import org.apache.avro.io.DecoderFactory +import org.apache.avro.io.EncoderFactory +import org.assertj.core.api.Assertions.assertThat +import org.everit.json.schema.loader.SchemaLoader +import org.json.JSONObject +import org.json.JSONTokener +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import java.io.File +import javax.xml.XMLConstants +import javax.xml.transform.stream.StreamSource +import javax.xml.validation.SchemaFactory +import kotlin.reflect.full.memberProperties +import kotlin.reflect.full.primaryConstructor + +/** + * Given a Baleen schema, create external schema (Avro, XSD, Json-Schema, Kotlin data class) and + * validate the data with the external schema + */ +class UseCase4Test { + + @Nested + inner class `Given a Baleen schema` { + val schema = "dog".describeAs { + attr("name", StringType(), required = true) + attr("numLegs", AllowsNull(IntType())) + } + + @Test + fun `create an XSD and validate the data against it`() { + val data = """ + + Fido + 4 + + """.trimIndent() + + val xsd = schema.toXSD() + + val dataFile = with(File.createTempFile("DogData-BaleenUseCase4", ".xml")) { + deleteOnExit() + writeText(data) + this + } + + val xsdFile = with(File.createTempFile("DogSchema-BaleenUseCase4", ".xsd")) { + deleteOnExit() + writeText(xsd) + this + } + + val schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) + val schema = schemaFactory.newSchema(xsdFile) + val validator = schema.newValidator() + + validator.validate(StreamSource(dataFile)) + } + + @Test + fun `create an json schema and validate the data against it`() { + val data = """ + { + "name":"Fido", + "numLegs": 4 + } + """.trimIndent() + + val jsonSchemaStr = schema.toJsonSchema() + + val jsonSchema = JSONObject(JSONTokener(jsonSchemaStr)) + val jsonData = JSONObject(JSONTokener(data)) + + val schema = SchemaLoader.load(jsonSchema) + schema.validate(jsonData) + } + + @Test + fun `create an avro schema and validate the data against it`() { + val unknownDataSchema = """ + { + "type": "record", + "name": "Dog", + "fields": [ + { "name": "name", "type": "string" }, + { "name": "numLegs", "type": ["null", "int"], "default": null } + ] + } + """.trimIndent().asAvroSchema() + + val data = GenericRecordBuilder(unknownDataSchema) + .set("name", "Fido") + .set("numLegs", 4) + .build() + + val dataStream = with(ByteArrayOutputStream()) { + val writer = GenericDatumWriter(unknownDataSchema) + val encoder = EncoderFactory().directBinaryEncoder(this, null) + writer.write(data, encoder) + encoder.flush() + ByteArrayInputStream(this.toByteArray()) + } + + val avroSchema = schema.toAvroSchema() + + // Read data stream with our generated avro schema. It should be same as the original. + val record = with(dataStream) { + val reader = GenericDatumReader(avroSchema) + val decoder = DecoderFactory().directBinaryDecoder(this, null) + reader.read(null, decoder) + } + + // Verify that the new generic record has the right data + assertThat(record["name"].toString()).isEqualTo("Fido") + assertThat(record["numLegs"]).isEqualTo(4) + } + + @Test + fun `create an data class and validate the class structure`() { + val dataClass = schema.toDataClass() + + assertThat(dataClass.isData).isTrue() + assertThat(dataClass.simpleName).isEqualTo("dog") + + val nameField = dataClass.memberProperties.find { it.name == "name" } + val numLegsField = dataClass.memberProperties.find { it.name == "numLegs" } + + assertThat(nameField?.returnType?.classifier).isEqualTo(String::class) + assertThat(nameField?.returnType?.isMarkedNullable).isFalse() + assertThat(numLegsField?.returnType?.classifier).isEqualTo(Int::class) + assertThat(numLegsField?.returnType?.isMarkedNullable).isTrue() + + val instance = dataClass.primaryConstructor?.call("Fido", 4) + assertThat(instance).isNotNull() + + assertThat(instance.validate(schema)).isValid() + } + + @Test + fun `create an data class instance and validate it against the schema`() { + val data = schema.toDataClassInstance("Fido", 4) + + assertThat(data.validate(schema)).isValid() + } + } +} From ce10b1a3205145dc20776524c8309293367e49af Mon Sep 17 00:00:00 2001 From: Ken Dallmeyer Date: Mon, 1 Jul 2019 14:59:34 -0500 Subject: [PATCH 18/18] Add use-case 5 : Baleen as multiplatform --- baleen-v2-tests/README.md | 19 ---- baleen-v2/README.md | 29 ++++++ .../baleen-v2-tests}/build.gradle | 6 ++ .../baleen/version2/BaleenImprovements.kt | 0 .../baleen/version2/UseCase1Test.kt | 0 .../baleen/version2/UseCase2Test.kt | 0 .../baleen/version2/UseCase3Test.kt | 0 .../baleen/version2/UseCase4Test.kt | 0 baleen-v2/baleen-v2/.gitignore | 2 + baleen-v2/baleen-v2/build.gradle | 43 +++++++++ build.gradle | 94 ++++++++++--------- settings.gradle | 3 +- 12 files changed, 131 insertions(+), 65 deletions(-) delete mode 100644 baleen-v2-tests/README.md create mode 100644 baleen-v2/README.md rename {baleen-v2-tests => baleen-v2/baleen-v2-tests}/build.gradle (88%) rename {baleen-v2-tests => baleen-v2/baleen-v2-tests}/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt (100%) rename {baleen-v2-tests => baleen-v2/baleen-v2-tests}/src/test/kotlin/com/shoprunner/baleen/version2/UseCase1Test.kt (100%) rename {baleen-v2-tests => baleen-v2/baleen-v2-tests}/src/test/kotlin/com/shoprunner/baleen/version2/UseCase2Test.kt (100%) rename {baleen-v2-tests => baleen-v2/baleen-v2-tests}/src/test/kotlin/com/shoprunner/baleen/version2/UseCase3Test.kt (100%) rename {baleen-v2-tests => baleen-v2/baleen-v2-tests}/src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt (100%) create mode 100644 baleen-v2/baleen-v2/.gitignore create mode 100644 baleen-v2/baleen-v2/build.gradle diff --git a/baleen-v2-tests/README.md b/baleen-v2-tests/README.md deleted file mode 100644 index 8d093724..00000000 --- a/baleen-v2-tests/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Preparation for version 2 - -Do test driven development for version 2 - -## Use Case 1 - Given we have the data, we define the schema manually and validate the data - -[UseCase1Test.kt](./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](./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](./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](./src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt) \ No newline at end of file diff --git a/baleen-v2/README.md b/baleen-v2/README.md new file mode 100644 index 00000000..90d42807 --- /dev/null +++ b/baleen-v2/README.md @@ -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) \ No newline at end of file diff --git a/baleen-v2-tests/build.gradle b/baleen-v2/baleen-v2-tests/build.gradle similarity index 88% rename from baleen-v2-tests/build.gradle rename to baleen-v2/baleen-v2-tests/build.gradle index e38f0622..d7025aaa 100644 --- a/baleen-v2-tests/build.gradle +++ b/baleen-v2/baleen-v2-tests/build.gradle @@ -23,3 +23,9 @@ repositories { test { ignoreFailures = true } + +if (!project.hasProperty("version2")) { + project.tasks.each { + it.onlyIf { false } + } +} \ No newline at end of file diff --git a/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt b/baleen-v2/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt similarity index 100% rename from baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt rename to baleen-v2/baleen-v2-tests/src/main/kotlin/com/shoprunner/baleen/version2/BaleenImprovements.kt diff --git a/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase1Test.kt b/baleen-v2/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase1Test.kt similarity index 100% rename from baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase1Test.kt rename to baleen-v2/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase1Test.kt diff --git a/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase2Test.kt b/baleen-v2/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase2Test.kt similarity index 100% rename from baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase2Test.kt rename to baleen-v2/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase2Test.kt diff --git a/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase3Test.kt b/baleen-v2/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase3Test.kt similarity index 100% rename from baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase3Test.kt rename to baleen-v2/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase3Test.kt diff --git a/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt b/baleen-v2/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt similarity index 100% rename from baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt rename to baleen-v2/baleen-v2-tests/src/test/kotlin/com/shoprunner/baleen/version2/UseCase4Test.kt diff --git a/baleen-v2/baleen-v2/.gitignore b/baleen-v2/baleen-v2/.gitignore new file mode 100644 index 00000000..1c5976d8 --- /dev/null +++ b/baleen-v2/baleen-v2/.gitignore @@ -0,0 +1,2 @@ +src/commonMain +src/commonTest \ No newline at end of file diff --git a/baleen-v2/baleen-v2/build.gradle b/baleen-v2/baleen-v2/build.gradle new file mode 100644 index 00000000..8f783830 --- /dev/null +++ b/baleen-v2/baleen-v2/build.gradle @@ -0,0 +1,43 @@ +plugins { + id 'org.jetbrains.kotlin.multiplatform' +} + +kotlin { + // Targets + jvm() // Creates a JVM target with the default name 'jvm' + js() // JS target named 'js' + + sourceSets { + commonMain { + kotlin { + srcDir project(":baleen").file("src/main/kotlin") + } + + dependencies { + implementation kotlin('stdlib-common') + } + } + commonTest { +// kotlin { +// srcDir project(":baleen").file("src/test/kotlin") +// } + + dependencies { + implementation kotlin('test-common') + implementation kotlin('test-annotations-common') + } + } + + jvmTest { + dependencies { + implementation kotlin('test-junit') + } + } + } +} + +if (!project.hasProperty("version2")) { + project.tasks.each { + it.onlyIf { false } + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 992a6b51..96a946e4 100644 --- a/build.gradle +++ b/build.gradle @@ -2,13 +2,13 @@ plugins { id 'idea' id "org.jetbrains.dokka" version "0.9.18" apply false id 'org.jetbrains.kotlin.jvm' version '1.3.41' apply false - id 'org.jmailen.kotlinter' version '2.1.0' apply false + id 'org.jetbrains.kotlin.multiplatform' version '1.3.41' apply false + id 'org.jmailen.kotlinter' version '2.10' apply false } subprojects { apply plugin: 'org.jetbrains.dokka' apply plugin: 'maven-publish' - apply plugin: 'kotlin' apply plugin: 'org.jmailen.kotlinter' apply plugin: 'signing' @@ -17,62 +17,66 @@ subprojects { jcenter() } - dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib" - testImplementation 'org.assertj:assertj-core:3.12.2' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.0' - testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.5.0' - } + if(it.name != "baleen-v2") { + apply plugin: 'kotlin' - test { - useJUnitPlatform() - } + dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib" + testImplementation 'org.assertj:assertj-core:3.12.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.0' + testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.5.0' + } - task sourceJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource - } + test { + useJUnitPlatform() + } - task javadocJar(type: Jar, dependsOn: dokka) { - classifier = 'javadoc' - from dokka - } + task sourceJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource + } - artifacts { - archives jar - archives sourceJar - archives javadocJar - } + task javadocJar(type: Jar, dependsOn: dokka) { + classifier = 'javadoc' + from dokka + } - signing { - sign publishing.publications - } + artifacts { + archives jar + archives sourceJar + archives javadocJar + } + + signing { + sign publishing.publications + } - publishing { - publications { - mavenJava(MavenPublication) { - customizePom(pom) + publishing { + publications { + mavenJava(MavenPublication) { + customizePom(pom) - from components.java + from components.java - artifact sourceJar - artifact javadocJar + artifact sourceJar + artifact javadocJar + } } - } - repositories { - maven { - url "https://oss.sonatype.org/service/local/staging/deploy/maven2" - credentials { - username sonatypeUsername - password sonatypePassword + repositories { + maven { + url "https://oss.sonatype.org/service/local/staging/deploy/maven2" + credentials { + username sonatypeUsername + password sonatypePassword + } } } } - } - model { - tasks.generatePomFileForMavenJavaPublication { - destination = file("$buildDir/generated-pom.xml") + model { + tasks.generatePomFileForMavenJavaPublication { + destination = file("$buildDir/generated-pom.xml") + } } } } diff --git a/settings.gradle b/settings.gradle index 075c00e5..67e16922 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,6 +6,7 @@ include 'baleen-jsonschema-generator' include 'jsonschema-baleen-generator' include 'baleen-xml' include 'baleen-xsd-generator' -include 'baleen-v2-tests' +include 'baleen-v2:baleen-v2' +include 'baleen-v2:baleen-v2-tests' rootProject.name = 'baleen'