### Question:
MapLayerInteractor { void updateLayerVisibility(boolean isVisible, String layerIdentifier) { List<Layer> layers = mapboxMap.getLayers(); updateLayerWithVisibility(layerIdentifier, layers, isVisible); } MapLayerInteractor(MapboxMap mapboxMap);   }### Answer:
@Test public void updateLayerVisibility_visibilityIsSet() { LineLayer anySymbolOrLineLayer = mock(LineLayer.class); when(anySymbolOrLineLayer.getSourceLayer()).thenReturn("any"); List<Layer> layers = buildLayerListWith(anySymbolOrLineLayer); MapboxMap map = mock(MapboxMap.class); when(map.getLayers()).thenReturn(layers); MapLayerInteractor layerInteractor = new MapLayerInteractor(map); layerInteractor.updateLayerVisibility(true, "any"); verify(anySymbolOrLineLayer).setProperties(any(PropertyValue.class)); }
@Test public void updateLayerVisibility_visibilityIsNotSet() { SymbolLayer anySymbolOrLineLayer = mock(SymbolLayer.class); when(anySymbolOrLineLayer.getSourceLayer()).thenReturn("any"); List<Layer> layers = buildLayerListWith(anySymbolOrLineLayer); MapboxMap map = mock(MapboxMap.class); when(map.getLayers()).thenReturn(layers); MapLayerInteractor layerInteractor = new MapLayerInteractor(map); layerInteractor.updateLayerVisibility(true, "random"); verify(anySymbolOrLineLayer, times(0)).setProperties(any(PropertyValue.class)); }
@Test public void updateLayerVisibility_visibilityIsNotSetIfInvalidLayer() { CircleLayer invalidLayer = mock(CircleLayer.class); List<Layer> layers = buildLayerListWith(invalidLayer); MapboxMap map = mock(MapboxMap.class); when(map.getLayers()).thenReturn(layers); MapLayerInteractor layerInteractor = new MapLayerInteractor(map); layerInteractor.updateLayerVisibility(true, "circle"); verify(invalidLayer, times(0)).setProperties(any(PropertyValue.class)); }