All Downloads are FREE. Search and download functionalities are using the official Maven repository.

arjuna.client.core.connector.SetuConnectUtils Maven / Gradle / Ivy

Go to download

Arjuna-Java is the client implementation in Java for development of test automation using Arjuna. It uses TestNG as the test engine. With minor tweaks, it can be used with any other test engine or custom test automation implementations. Arjuna is a Python based test automation framework developed by Rahul Verma (www.rahulverma.net)

The newest version!
package arjuna.client.core.connector;

import java.util.Arrays;
import java.util.Map;

public class SetuConnectUtils {
	private static SetuRequester setuClient = new DefaultSetuRequester();
	
	public static void setTestSessionSetuIdArg(Map inMap, String id) {
		inMap.put("testSessionSetuId", id);
	}
	
	public static void setAutomatorSetuIdArg(Map inMap, String id) {
		inMap.put("automatorSetuId", id);
	}
	
	public static void setGuiSetuIdArg(Map inMap, String id) {
		inMap.put("guiSetuId", id);
	}
	
	public static void addArgs(Map inMap, SetuArg... args) {
		for(SetuArg arg: args) {
			inMap.put(arg.getName(), arg.getObject());
		}		
	}

	private static void prepareRequestFromMap(SetuRequest request, Map inMap) {
		for(String name: inMap.keySet()) {
			request.addArg(name, inMap.get(name));
		}		
	}
	
	private static void prepareRequestFromArgs(SetuRequest request, SetuArg...args) {
		for(SetuArg arg: args) {
			request.addArg(arg.getName(), arg.getObject());
		}		
	}
	
	private static SetuRequest createRequest(String component, String actionType, Map inMap, SetuArg... args) {
		SetuRequest request = new DefaultSetuRequest(component, actionType);
		if (inMap != null) {
			prepareRequestFromMap(request, inMap);
		}
		prepareRequestFromArgs(request, args);
		return request;
	}
	
	public static ,E2 extends Enum> SetuResponse sendRequest(E1 component, E2 actionType) throws Exception {
		SetuRequest request = createRequest(component.toString(), actionType.toString(), null);
		return setuClient.post(request);
	}
	
	public static  ,E2 extends Enum> SetuResponse sendRequest(E1 component, E2 actionType, Map inMap) throws Exception {
		SetuRequest request = createRequest(component.toString(), actionType.toString(), inMap);
		return setuClient.post(request);
	}
	
	public static  ,E2 extends Enum> SetuResponse sendRequest(E1 component, E2 actionType, SetuArg... args) throws Exception {
		SetuRequest request = createRequest(component.toString(), actionType.toString(), null, args);
		return setuClient.post(request);
	}
	
	public static  ,E2 extends Enum> SetuResponse sendRequest(E1 component, E2 actionType, Map inMap, SetuArg... args) throws Exception {
		SetuRequest request = createRequest(component.toString(), actionType.toString(), inMap, args);
		SetuResponse resp = setuClient.post(request);
		return resp;
	}
	
	// From Joachim Sauer's Stackoverflow answer: https://stackoverflow.com/a/784842
	public static  T[] concat(T[] first, T[] second) {
		  T[] result = Arrays.copyOf(first, first.length + second.length);
		  System.arraycopy(second, 0, result, first.length, second.length);
		  return result;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy