### Question:
ServiceMethod { public Map<String, Object> executeSync(Map<String, Object> arguments) { if (arguments == null){ throw new IllegalArgumentException("Parameters should not be null."); } validateParameters(arguments); if (syncExecute) { try { return syncExecImpl(arguments); } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { throw new RuntimeException("Method execution failed", ex); } } else if (asyncExecute) { return wrapAsSync(arguments); } else { throw new RuntimeException("Neither synchronous or asynchronous implementation was provided."); } } ServiceMethod(ServiceMethodDescription serviceMethodDescription, ServiceDescription serviceDescription); final String getName(); final String getDescription(); List<DataDescription> getArguments(); Map<String, DataDescription> getArgumentMap(); List<DataDescription> getResults(); Map<String, DataDescription> getResultMap(); @Override String toString(); Map<String, Object> executeSync(Map<String, Object> arguments); void executeAsync(Map<String, Object> arguments, Consumer<Map<String, Object>> callback, Consumer<Exception> errorCallback);  }### Answer:
@Test public void execute1() { ServiceMethod method = MathService.createMathService().getServiceMethods().get("add"); Map<String, Object> parameters = new HashMap<>(); parameters.put("arg1", 1); parameters.put("arg2", 2); Map<String, Object> result = method.executeSync(parameters); assertThat(result.get("result"), equalTo((Object) 3.0)); }
@Test(expected = IllegalArgumentException.class) public void execute2() { ServiceMethod method = MathService.createMathService().getServiceMethods().get("add"); Map<String, Object> parameters = new HashMap<>(); parameters.put("arg1", 1); parameters.put("arg2", "test"); method.executeSync(parameters); }
@Test public void execute3() { ServiceMethod method = MathService.createMathService().getServiceMethods().get("multiply"); Map<String, Object> parameters = new HashMap<>(); parameters.put("arg1", 1); parameters.put("arg2", 2); Map<String, Object> result = method.executeSync(parameters); assertThat(result.get("result"), equalTo((Object) 2.0)); }