Skip to content

Commit d2f9727

Browse files
QuadStingraySimon Siedler
authored andcommitted
fix: fix not compiling test for schema
1 parent 6b9dca2 commit d2f9727

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/test/scala/dev/mongocamp/driver/mongodb/schema/SchemaSpec.scala

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package dev.mongocamp.driver.mongodb.schema
22

3-
import dev.mongocamp.driver.mongodb.test.TestDatabase.{PersonDAO, PersonDocumentDAO}
3+
import dev.mongocamp.driver.mongodb.test.TestDatabase.{ PersonDAO, PersonDocumentDAO }
44
import dev.mongocamp.driver.mongodb._
55
import dev.mongocamp.driver.mongodb.relation.RelationDemoDatabase._
6-
import org.specs2.mutable.{Before, Specification}
6+
import org.specs2.mutable.{ Before, Specification }
77

88
import scala.util.Try
99

@@ -14,25 +14,25 @@ class SchemaSpec extends Specification with Before {
1414
"Schema" should {
1515
"analyse Json Schema from document dao" in {
1616
// #region schema-analysis
17-
val schemaExplorer = new SchemaExplorer()
17+
val schemaExplorer = new SchemaExplorer()
1818
val schemaAnalysis = schemaExplorer.analyzeSchema(PersonDocumentDAO)
1919
// #endregion schema-analysis
20-
schemaJson.contains("\"$schema\":\"https://json-schema.org/draft/2020-12/schema\"") must beTrue
21-
schemaJson.contains("\"Friends\":") must beTrue
22-
schemaJson.contains("\"title\":\"Friends\"") must beTrue
23-
schemaJson.contains("\"People\":") must beTrue
24-
schemaJson.contains("\"title\":\"People\"") must beTrue
25-
val idPattern1 = schemaJson.contains("\"_id\":{\"pattern\":\"^([a-fA-F0-9]{2})+$\",\"type\":\"string\"}")
26-
val idPattern2 = schemaJson.contains("\"_id\":{\"type\":\"string\",\"pattern\":\"^([a-fA-F0-9]{2})+$\"}")
27-
(idPattern1 || idPattern2) must beTrue
28-
schemaJson.contains("\"isActive\":{\"type\":\"boolean\"}") must beTrue
20+
schemaAnalysis.count must beEqualTo(200)
21+
schemaAnalysis.sample must beEqualTo(200)
22+
schemaAnalysis.percentageOfAnalysed must beEqualTo(1.0)
23+
schemaAnalysis.fields.size must beEqualTo(20)
24+
val idField = schemaAnalysis.fields.head
25+
idField.name must beEqualTo("_id")
26+
idField.fieldTypes.head.fieldType must beEqualTo("objectId")
27+
idField.fieldTypes.head.count must beEqualTo(200)
28+
idField.fieldTypes.head.percentageOfParent must beEqualTo(1.0)
2929
}
3030

3131
"detect Json Schema from document dao" in {
3232
// #region schema-explorer
33-
val schemaExplorer = new SchemaExplorer()
34-
val schema = schemaExplorer.detectSchema(PersonDocumentDAO)
35-
val schemaJson = schema.toJson
33+
val schemaExplorer = new SchemaExplorer()
34+
val schema = schemaExplorer.detectSchema(PersonDocumentDAO)
35+
val schemaJson = schema.toJson
3636
// #endregion schema-explorer
3737
schemaJson.contains("\"$schema\":\"https://json-schema.org/draft/2020-12/schema\"") must beTrue
3838
schemaJson.contains("\"Friends\":") must beTrue

0 commit comments

Comments
 (0)