class MBTilesHelper {

    public void setMBTileLayers(Context context, BaseLayerSwitcherPlugin baseLayerSwitcherPlugin) {
        if (mbtilesDir.exists() && mbtilesDir.exists() && mbtilesDir.listFiles() != null) {
            for (File mbTile : mbtilesDir.listFiles()) {
                MBTilesLayer mbTilesLayer = new MBTilesLayer(context, mbTile, this);
                if (!TextUtils.isEmpty(mbTilesLayer.getDisplayName())) {
                    baseLayerSwitcherPlugin.addBaseLayer(mbTilesLayer, false);
                }
            }
        }

    }

}

class MBTilesHelperTest  {

    @Rule
    public MockitoRule rule;
    private Context context;
    @Mock
    private Style style;
    @Mock
    private BaseLayerSwitcherPlugin switcherPlugin;
    private MBTilesHelper mbTilesHelper;

    @Test
    public void testSetMBTileLayers() {

        ReflectionHelpers.setField(mbTilesHelper, "mbtilesDir", new File("src/test/resources/"));
        mbTilesHelper.setMBTileLayers(context, switcherPlugin);
        verify(switcherPlugin, times(2)).addBaseLayer(any(MBTilesLayer.class), eq(false));
    }

}