Skip to content

Commit c9379a6

Browse files
author
Hanseter
committed
Fix failing tests
1 parent a8415ba commit c9379a6

6 files changed

Lines changed: 57 additions & 44 deletions

File tree

src/main/kotlin/com/github/hanseter/json/editor/JsonPropertiesEditor.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ class JsonPropertiesEditor @JvmOverloads constructor(
154154
(treeTableView.root as FilterableTreeItem).add(pane.treeItem)
155155
pane.treeItem.isExpanded = idsToPanes.size <= viewOptions.numberOfInitiallyOpenedObjects
156156
pane.valid.addListener(paneValidListener)
157+
paneValidListener.changed(pane.valid, pane.valid.get(), pane.valid.get())
157158
}
158159

159160
fun display(

src/main/kotlin/com/github/hanseter/json/editor/JsonPropertiesPane.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ class JsonPropertiesPane(
204204
private fun updateTreeAfterChildChange(control: TypeControl) {
205205
val item = findInTree(treeItem, control) ?: return
206206

207+
item.list.clear()
207208
item.list.setAll(control.childControls.map { wrapControlInTreeItem(it) })
208209
}
209210

src/test/kotlin/com/github/hanseter/json/editor/CustomizationObjectTest.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ package com.github.hanseter.json.editor
22

33
import com.github.hanseter.json.editor.types.TypeModel
44
import com.github.hanseter.json.editor.util.CustomizationObject
5+
import javafx.scene.Parent
56
import javafx.scene.control.Labeled
67
import javafx.scene.control.TextField
78
import javafx.stage.Stage
89
import org.hamcrest.MatcherAssert
10+
import org.hamcrest.MatcherAssert.assertThat
911
import org.hamcrest.Matchers
12+
import org.hamcrest.Matchers.`is`
13+
import org.hamcrest.Matchers.not
1014
import org.json.JSONObject
1115
import org.junit.jupiter.api.Test
1216
import org.junit.jupiter.api.extension.ExtendWith
@@ -59,14 +63,14 @@ class CustomizationObjectTest {
5963

6064
val fooControl = editor.getControlInTable("bar") as TextField
6165

62-
MatcherAssert.assertThat((fooCell.graphic as Labeled).text, Matchers.`is`("bar"))
63-
MatcherAssert.assertThat((notFooCell.graphic as Labeled).text, Matchers.`is`("notFoo"))
66+
assertThat(((fooCell.graphic as Parent).childrenUnmodifiable.first() as Labeled).text, `is`("bar"))
67+
assertThat(((notFooCell.graphic as Parent).childrenUnmodifiable.first() as Labeled).text, `is`("notFoo"))
6468

6569
fooControl.text = "something"
6670

6771
WaitForAsyncUtils.waitForFxEvents()
68-
MatcherAssert.assertThat((fooCell.graphic as Labeled).text, Matchers.`is`("barsomething"))
69-
MatcherAssert.assertThat((notFooCell.graphic as Labeled).text, Matchers.`is`("notFoo"))
72+
assertThat(((fooCell.graphic as Parent).childrenUnmodifiable.first() as Labeled).text, `is`("barsomething"))
73+
assertThat(((notFooCell.graphic as Parent).childrenUnmodifiable.first() as Labeled).text, `is`("notFoo"))
7074
}
7175

7276
@Test
@@ -101,8 +105,8 @@ class CustomizationObjectTest {
101105

102106
val fooCell = editor.getKeyCellInTable("foo")
103107

104-
MatcherAssert.assertThat(fooCell.tooltip, Matchers.notNullValue())
105-
MatcherAssert.assertThat(fooCell.tooltip.text, Matchers.`is`("fooDesc"))
108+
assertThat(fooCell.tooltip, Matchers.notNullValue())
109+
assertThat(fooCell.tooltip.text, `is`("fooDesc"))
106110

107111
}
108112

@@ -127,7 +131,7 @@ class CustomizationObjectTest {
127131

128132
val fooCell = editor.getKeyCellInTable("foo")
129133

130-
MatcherAssert.assertThat((fooCell.graphic as Labeled).text, Matchers.`is`("foo"))
134+
assertThat(((fooCell.graphic as Parent).childrenUnmodifiable.first() as Labeled).text, `is`("foo"))
131135

132136
editor.customizationObject = object : CustomizationObject {
133137

@@ -142,7 +146,7 @@ class CustomizationObjectTest {
142146

143147
WaitForAsyncUtils.waitForFxEvents()
144148
val fooCellNew = editor.getKeyCellInTable("bar")
145-
MatcherAssert.assertThat((fooCellNew.graphic as Labeled).text, Matchers.`is`("bar"))
149+
assertThat(((fooCellNew.graphic as Parent).childrenUnmodifiable.first() as Labeled).text, `is`("bar"))
146150
}
147151

148152
}

src/test/kotlin/com/github/hanseter/json/editor/SchemaChangeTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class SchemaChangeTest {
5757

5858

5959

60-
PropertiesEditResult(it.data, ParsedSchema.create(newSchema, null as URI))
60+
PropertiesEditResult(it.data, ParsedSchema.create(newSchema, null))
6161
}
6262

6363

src/test/kotlin/com/github/hanseter/json/editor/ValidationKeywordsTest.kt

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.github.hanseter.json.editor
33
import javafx.scene.control.TextField
44
import javafx.stage.Stage
55
import org.hamcrest.MatcherAssert
6+
import org.hamcrest.MatcherAssert.assertThat
67
import org.hamcrest.Matchers.`is`
78
import org.json.JSONObject
89
import org.junit.jupiter.api.Test
@@ -39,72 +40,78 @@ class ValidationKeywordsTest {
3940
editor.display("1", "1", JSONObject().put("a", "foo"), schema) { it }
4041

4142
WaitForAsyncUtils.waitForFxEvents()
42-
MatcherAssert.assertThat(editor.valid.get(), `is`(true))
43+
assertThat(editor.valid.get(), `is`(true))
4344

4445
val stringControl = editor.getControlInTable("a") as TextField
4546

4647
stringControl.text = "bar"
4748

4849
WaitForAsyncUtils.waitForFxEvents()
49-
MatcherAssert.assertThat(editor.valid.get(), `is`(false))
50+
assertThat(editor.valid.get(), `is`(false))
5051
}
5152

5253
@Test
5354
fun testConditional() {
5455
val schema = JSONObject("""
5556
{
57+
"type":"object",
5658
"properties": {
57-
"a": {
58-
"type": "string"
59-
},
60-
"b": {
61-
"type": "string"
62-
}
63-
},
64-
"if": {
65-
"properties": {
66-
"a": {
67-
"const": "foo"
68-
}
69-
}
70-
},
71-
"then": {
72-
"properties": {
73-
"b": {
74-
"pattern": ".*bar.*"
75-
}
76-
}
77-
},
78-
"else": {
79-
"properties": {
80-
"b": {
81-
"pattern": ".*baz.*"
82-
}
83-
}
59+
"nested": {
60+
"type":"object",
61+
"properties": {
62+
"a": {
63+
"type": "string"
64+
},
65+
"b": {
66+
"type": "string"
67+
}
68+
},
69+
"if": {
70+
"properties": {
71+
"a": {
72+
"const": "foo"
73+
}
74+
}
75+
},
76+
"then": {
77+
"properties": {
78+
"b": {
79+
"pattern": ".*bar.*"
80+
}
81+
}
82+
},
83+
"else": {
84+
"properties": {
85+
"b": {
86+
"pattern": ".*baz.*"
87+
}
88+
}
89+
}
90+
}
8491
}
8592
}
8693
""")
8794

88-
editor.display("1", "1", JSONObject("""{"a": "foo", "b": "not"}"""), schema) { it }
95+
editor.display("1", "1", JSONObject("""{"nested":{"a": "foo", "b": "not"}}"""), schema) { it }
8996

9097
WaitForAsyncUtils.waitForFxEvents()
91-
MatcherAssert.assertThat(editor.valid.get(), `is`(false))
98+
assertThat(editor.valid.get(), `is`(false))
9299

93100
val itemTable = editor.getItemTable()
94101
val aControl = editor.getControlInTable("a") as TextField
95102
val bControl = editor.getControlInTable("b") as TextField
96103

97104
bControl.text = "something bar something"
98105
WaitForAsyncUtils.waitForFxEvents()
99-
MatcherAssert.assertThat(editor.valid.get(), `is`(true))
106+
assertThat(editor.valid.get(), `is`(true))
100107

101108

102109
aControl.text = "bar"
103110
WaitForAsyncUtils.waitForFxEvents()
104-
MatcherAssert.assertThat(editor.valid.get(), `is`(false))
111+
assertThat(editor.valid.get(), `is`(false))
105112

106113
bControl.text = "something baz something"
107114
WaitForAsyncUtils.waitForFxEvents()
108-
MatcherAssert.assertThat(editor.valid.get(), `is`(true))
115+
assertThat(editor.valid.get(), `is`(true))
109116
}
110117
}

src/test/kotlin/com/github/hanseter/json/editor/app/SchemaChangingTestApp.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class SchemaChangingTestApp : Application() {
9696

9797
PropertiesEditResult(
9898
SchemaNormalizer.deepCopy(it.data).put("b", ""),
99-
ParsedSchema.Companion.create(newSchema, null as URI)
99+
ParsedSchema.Companion.create(newSchema, null)
100100
)
101101
}
102102

0 commit comments

Comments
 (0)