I'm trying to test my SimpleFrgament
class using Roboelectric
.
Now the scenario is - the fragment opens sqlite DB and fetches Page
(Pojo class) from it and based on the values inside the POJO my layout is inflated.
Here is the code:
MyDb dbInstance = new MyDb(getActivity());
dbInstance.open();
Page currentPage = dbInstance.retrievePage(pageId, selectedLang);
dbInstance.close();
if (currentPage.getStatus() == null || currentPage.getStatus().size() == 0) {
llStatus.setVisibility(View.GONE);
} else {
String color = currentPage.getStatus().get(0).getColor();
if (color.equals("red"))
tvStatus.setTextColor(Color.RED);
else
tvStatus.setTextColor(Color.GREEN);
tvStatus.setText(currentPage.getStatus().get(0).getTitle());
}
Now this currentPage is obviously null and even if I fill it with some dummy values in my test code, the above piece of code will override it with null. So what is the approach to bypass the code or shadow the local database values?