@Test public void testResolveParentWithIdFound() { Element expected = createMock(Element.class); replay(expected); Element parent = createMock(Element.class); expect(parent.findElementById("id")).andReturn(expected); replay(parent); baseElement = createMock(Element.class); expect(baseElement.getParent()).andReturn(parent); replay(baseElement); TargetElementResolver resolver = new TargetElementResolver(null, baseElement); assertEquals(expected, resolver.resolve("#parent#id")); verify(expected); verify(parent); verify(baseElement); }
@Nullable public Element resolve(@Nullable final String id) { if (id == null) { return null; } if (id.startsWith(PARENT)) { return resolveParents(id, base.getParent()); } if (id.startsWith("#")) { return base.findElementById(id); } return screen.findElementById(id); }
TargetElementResolver { @Nullable public Element resolve(@Nullable final String id) { if (id == null) { return null; } if (id.startsWith(PARENT)) { return resolveParents(id, base.getParent()); } if (id.startsWith("#")) { return base.findElementById(id); } return screen.findElementById(id); } }
TargetElementResolver { @Nullable public Element resolve(@Nullable final String id) { if (id == null) { return null; } if (id.startsWith(PARENT)) { return resolveParents(id, base.getParent()); } if (id.startsWith("#")) { return base.findElementById(id); } return screen.findElementById(id); } TargetElementResolver(@Nonnull final Screen screen, @Nonnull final Element baseElement); }
TargetElementResolver { @Nullable public Element resolve(@Nullable final String id) { if (id == null) { return null; } if (id.startsWith(PARENT)) { return resolveParents(id, base.getParent()); } if (id.startsWith("#")) { return base.findElementById(id); } return screen.findElementById(id); } TargetElementResolver(@Nonnull final Screen screen, @Nonnull final Element baseElement); @Nullable Element resolve(@Nullable final String id); }
TargetElementResolver { @Nullable public Element resolve(@Nullable final String id) { if (id == null) { return null; } if (id.startsWith(PARENT)) { return resolveParents(id, base.getParent()); } if (id.startsWith("#")) { return base.findElementById(id); } return screen.findElementById(id); } TargetElementResolver(@Nonnull final Screen screen, @Nonnull final Element baseElement); @Nullable Element resolve(@Nullable final String id);  }