use of com.datastax.oss.simulacron.common.request.Query in project dsbulk by datastax.
the class EndToEndUtils method createSimpleParameterizedQuery.
public static RequestPrime createSimpleParameterizedQuery(String query) {
LinkedHashMap<String, String> paramTypes = new LinkedHashMap<>();
paramTypes.put("country_code", "varchar");
paramTypes.put("country_name", "varchar");
paramTypes.put("beginning_ip_address", "inet");
paramTypes.put("ending_ip_address", "inet");
paramTypes.put("beginning_ip_number", "bigint");
paramTypes.put("ending_ip_number", "bigint");
Query when = new Query(query, Collections.emptyList(), new LinkedHashMap<>(), paramTypes);
SuccessResult then = new SuccessResult(new ArrayList<>(), new LinkedHashMap<>());
return new RequestPrime(when, then);
}
use of com.datastax.oss.simulacron.common.request.Query in project dsbulk by datastax.
the class EndToEndUtils method createQueryWithResultSetWithQuotes.
public static RequestPrime createQueryWithResultSetWithQuotes(String query, int numOfResults) {
Query when = new Query(query);
LinkedHashMap<String, String> columnTypes = new LinkedHashMap<>();
columnTypes.put("country_code", "varchar");
columnTypes.put("country_name", "varchar");
columnTypes.put("beginning_ip_address", "inet");
columnTypes.put("ending_ip_address", "inet");
columnTypes.put("beginning_ip_number", "bigint");
columnTypes.put("ending_ip_number", "bigint");
List<LinkedHashMap<String, Object>> rows = new ArrayList<>();
for (int i = 0; i < numOfResults; i++) {
LinkedHashMap<String, Object> row = new LinkedHashMap<>();
row.put("country_code", "country" + ";" + i);
row.put("country_name", "country" + ";" + i);
row.put("beginning_ip_address", "127.0.0." + i);
row.put("ending_ip_address", "127.2.0." + i);
row.put("beginning_ip_number", Integer.toString(i));
row.put("ending_ip_number", Integer.toString(i));
rows.add(row);
}
SuccessResult then = new SuccessResult(rows, columnTypes);
return new RequestPrime(when, then);
}
use of com.datastax.oss.simulacron.common.request.Query in project dsbulk by datastax.
the class EndToEndUtils method createQueryWithResultSet.
public static RequestPrime createQueryWithResultSet(String query, int numOfResults) {
Query when = new Query(query);
LinkedHashMap<String, String> columnTypes = new LinkedHashMap<>();
columnTypes.put("country_code", "varchar");
columnTypes.put("country_name", "varchar");
columnTypes.put("beginning_ip_address", "inet");
columnTypes.put("ending_ip_address", "inet");
columnTypes.put("beginning_ip_number", "bigint");
columnTypes.put("ending_ip_number", "bigint");
List<LinkedHashMap<String, Object>> rows = new ArrayList<>();
for (int i = 0; i < numOfResults; i++) {
LinkedHashMap<String, Object> row = new LinkedHashMap<>();
row.put("country_code", "country" + i);
row.put("country_name", "country" + i);
row.put("beginning_ip_address", "127.0.0.1");
row.put("ending_ip_address", "127.2.0.1");
row.put("beginning_ip_number", Integer.toString(i));
row.put("ending_ip_number", Integer.toString(i));
rows.add(row);
}
SuccessResult then = new SuccessResult(rows, columnTypes);
return new RequestPrime(when, then);
}
use of com.datastax.oss.simulacron.common.request.Query in project dsbulk by datastax.
the class EndToEndUtils method createParameterizedQuery.
public static RequestPrime createParameterizedQuery(String query, Map<String, Object> params, Result then) {
LinkedHashMap<String, String> paramTypes = new LinkedHashMap<>();
paramTypes.put("country_code", "varchar");
paramTypes.put("country_name", "varchar");
paramTypes.put("beginning_ip_address", "inet");
paramTypes.put("ending_ip_address", "inet");
paramTypes.put("beginning_ip_number", "bigint");
paramTypes.put("ending_ip_number", "bigint");
LinkedHashMap<String, Object> defaultParams = new LinkedHashMap<>();
defaultParams.put("country_code", "*");
defaultParams.put("country_name", "*");
defaultParams.put("beginning_ip_address", "*");
defaultParams.put("ending_ip_address", "*");
defaultParams.put("beginning_ip_number", "*");
defaultParams.put("ending_ip_number", "*");
for (String key : params.keySet()) {
defaultParams.put(key, params.get(key));
}
Query when = new Query(query, Collections.emptyList(), defaultParams, paramTypes);
return new RequestPrime(when, then);
}
Aggregations