### Question:
EnvoyCoupler { public List<WMSEnvoyAndState> retrieveRelatedEnvoys(Collection<? extends WMSLayerState> states) { List<WMSEnvoyAndState> envoyAndStates = New.list(); Map<String, WMSEnvoy> serversAndEnvoys = mapServersAndEnvoys(); Set<String> retrievedTypes = New.set(); Set<String> notLoadedServers = New.set(); for (WMSLayerState state : states) { WMSEnvoy envoy = serversAndEnvoys.get(state.getUrl()); if (envoy != null) { String[] layerNames = state.getParameters().getLayerName().split(","); for (String layerName : layerNames) { String key = WMSLayerKey.createKey( envoy.getServerConnectionConfig().getServerId(OGCServerSource.WMS_GETMAP_SERVICE), layerName); if (!retrievedTypes.contains(key)) { DataTypeInfo existingType = myDataController.findMemberById(key); if (existingType instanceof WMSDataType) { retrievedTypes.add(key); WMSDataType existingWmsType = (WMSDataType)existingType; WMSEnvoyAndState envoyAndState = new WMSEnvoyAndState(envoy, existingWmsType, state, layerName); envoyAndStates.add(envoyAndState); } else { String message = "Unable to restore WMS layer " + state.getId() + " layer does not exist on server " + state.getUrl(); LOGGER.warn(message); Notify.warn(message); } } } } else { notLoadedServers.add(state.getUrl()); } } for (String notLoadedServer : notLoadedServers) { LOGGER.warn("Server not loaded unable to load any WMS layers for " + notLoadedServer); } return envoyAndStates; } EnvoyCoupler(Plugin wmsPlugin, GenericRegistry<Envoy> envoyRegistry, DataGroupController dataController); List<WMSEnvoyAndState> retrieveRelatedEnvoys(Collection<? extends WMSLayerState> states);  }### Answer:
@Test public void testRetrieveRelatedEnvoys() { Plugin wmsPlugin = createPlugin(); List<ServerConnectionParams> params = createServerConnectionParams(ourServerUrl); List<WMSEnvoyAndEnvoy> envoys = createEnvoys(params); GenericRegistry<Envoy> envoyRegistry = createEnvoyRegistry(wmsPlugin, envoys); WMSDataType dataType = createDataType(); DataGroupController dataController = createDataController(dataType); EasyMock.replay(dataType); List<WMSEnvoyAndState> envoyAndStates = performTest(params, envoys, wmsPlugin, dataController, envoyRegistry); assertEquals(1, envoyAndStates.size()); WMSEnvoyAndState envoyAndState = envoyAndStates.get(0); assertEquals(myStates.get(1), envoyAndState.getState()); assertEquals(envoys.get(1), envoyAndState.getEnvoy()); assertEquals(dataType, envoyAndState.getTypeInfo()); EasyMock.verify(dataType); }