Search in sources :

Example 6 with SuccessResult

use of com.datastax.oss.simulacron.common.result.SuccessResult 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);
}
Also used : Query(com.datastax.oss.simulacron.common.request.Query) RequestPrime(com.datastax.oss.simulacron.common.cluster.RequestPrime) ArrayList(java.util.ArrayList) SuccessResult(com.datastax.oss.simulacron.common.result.SuccessResult) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

RequestPrime (com.datastax.oss.simulacron.common.cluster.RequestPrime)6 SuccessResult (com.datastax.oss.simulacron.common.result.SuccessResult)6 LinkedHashMap (java.util.LinkedHashMap)6 Query (com.datastax.oss.simulacron.common.request.Query)4 Prime (com.datastax.oss.simulacron.common.stubbing.Prime)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DataStaxBulkLoader (com.datastax.oss.dsbulk.runner.DataStaxBulkLoader)2 ExitStatus (com.datastax.oss.dsbulk.runner.ExitStatus)2 FunctionFailureResult (com.datastax.oss.simulacron.common.result.FunctionFailureResult)2 ReadTimeoutResult (com.datastax.oss.simulacron.common.result.ReadTimeoutResult)2 WriteFailureResult (com.datastax.oss.simulacron.common.result.WriteFailureResult)2 WriteTimeoutResult (com.datastax.oss.simulacron.common.result.WriteTimeoutResult)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)1 DefaultProtocolVersion (com.datastax.oss.driver.api.core.DefaultProtocolVersion)1 DataType (com.datastax.oss.driver.api.core.type.DataType)1 TEXT (com.datastax.oss.driver.api.core.type.DataTypes.TEXT)1 ImmutableMap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap)1