MethodBehavior { public void addYield(MethodYield yield) { yields.add(yield); } MethodBehavior(String signature, boolean varArgs); void addYield(MethodYield yield); void createYield(ExplodedGraph.Node node); ExceptionalYield createExceptionalCheckBasedYield(SymbolicValue target, ExplodedGraph.Node node, String exceptionType, SECheck check); boolean isMethodVarArgs(); int methodArity(); List<MethodYield> yields(); Stream<ExceptionalYield> exceptionalPathYields(); Stream<HappyPathYield> happyPathYields(); void addParameter(SymbolicValue sv); List<SymbolicValue> parameters(); boolean isComplete(); void completed(); boolean isVisited(); void visited(); String signature(); void setVarArgs(boolean varArgs); List<String> getDeclaredExceptions(); void setDeclaredExceptions(List<String> declaredExceptions); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test void equality() { MethodBehavior mb = newMethodBehavior("foo()Ljava/lang/Object;"); addYield(mb, ObjectConstraint.NOT_NULL); addYield(mb, ObjectConstraint.NULL); MethodBehavior sameYields = newMethodBehavior("foo()Ljava/lang/Object;"); addYield(sameYields, ObjectConstraint.NOT_NULL); addYield(sameYields, ObjectConstraint.NULL); MethodBehavior differentType = new MethodBehavior("foo()Ljava/lang/Object;", false) { private Object o = new Object(); }; addYield(differentType, ObjectConstraint.NOT_NULL); addYield(differentType, ObjectConstraint.NULL); MethodBehavior differentSignature = newMethodBehavior("bar()Ljava/lang/Object;"); addYield(differentSignature, ObjectConstraint.NOT_NULL); addYield(differentSignature, ObjectConstraint.NULL); assertThat(mb) .isEqualTo(mb) .isEqualTo(sameYields) .isNotEqualTo(differentType) .isNotEqualTo(differentSignature) .isNotEqualTo(null) .isNotEqualTo(new Object()); }
@Test void to_String_display_number_of_yields() { String signature = "foo()Ljava/lang/Object;"; MethodBehavior mb1 = newMethodBehavior(signature); addYield(mb1, ObjectConstraint.NOT_NULL); addYield(mb1, ObjectConstraint.NULL); assertThat(mb1).hasToString("foo()Ljava/lang/Object; [2 yield(s)]"); }