From dc9a3caeb46c3b29f2827ad619f29e5eb1e33cc0 Mon Sep 17 00:00:00 2001 From: Sergey Pak Date: Sat, 23 Mar 2024 12:52:33 +0100 Subject: [PATCH] fix tests in ControllerBackedStoreTest and RunConfigurationSchemeManagerTest GitOrigin-RevId: 222f67b464e98ef5ac9d01face5aecf4b2736c1a --- .../testSrc/ControllerBackedStoreTest.kt | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/platform/configuration-store-impl/testSrc/ControllerBackedStoreTest.kt b/platform/configuration-store-impl/testSrc/ControllerBackedStoreTest.kt index bddb33f84e0a..97eea9ddac7b 100644 --- a/platform/configuration-store-impl/testSrc/ControllerBackedStoreTest.kt +++ b/platform/configuration-store-impl/testSrc/ControllerBackedStoreTest.kt @@ -131,7 +131,12 @@ class ControllerBackedStoreTest { }) @State(name = "TestState", storages = [Storage(value = StoragePathMacros.NON_ROAMABLE_FILE)]) - class TestComponentWithElementState : SerializablePersistentStateComponent(Element("test")) + class TestComponentWithElementState : SerializablePersistentStateComponent(Element("test")) { + + fun update(newState: Element) { + updateState { newState } + } + } val component = TestComponentWithElementState() store.initComponent(component = component, serviceDescriptor = null, pluginId = PluginManagerCore.CORE_ID) @@ -147,7 +152,7 @@ class ControllerBackedStoreTest { hello """.trimIndent() - component.state = JDOMUtil.load(testElementXml) + component.update(JDOMUtil.load(testElementXml)) store.save(forceSavingAllSettings = true) assertThat(jsonDomToXml(saved!!)).isEqualTo(testElementXml) @@ -237,7 +242,7 @@ class ControllerBackedStoreTest { assertThat(component.state.foo).isEqualTo("old") assertThat(component.state.bar).isEmpty() - component.state = ControllerTestState(bar = "42") + component.update(ControllerTestState(bar = "42")) store.save(forceSavingAllSettings = true) store.initComponent(component = component, serviceDescriptor = null, pluginId = PluginManagerCore.CORE_ID) @@ -355,6 +360,10 @@ class ControllerBackedStoreTest { override fun noStateLoaded() { loadState(TestState()) } + + fun update(newState: TestState) { + updateState { newState } + } } val component = TestComponent() @@ -363,6 +372,7 @@ class ControllerBackedStoreTest { assertThat(component.state.foo).isEqualTo("hello") component.state.foo = "newValue" + component.update(component.state) store.save(forceSavingAllSettings = true) assertThat(Json.encodeToString(saved)).isEqualTo("""{"foo":"newValue","bar":"test2"}""") } @@ -391,6 +401,10 @@ class ControllerBackedStoreTest { override fun noStateLoaded() { loadState(TestState()) } + + fun update(newState: TestState) { + updateState { newState } + } } val component = TestComponent() @@ -399,6 +413,7 @@ class ControllerBackedStoreTest { assertThat(component.state.foo).isEmpty() component.state.foo = "newValue" + component.update(component.state) store.save(forceSavingAllSettings = true) assertThat(component.state.foo).isEqualTo("newValue") @@ -431,12 +446,16 @@ class ControllerBackedStoreTest { override fun noStateLoaded() { loadState(TestState()) } + fun update(newState: TestState) { + updateState { newState } + } } val component = TestComponent() store.initComponent(component = component, serviceDescriptor = null, pluginId = PluginManagerCore.CORE_ID) component.state.foo = "hello" + component.update(component.state) store.save(forceSavingAllSettings = true) store.reloadStates(setOf("TestCacheState")) @@ -499,6 +518,10 @@ private class ControllerTestComponent : SerializablePersistentStateComponent