I've just started using ObjectBox in my Android apps and I have a simple question about it. This project rests on the Clean Architecture where I have a repository class which receives a BoxStore in its constructor via DI (Dagger2). Inside that constructor, as usual, I create a Box instance using boxStore.boxFor().
It's working perfectly but now I need to test this repository class and... I'm facing some problems that I don't know how to solve.
My first try was to mock BoxStore with Mockito and pass this mock to the repository's constructor. It throws a NullPoinerException. Then, I tried to create a local BoxStore, using the code below:
@Before
public void before() {
File tempFile = null;
try {
tempFile = File.createTempFile("object-store-test", "");
} catch (IOException e) {
e.printStackTrace();
}
tempFile.delete();
boxStoreDir = tempFile;
store = MyObjectBox.builder().directory(boxStoreDir).build();
repository = new EstadoOrgaoLocalRepository(store);
}
However, now I have the error java.lang.UnsatisfiedLinkError: no objectbox in java.library.path. I don't think installing ObjectBox locally in each developer machine would be a good option here.
So, my simple question is: how can I unit test my repository classes that receive a BoxStore instance via constructor injection?