mirror of
https://github.com/corda/corda.git
synced 2025-04-07 11:27:01 +00:00
Protocols: fix unit tests for progress tracker and don't emit UNSTARTED to all subscribers.
This commit is contained in:
parent
8f27c35f18
commit
f32c83b8b3
@ -12,7 +12,7 @@ import core.TransientProperty
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.lang.kotlin.BehaviourSubject
|
||||
import rx.subjects.BehaviorSubject
|
||||
import rx.subjects.PublishSubject
|
||||
import java.util.*
|
||||
|
||||
// TODO: Expose the concept of errors.
|
||||
@ -159,8 +159,8 @@ class ProgressTracker(vararg steps: Step) {
|
||||
return currentStep
|
||||
}
|
||||
|
||||
// These two fields won't be serialized.
|
||||
private val _changes by TransientProperty { BehaviorSubject.create<Change>(Change.Position(UNSTARTED)) }
|
||||
// This field won't be serialized.
|
||||
private val _changes by TransientProperty { PublishSubject.create<Change>() }
|
||||
|
||||
/**
|
||||
* An observable stream of changes: includes child steps, resets and any changes emitted by individual steps (e.g.
|
||||
|
@ -58,6 +58,7 @@ class ProgressTrackerTest {
|
||||
@Test
|
||||
fun `cannot go beyond end`() {
|
||||
pt.currentStep = SimpleSteps.FOUR
|
||||
pt.nextStep()
|
||||
assertFails { pt.nextStep() }
|
||||
}
|
||||
|
||||
@ -70,13 +71,20 @@ class ProgressTrackerTest {
|
||||
stepNotification += it
|
||||
}
|
||||
|
||||
fun assertNextStep(step: ProgressTracker.Step) {
|
||||
assertEquals(step, (stepNotification.pollFirst() as ProgressTracker.Change.Position).newStep)
|
||||
}
|
||||
|
||||
pt.currentStep = SimpleSteps.ONE
|
||||
assertNextStep(SimpleSteps.ONE)
|
||||
|
||||
pt.childrenFor[SimpleSteps.TWO] = pt2
|
||||
pt.nextStep()
|
||||
|
||||
assertEquals(ChildSteps.AYY, pt.nextStep())
|
||||
assertEquals(ChildSteps.AYY, (stepNotification.pollFirst() as ProgressTracker.Change.Position).newStep)
|
||||
assertEquals(SimpleSteps.TWO, (stepNotification.pollFirst() as ProgressTracker.Change.Structural).parent)
|
||||
assertNextStep(SimpleSteps.TWO)
|
||||
|
||||
assertEquals(ChildSteps.AYY, pt2.nextStep())
|
||||
assertNextStep(ChildSteps.AYY)
|
||||
assertEquals(ChildSteps.BEE, pt2.nextStep())
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user