@Points("77.4") @Test public void hasMethodLoadMoney() throws Throwable { String method = "loadMoney"; Object olio = newKortti(4.0); assertTrue( "add the class " + klassName + " method public void " + method + "(double amount) ", klass.method(olio, method).returningVoid().taking(double.class).isPublic()); String v = "\nFailure was caused by code Lyyracard lc = new LyyraCard(4.0); lc.loadMoney(2.0);"; klass.method(olio, method).returningVoid().taking(double.class).withNiceError(v).invoke(2.0); }
@Test @Points("85.3") public void test7() throws Throwable { String method = "totalWeightsMeasured"; Reformatory k = new Reformatory(); assertTrue( "add class " + klassName + " method public int " + method + "() ", klass.method(k, method).returning(int.class).takingNoParams().isPublic()); String v = "\nCode that caused the problem " + "k = new Reformatory; k.totalWeightsMeasured();"; klass.method(k, method).returning(int.class).takingNoParams().withNiceError(v).invoke(); }
/* * helpers */ private void syo(String miten, Object card) throws Throwable { String method = "pay" + miten; String v = "\nFailure was caused by code lc = new LyyraCard(4); lc." + method + "()"; klass.method(card, method).returningVoid().takingNoParams().withNiceError(v).invoke(); }
@Points("77.2") @Test public void hasMethodPayGourmet() throws Throwable { String method = "payGourmet"; // Reflex.ClassRef<Object> klass = Reflex.reflect(klassName); Object olio = newKortti(4.0); assertTrue( "add the class " + klassName + " method public void " + method + "() ", klass.method(olio, method).returningVoid().takingNoParams().isPublic()); String v = "\nFailure was caused by code Lyyracard lc = new LyyraCard(4.0); lc.payGourmet()"; klass.method(olio, method).returningVoid().takingNoParams().withNiceError(v).invoke(); }
private Object newKortti(double arvo) throws Throwable { Reflex.MethodRef1<Object, Object, Double> ctor = klass.constructor().taking(double.class).withNiceError(); assertTrue( "Add class " + klassName + " constructor: public " + klassName + "(double initialBalance)", ctor.isPublic()); return ctor.invoke(arvo); }
@Points("85.2") @Test public void test4() throws Throwable { String method = "feed"; Person h = new Person("Pekka", 20, 175, 85); Reformatory k = new Reformatory(); assertTrue( "add class " + klassName + " method public void " + method + "(Person h) ", klass.method(k, method).returningVoid().taking(Person.class).isPublic()); String v = "\nCode that caused the problem " + "k = new Reformatory(); h = new Person(\"Pekka\", 20, 175, 85); k.weight(h);"; klass.method(k, method).returningVoid().taking(Person.class).withNiceError(v).invoke(h); }
private void loadMoney(Object card, double maara) throws Throwable { String method = "loadMoney"; String v = "\nFailure was caused by code lc = new LyyraCard(4); lc." + method + "(" + maara + ")"; klass.method(card, method).returningVoid().taking(double.class).withNiceError(v).invoke(maara); }
@Points("77.1") @Test public void classPublic() { assertTrue( "class " + klassName + " should be public, define it as follows\npublic class Product {...\n}", klass.isPublic()); }
@Points("77.1") @Test public void testConstructor() throws Throwable { Reflex.MethodRef1<Object, Object, Double> ctor = klass.constructor().taking(double.class).withNiceError(); assertTrue( "Add class " + klassName + " constructor: public " + klassName + "(double initialBalance)", ctor.isPublic()); ctor.invoke(4.0); }
private String toString(Object olio) throws Throwable { // Reflex.ClassRef<Object> klassi = Reflex.reflect(klassName); String method = "toString"; String v = "\nFailure was caused by code lc = new LyyraCard(4); lc.toString()"; return klass .method(olio, method) .returning(String.class) .takingNoParams() .withNiceError(v) .invoke(); }