Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. public abstract class AbstractApiFunctionalTest extends AbstractLazyInitializationDependencyInjectionSpringContextTests {
  2.  
  3.     private DataSetupFacade dataSetupFacade;
  4.     private XmlApiTestUtil xmlApiTestUtil;
  5.     private HashMap<Class<?>, JsonApiTestUtil> jsonApiTestUtilHashMap;
  6.     private String emailDomain = "functionaltest.com";
  7.  
  8.     protected AbstractApiFunctionalTest() {
  9.         jsonApiTestUtilHashMap = new HashMap<Class<?>, JsonApiTestUtil>();
  10.     }
  11.  
  12.     protected Environment getEnvironment() {
  13.         return (Environment) getApplicationContext().getBean("environment");
  14.     }
  15.  
  16.     public XmlApiTestUtil getXmlApiTestUtil() {
  17.         if(xmlApiTestUtil == null){
  18.             xmlApiTestUtil = new XmlApiTestUtil(getEnvironmentContextHostMappingFactory());
  19.         }
  20.         return xmlApiTestUtil;
  21.     }
  22.  
  23.     public <T extends JsonTestResponse> JsonApiTestUtil<T> getJsonApiTestUtil(T jsonTestResponse){
  24.         Class<?> jsonTestResponseTypeClass = ReflectionUtils.getTypeArguments(JsonTestResponse.class, jsonTestResponse.getClass()).get(0);
  25.        
  26.         if(!jsonApiTestUtilHashMap.containsKey(jsonTestResponseTypeClass)){
  27.             jsonApiTestUtilHashMap.put(jsonTestResponseTypeClass, new JsonApiTestUtil<T>(getEnvironmentContextHostMappingFactory()));
  28.         }
  29.        
  30.         return jsonApiTestUtilHashMap.get(jsonTestResponseTypeClass);
  31.     }
  32.  
  33.     public EnvironmentContextHostMappingFactory getEnvironmentContextHostMappingFactory(){
  34.         return (EnvironmentContextHostMappingFactory) getApplicationContext().getBean("environmentContextHostMappingFactory");
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement