1 7 package com.inversoft.verge.mvc.model.test; 8 9 10 import java.util.Map ; 11 12 import javax.servlet.http.HttpServletRequest ; 13 14 import com.inversoft.verge.mvc.MVCException; 15 import com.inversoft.verge.mvc.MVCRequest; 16 import com.inversoft.verge.mvc.model.ModelResolution; 17 import com.inversoft.verge.mvc.model.ModelResolver; 18 import com.inversoft.verge.mvc.model.form.FormMetaData; 19 20 21 25 public class TestModelResolver implements ModelResolver { 26 27 30 public static final ModelResolution MODEL = new ModelResolution(new Object (), 31 new FormMetaData("id", "")); 32 33 public boolean calledDefinition = false; 34 public boolean calledParams = false; 35 public boolean calledNull = false; 36 37 38 40 public ModelResolution resolve(MVCRequest mvcRequest, String definition, Map extraParams) 41 throws MVCException { 42 HttpServletRequest request = mvcRequest.getRequest(); 43 if (request.getParameter("resolverTestDefinition") != null) { 44 calledDefinition = true; 45 if (definition == null || !definition.equals("test")) { 46 throw new MVCException("Resolver - definition test failed"); 47 } 48 } else if (request.getParameter("resolverTestParams") != null) { 49 calledParams = true; 50 if (extraParams == null || !extraParams.get("param").equals("test")) { 51 throw new MVCException("Resolver - params test failed"); 52 } 53 } else if (request.getParameter("resolverTestNull") != null) { 54 calledNull = true; 55 return null; 56 } 57 58 return MODEL; 59 } 60 } 61 | Popular Tags |