@@ -20,7 +20,9 @@ import com.intellij.openapi.ui.Messages
20
20
import com.intellij.openapi.vfs.VfsUtilCore
21
21
import com.intellij.openapi.vfs.VirtualFile
22
22
import eu.ibagroup.formainframe.dataops.content.service.SyncProcessService
23
+ import eu.ibagroup.formainframe.dataops.content.service.SyncProcessServiceImpl
23
24
import eu.ibagroup.formainframe.dataops.content.synchronizer.checkFileForSync
25
+ import eu.ibagroup.formainframe.dataops.content.synchronizer.checkForSync
24
26
import eu.ibagroup.formainframe.testutils.WithApplicationShouldSpec
25
27
import eu.ibagroup.formainframe.testutils.testServiceImpl.TestSyncProcessServiceImpl
26
28
import io.kotest.assertions.assertSoftly
@@ -115,6 +117,28 @@ class ContentTestSpec : WithApplicationShouldSpec({
115
117
wasWarningShown shouldBe false
116
118
}
117
119
}
120
+ // syncUtils.checkForSync
121
+ should("check that any file is syncing") {
122
+ syncProcessService.testInstance = object : TestSyncProcessServiceImpl () {
123
+ override fun isAnyFileSyncingNow(): Boolean {
124
+ return true
125
+ }
126
+ }
127
+
128
+ val result = checkForSync(mockk())
129
+ assertSoftly {
130
+ result shouldBe true
131
+ wasWarningShown shouldBe true
132
+ }
133
+ }
134
+ should("check that no file is syncing") {
135
+ val result = checkForSync()
136
+
137
+ assertSoftly {
138
+ result shouldBe false
139
+ wasWarningShown shouldBe false
140
+ }
141
+ }
118
142
// SyncAction.actionPerformed
119
143
should("synchronize the file with the remote file") {}
120
144
// MemberContentSynchronizer.fetchRemoteContentBytes
@@ -133,56 +157,59 @@ class ContentTestSpec : WithApplicationShouldSpec({
133
157
should("adapt content for the dataset from mainframe with variable print length") {}
134
158
}
135
159
context("dataops module: content/service") {
160
+ val syncProcessService = SyncProcessServiceImpl ()
136
161
137
162
val virtualFileMock = mockk<VirtualFile >()
138
163
val progressIndicatorMock = mockk<ProgressIndicator >()
139
164
140
165
beforeEach {
166
+ syncProcessService.startFileSync(virtualFileMock, progressIndicatorMock)
167
+
141
168
val isAncestorRef : (VirtualFile , VirtualFile , Boolean ) -> Boolean = VfsUtilCore : :isAncestor
142
169
mockkStatic(isAncestorRef as KFunction <* >)
143
170
}
144
171
145
172
afterEach {
173
+ syncProcessService.stopFileSync(virtualFileMock)
174
+
146
175
unmockkAll()
147
176
}
148
177
149
178
// SyncProcessServiceImpl.isFileSyncingNow
150
- // TODO: rewrite to the service usage
151
- // should("file is syncing now") {
152
- // every { progressIndicatorMock.isRunning } returns true
153
- //
154
- // val result = SyncProcessService.getService().isFileSyncingNow(virtualFileMock)
155
- //
156
- // assertSoftly {
157
- // result shouldBe true
158
- // }
159
- // }
179
+ should("file is syncing now") {
180
+ every { progressIndicatorMock.isRunning } returns true
181
+
182
+ val result = syncProcessService.isFileSyncingNow(virtualFileMock)
183
+
184
+ assertSoftly {
185
+ result shouldBe true
186
+ }
187
+ }
160
188
should("file is not syncing now") {
161
189
every { progressIndicatorMock.isRunning } returns false
162
190
163
- val result = SyncProcessService .getService() .isFileSyncingNow(virtualFileMock)
191
+ val result = syncProcessService .isFileSyncingNow(virtualFileMock)
164
192
165
193
assertSoftly {
166
194
result shouldBe false
167
195
}
168
196
}
169
197
// SyncProcessServiceImpl.areDependentFilesSyncingNow
170
- // TODO: rewrite to the service usage
171
- // should("dependent files are syncing now") {
172
- // every { progressIndicatorMock.isRunning } returns true
173
- // every { VfsUtilCore.isAncestor(virtualFileMock, any(), true) } returns true
174
- //
175
- // val result = SyncProcessService.getService().areDependentFilesSyncingNow(virtualFileMock)
176
- //
177
- // assertSoftly {
178
- // result shouldBe true
179
- // }
180
- // }
198
+ should("dependent files are syncing now") {
199
+ every { progressIndicatorMock.isRunning } returns true
200
+ every { VfsUtilCore .isAncestor(virtualFileMock, any(), true) } returns true
201
+
202
+ val result = syncProcessService.areDependentFilesSyncingNow(virtualFileMock)
203
+
204
+ assertSoftly {
205
+ result shouldBe true
206
+ }
207
+ }
181
208
should("dependent files are not syncing now") {
182
209
every { progressIndicatorMock.isRunning } returns true
183
210
every { VfsUtilCore .isAncestor(virtualFileMock, any(), true) } returns false
184
211
185
- val result = SyncProcessService .getService() .areDependentFilesSyncingNow(virtualFileMock)
212
+ val result = syncProcessService .areDependentFilesSyncingNow(virtualFileMock)
186
213
187
214
assertSoftly {
188
215
result shouldBe false
@@ -191,7 +218,26 @@ class ContentTestSpec : WithApplicationShouldSpec({
191
218
should("dependent files are not syncing now because no sync is running") {
192
219
every { progressIndicatorMock.isRunning } returns false
193
220
194
- val result = SyncProcessService .getService().areDependentFilesSyncingNow(virtualFileMock)
221
+ val result = syncProcessService.areDependentFilesSyncingNow(virtualFileMock)
222
+
223
+ assertSoftly {
224
+ result shouldBe false
225
+ }
226
+ }
227
+ // SyncProcessServiceImpl.isAnyFileSyncingNow
228
+ should("any file is syncing now") {
229
+ every { progressIndicatorMock.isRunning } returns true
230
+
231
+ val result = syncProcessService.isAnyFileSyncingNow()
232
+
233
+ assertSoftly {
234
+ result shouldBe true
235
+ }
236
+ }
237
+ should("no file is syncing now") {
238
+ every { progressIndicatorMock.isRunning } returns false
239
+
240
+ val result = syncProcessService.isAnyFileSyncingNow()
195
241
196
242
assertSoftly {
197
243
result shouldBe false
0 commit comments