/** * Builds the {@link #lookupMap} map of the given tree. This allows direct access to the tree * elements via data objects. * * @param tree * the tree * @return the lookup map for the given tree */ public static Map<Object, InvocationTreeElement> buildLookupMap(InvocationTreeElement tree) { return InvocationTreeUtil.getRoot(tree).asStream().collect(Collectors.toMap(e -> calculateLookupKey(e.getDataElement()), Function.identity())); }
/** * {@inheritDoc} */ @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { InvocationTreeElement input = validateInput(newInput); if (input == null) { return; } lookupMap = InvocationTreeUtil.buildLookupMap(input); rootElement = InvocationTreeUtil.getRoot(input); }
@Test public void successful() { InvocationTreeElement root = InvocationTreeUtil.getRoot(tree); assertThat(root, is(tree)); }
@Test public void useNullValue() { InvocationTreeElement root = InvocationTreeUtil.getRoot(null); assertThat(root, is(nullValue())); } }
@Test public void successfulInTree() { InvocationTreeElement treeElement = InvocationTreeUtil.lookupTreeElement(InvocationTreeUtil.buildLookupMap(tree), span03); InvocationTreeElement root = InvocationTreeUtil.getRoot(treeElement); assertThat(root, is(tree)); }