### Question:
LayerLinker { public String getLinkedLayerId(String layerId) { LinkedLayers linkedLayers = myPrefs.getJAXBObject(LinkedLayers.class, ourLinkedLayersKey, (LinkedLayers)null); String linkedLayerId = null; if (linkedLayers != null) { for (LinkedLayer linkedLayer : linkedLayers.getLinkedLayers()) { if (layerId.equals(linkedLayer.getLinkedLayersTypeKey())) { linkedLayerId = linkedLayer.getOtherLinkedLayersTypeKey(); break; } else if (layerId.equals(linkedLayer.getOtherLinkedLayersTypeKey())) { linkedLayerId = linkedLayer.getLinkedLayersTypeKey(); break; } } } return linkedLayerId; } LayerLinker(PreferencesRegistry prefsRegistry); String getLinkedLayerId(String layerId);  }### Answer:
@Test public void testGetLinkedLayer() { EasyMockSupport support = new EasyMockSupport(); LinkedLayers links = createLinks(); PreferencesRegistry prefsReg = createPrefsRegistry(support, links); support.replayAll(); LayerLinker linker = new LayerLinker(prefsReg); assertEquals(ourOtherLinkedLayerId, linker.getLinkedLayerId(ourLinkedLayerId)); support.verifyAll(); }
@Test public void testGetLinkedLayerReverse() { EasyMockSupport support = new EasyMockSupport(); LinkedLayers links = createLinks(); PreferencesRegistry prefsReg = createPrefsRegistry(support, links); support.replayAll(); LayerLinker linker = new LayerLinker(prefsReg); assertEquals(ourLinkedLayerId, linker.getLinkedLayerId(ourOtherLinkedLayerId)); support.verifyAll(); }
@Test public void testGetLinkedNotLinked() { EasyMockSupport support = new EasyMockSupport(); LinkedLayers links = createLinks(); PreferencesRegistry prefsReg = createPrefsRegistry(support, links); support.replayAll(); LayerLinker linker = new LayerLinker(prefsReg); assertNull(linker.getLinkedLayerId("iamunlinked")); support.verifyAll(); }
@Test public void testGetLinkedNull() { EasyMockSupport support = new EasyMockSupport(); PreferencesRegistry prefsReg = createPrefsRegistry(support, null); support.replayAll(); LayerLinker linker = new LayerLinker(prefsReg); assertNull(linker.getLinkedLayerId(ourLinkedLayerId)); support.verifyAll(); }