For my unit test, I need to create a dummy PagingState
value.
https://docs.datastax.com/en/latest-java-driver-api/com/datastax/driver/core/PagingState.html
I can see that there is a fromString
method which can create the PagingState
object for me. But I need to provide the string in correct format.
What is the format of PagingState
?
I read that The paging state is a array of 16 bytes
. I tried doing the following
val pagingStateByteArray = Array[Byte](1.toByte,2.toByte,3.toByte,4.toByte,5.toByte,6.toByte,7.toByte,8.toByte,9.toByte,10.toByte,11.toByte,12.toByte,13.toByte,14.toByte,15.toByte,16.toByte)
val pagingState = PagingState.fromBytes(pagingStateByteArray) //make this more accurate. instance of PagingState
but got error
Cannot deserialize paging state, invalid format. The serialized form was corrupted, or not initially generated from a PagingState object.
com.datastax.driver.core.exceptions.PagingStateException: Cannot deserialize paging state, invalid format. The serialized form was corrupted, or not initially generated from a PagingState object.
at com.datastax.driver.core.PagingState.<init>(PagingState.java:60)
at com.datastax.driver.core.PagingState.fromBytes(PagingState.java:170)
Paging state has a meaning for driver (source code), so you need to provide meaningful values.
But for your test you can use the same value that is used in the Java driver tests:
PagingState emptyStatement = PagingState.fromString("00000000");;