public void executeMethod(CallMethod callMethod) { methodExecutor.executeMethod( callMethod ); }
public void executeMethod(CallMethod callMethod) { methodExecutor.executeMethod( callMethod ); }
@Test public void testCallMethodNoArgumentOnFact() throws Exception { HashMap<String, Object> populatedData = new HashMap<String, Object>(); MethodExecutor methodExecutor = new MethodExecutor(populatedData); Cheesery listChesse = new Cheesery(); listChesse.setTotalAmount(1000); populatedData.put("cheese", listChesse); CallMethod mCall = new CallMethod(); mCall.setVariable("cheese"); mCall.setMethodName("setTotalAmountToZero"); methodExecutor.executeMethod(mCall); assertTrue(listChesse.getTotalAmount() == 0); }
@Test public void testCallMethodOnStandardArgumentOnFact() throws Exception { HashMap<String, Object> populatedData = new HashMap<String, Object>(); MethodExecutor methodExecutor = new MethodExecutor(populatedData); Cheesery listChesse = new Cheesery(); listChesse.setTotalAmount(1000); populatedData.put("cheese", listChesse); CallMethod mCall = new CallMethod(); mCall.setVariable("cheese"); mCall.setMethodName("addToTotalAmount"); CallFieldValue field = new CallFieldValue(); field.value = "5"; mCall.addFieldValue(field); methodExecutor.executeMethod(mCall); assertTrue(listChesse.getTotalAmount() == 1005); }
@Test public void testCallMethodOnClassArgumentAndOnArgumentStandardOnFact() throws Exception { HashMap<String, Object> populatedData = new HashMap<String, Object>(); MethodExecutor methodExecutor = new MethodExecutor(populatedData); Cheesery listChesse = new Cheesery(); listChesse.setTotalAmount(1000); populatedData.put("cheese", listChesse); Cheesery.Maturity m = new Cheesery.Maturity("veryYoung"); populatedData.put("m", m); CallMethod mCall = new CallMethod(); mCall.setVariable("cheese"); mCall.setMethodName("setAgeToMaturity"); CallFieldValue field = new CallFieldValue(); field.value = "=m"; mCall.addFieldValue(field); CallFieldValue field2 = new CallFieldValue(); field2.value = "veryold"; mCall.addFieldValue(field2); methodExecutor.executeMethod(mCall); assertTrue(m.getAge().equals("veryold")); } }
@Test public void testCallMethodOnClassArgumentOnFact() throws Exception { HashMap<String, Object> populatedData = new HashMap<String, Object>(); MethodExecutor methodExecutor = new MethodExecutor(populatedData); Cheesery listChesse = new Cheesery(); listChesse.setTotalAmount(1000); populatedData.put("cheese", listChesse); Cheesery.Maturity m = new Cheesery.Maturity(); populatedData.put("m", m); CallMethod mCall = new CallMethod(); mCall.setVariable("cheese"); mCall.setMethodName("setGoodMaturity"); CallFieldValue field = new CallFieldValue(); field.value = "=m"; mCall.addFieldValue(field); methodExecutor.executeMethod(mCall); assertTrue(listChesse.getMaturity().equals(m)); assertTrue(listChesse.getMaturity() == m); }