static void renderIntermediateClassBuilder(JUnitSoftAssertions softly, String intermediateClassBuilderSource) throws Exception { BuilderTester<IntermediateClass> tester = new BuilderTester<IntermediateClass>(IntermediateClass.class, intermediateClassBuilderSource); IntermediateClass constructed = tester.test(".name(\"name2\")"); softly.assertThat(constructed.getName()).as("name").isEqualTo("name2"); }
static void renderNormalJavaBeanBuilder(JUnitSoftAssertions softly, String normalJavaBeanBuilderSource) throws Exception { BuilderTester<NormalJavaBean> tester = new BuilderTester<NormalJavaBean>(NormalJavaBean.class, normalJavaBeanBuilderSource); NormalJavaBean constructed = tester .test(".name($S).age(18).date(new java.util.Date()).address(new Address())", "builderTest"); softly.assertThat(constructed.getName()).isEqualTo("builderTest"); softly.assertThat(constructed.getAge()).isEqualTo(18); }
static void assertGivenStackValues(Object[][] values, final JUnitSoftAssertions softly, final StackFrame frame){ for (Object[] stackValues : values) { int position = (int)stackValues[0]; int value = (int)stackValues[1]; assertThatValueAtPositionIsEqual(position, value, softly, frame); } }
static void assertGivenStackValuesWithAttributes(Object[][] values, final JUnitSoftAssertions softly, final StackFrame frame){ for (Object[] stackValues : values) { int position = (int)stackValues[0]; int value = (int)stackValues[1]; String attribute = (String)stackValues[2]; assertThatValueAtPositionHave(position, value, attribute, softly, frame); } }
public SimpleDependencyCheck(JUnitSoftAssertions softly) { this.softly = softly; }
static void assertThatValueAtPositionHave(int position, int value, String attribute, final JUnitSoftAssertions softly, final StackFrame frame){ assertThatValueAtPositionIsEqual(position, value, softly, frame); softly.assertThat(frame.getOperandAttr(position)).isEqualTo(attribute); // same const pool string }
static void assertThatValueAtPositionIsEqual(int position, int value, final JUnitSoftAssertions softly, final StackFrame frame){ softly.assertThat(frame.peek(position)).isEqualTo(value); }