### Question:
MapLayerInteractor { boolean isLayerVisible(String layerIdentifier) { List<Layer> layers = mapboxMap.getLayers(); return findLayerVisibility(layerIdentifier, layers); } MapLayerInteractor(MapboxMap mapboxMap);   }### Answer:
@Test public void isLayerVisible_visibleReturnsTrue() { SymbolLayer anySymbolOrLineLayer = mock(SymbolLayer.class); when(anySymbolOrLineLayer.getSourceLayer()).thenReturn("any"); when(anySymbolOrLineLayer.getVisibility()).thenReturn(visibility(Property.VISIBLE)); List<Layer> layers = buildLayerListWith(anySymbolOrLineLayer); MapboxMap map = mock(MapboxMap.class); when(map.getLayers()).thenReturn(layers); MapLayerInteractor layerInteractor = new MapLayerInteractor(map); boolean isVisible = layerInteractor.isLayerVisible("any"); assertTrue(isVisible); }
@Test public void isLayerVisible_visibleReturnsFalse() { LineLayer anySymbolOrLineLayer = mock(LineLayer.class); when(anySymbolOrLineLayer.getSourceLayer()).thenReturn("any"); when(anySymbolOrLineLayer.getVisibility()).thenReturn(visibility(Property.NONE)); List<Layer> layers = buildLayerListWith(anySymbolOrLineLayer); MapboxMap map = mock(MapboxMap.class); when(map.getLayers()).thenReturn(layers); MapLayerInteractor layerInteractor = new MapLayerInteractor(map); boolean isVisible = layerInteractor.isLayerVisible("any"); assertFalse(isVisible); }
@Test public void isLayerVisible_visibleReturnsFalseIfInvalidLayer() { HeatmapLayer invalidLayer = mock(HeatmapLayer.class); List<Layer> layers = buildLayerListWith(invalidLayer); MapboxMap map = mock(MapboxMap.class); when(map.getLayers()).thenReturn(layers); MapLayerInteractor layerInteractor = new MapLayerInteractor(map); boolean isVisible = layerInteractor.isLayerVisible("heatmap"); assertFalse(isVisible); }