コード例 #1
0
  /** Validate simple statement selects for all primitive data types */
  public void primitiveSelectTest() throws Throwable {
    String execute_string;
    Object value;
    Row row;
    for (DataType dataType : PRIMITIVE_SELECT_STATEMENTS.keySet()) {
      execute_string = PRIMITIVE_SELECT_STATEMENTS.get(dataType);
      row = session.execute(execute_string).one();

      value = SAMPLE_DATA.get(dataType);
      assertEquals(TestUtils.getValue(row, "k", dataType), value);
      assertEquals(TestUtils.getValue(row, "v", dataType), value);
    }
    assertEquals(SAMPLE_DATA.size(), 15);
    assertEquals(PRIMITIVE_SELECT_STATEMENTS.keySet().size(), SAMPLE_DATA.size());
  }
コード例 #2
0
  /** Test simple statement selects for all collection data types */
  @SuppressWarnings("unchecked")
  public void collectionSelectTest() throws Throwable {
    HashMap<DataType, Object> sampleValueMap;
    String execute_string;
    DataType typeArgument1;
    DataType typeArgument2;
    Row row;
    for (DataType dataType : COLLECTION_SELECT_STATEMENTS.keySet()) {
      execute_string = COLLECTION_SELECT_STATEMENTS.get(dataType);
      row = session.execute(execute_string).one();

      sampleValueMap = (HashMap<DataType, Object>) SAMPLE_COLLECTIONS.get(dataType);
      typeArgument1 = dataType.getTypeArguments().get(0);
      if (dataType.getName() == DataType.Name.MAP) {
        typeArgument2 = dataType.getTypeArguments().get(1);

        // Create a copy of the map that is being expected
        HashMap<DataType, Object> sampleMap =
            (HashMap<DataType, Object>) sampleValueMap.get(typeArgument1);
        Object mapKey = SAMPLE_DATA.get(sampleMap.keySet().iterator().next());
        Object mapValue = sampleMap.values().iterator().next();
        HashMap<Object, Object> expectedMap = new HashMap<Object, Object>();
        expectedMap.put(mapKey, mapValue);

        assertEquals(TestUtils.getValue(row, "k", typeArgument2), SAMPLE_DATA.get(typeArgument2));
        assertEquals(TestUtils.getValue(row, "v", dataType), expectedMap);
      } else {
        Object expectedValue = sampleValueMap.get(typeArgument1);

        assertEquals(TestUtils.getValue(row, "k", typeArgument1), SAMPLE_DATA.get(typeArgument1));
        assertEquals(TestUtils.getValue(row, "v", dataType), expectedValue);
      }
    }
    assertEquals(SAMPLE_COLLECTIONS.size(), 255);
    assertEquals(COLLECTION_SELECT_STATEMENTS.keySet().size(), SAMPLE_COLLECTIONS.size());
  }