### Question:
PathToken { boolean isUpstreamDefinite() { if (upstreamDefinite == null) { upstreamDefinite = isRoot() || prev.isTokenDefinite() && prev.isUpstreamDefinite(); } return upstreamDefinite; }  int getTokenCount(); boolean isPathDefinite(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); void invoke(PathFunction pathFunction, String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx); abstract void evaluate(String currentPath, PathRef parent,  Object model, EvaluationContextImpl ctx); abstract boolean isTokenDefinite(); void setNext(final PathToken next);  }### Answer:
@Test public void is_upstream_definite_in_simple_case() { assertThat(makePathReturningTail(makePPT("foo")).isUpstreamDefinite()).isTrue(); assertThat(makePathReturningTail(makePPT("foo"), makePPT("bar")).isUpstreamDefinite()).isTrue(); assertThat(makePathReturningTail(makePPT("foo", "foo2"), makePPT("bar")).isUpstreamDefinite()).isFalse(); assertThat(makePathReturningTail(new WildcardPathToken(), makePPT("bar")).isUpstreamDefinite()).isFalse(); assertThat(makePathReturningTail(new ScanPathToken(), makePPT("bar")).isUpstreamDefinite()).isFalse(); }
@Test public void is_upstream_definite_in_complex_case() { assertThat(makePathReturningTail(makePPT("foo"), makePPT("bar"), makePPT("baz")).isUpstreamDefinite()).isTrue(); assertThat(makePathReturningTail(makePPT("foo"), new WildcardPathToken()).isUpstreamDefinite()).isTrue(); assertThat(makePathReturningTail(new WildcardPathToken(), makePPT("bar"), makePPT("baz")).isUpstreamDefinite()).isFalse(); }