objectbox / objectbox/objectbox-java
Make it easier to reliably test data observers
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Java
- Star
- 4.6k
- Fork
- 311
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
In my experience, testing data observers is somewhat brittle. Even with explicit transactions I sometimes get "delayed" notifications that have been triggered by the previous operation.
Let's take this test (ObjectBox 2.2.0 + RxJava 2):
boxStore.runInTx {
boxStore.boxFor(SomeEntity::class.java).put(SomeEntity())
}
val testObserver = TestObserver.create<Optional<SomeEntity>>()
boxStore.runInTx {
repository.find(123).subscribeWith(testObserver)
}
testObserver.awaitCount(1)
testObserver.assertValueCount(1)
Sometimes, I get a value count of 2 from the original put operation. For completeness, the code of the find() method:
fun find(id: Long): Observable<Optional<SomeEntity>> {
return Observable.create { emitter ->
val query = this.boxStore.boxFor(SomeEntity::class)
.query()
.equal(SomeEntity_.id, id)
.build()
query.subscribe().observer { result ->
emitter.onNext(result.firstOrNull().toOptional())
}
}
}
Assuming I did not misunderstand the docs or misuse the ObjectBox API, it would be great if ObjectBox could offer some method e.g. to block until all notifications triggered by the last transaction have been issued.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với chuỗi runInTx, TestObserver và query.subscribe().observer được nêu trong issue, sau đó xem xét hành vi của data-observer và transaction trong ObjectBox mà chuỗi này thực hiện. Công việc được xem là hoàn tất khi có một cách đáng tin cậy để chờ các thông báo từ transaction trước đó, được chứng minh bằng một test luôn nhận được đúng một giá trị như mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java, kotlin
- Lĩnh vực
- databases, testing
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100