@Test
  public void queryWithHashKey() {
    putItemWithHashKey();
    putItemWithHashKeyOverwriteItem();

    String code = "hash1";
    TestClassWithHashKey hashKeyTemplate = new TestClassWithHashKey();
    hashKeyTemplate.setCode(code);

    Map<String, Condition> emptyRangeConditions = new HashMap<String, Condition>();

    DynamoDBQueryExpression<TestClassWithHashKey> query =
        new DynamoDBQueryExpression<TestClassWithHashKey>()
            .withHashKeyValues(hashKeyTemplate)
            .withRangeKeyConditions(emptyRangeConditions);

    List<TestClassWithHashKey> valueList = mapper.query(TestClassWithHashKey.class, query);
    Assert.assertNotNull("Value list is null.", valueList);
    Assert.assertNotSame("Value list is empty.", 0, valueList.size());
    Assert.assertEquals("Value list has more than one item.", 1, valueList.size());

    TestClassWithHashKey value = valueList.get(0);
    Assert.assertEquals("Wrong code.", code, value.getCode());
    Assert.assertEquals("Wrong stringData.", "string1", value.getStringData());
    Assert.assertEquals("Wrong intData.", 1, value.getIntData());
    Assert.assertEquals(
        "Wrong stringSetData.", set("stringSetVal1", "stringSetVal2"), value.getStringSetData());
    Assert.assertEquals("Wrong numberSetData.", set(1, 2), value.getNumberSetData());
  }
  @Test
  public void queryWithUnknownHashKey() {
    putItemWithHashKey();

    String code = "hash1x";
    TestClassWithHashKey hashKeyTemplate = new TestClassWithHashKey();
    hashKeyTemplate.setCode(code);

    Map<String, Condition> emptyRangeConditions = new HashMap<String, Condition>();

    DynamoDBQueryExpression<TestClassWithHashKey> query =
        new DynamoDBQueryExpression<TestClassWithHashKey>()
            .withHashKeyValues(hashKeyTemplate)
            .withRangeKeyConditions(emptyRangeConditions);

    List<TestClassWithHashKey> valueList = mapper.query(TestClassWithHashKey.class, query);
    Assert.assertNotNull("Value list is null.", valueList);
    Assert.assertEquals("Value list should be empty.", 0, valueList.size());
  }
  // Test: put item with HashKey
  @Test
  public void putItemWithHashKey() {
    createTable(hashTableName, createStringAttributeDefinition("code"));

    TestClassWithHashKey value = new TestClassWithHashKey();
    value.setCode("hash1");
    value.setStringData("string1");
    value.setIntData(1);
    value.setStringSetData(set("stringSetVal1", "stringSetVal2"));
    value.setNumberSetData(set(1, 2));
    mapper.save(value);
  }
  @Test
  public void utf8Test() {
    createGenericTable(hashTableName, "code");

    TestClassWithHashKey value = new TestClassWithHashKey();
    value.setCode("éáűőúöüóí");
    value.setStringData("űáéúőóüöí");
    mapper.save(value);

    TestClassWithHashKey readValue = mapper.load(TestClassWithHashKey.class, "éáűőúöüóí");
    Assert.assertEquals("éáűőúöüóí", readValue.getCode());
    Assert.assertEquals("űáéúőóüöí", readValue.getStringData());
  }
  @Test
  public void getHashItemTest() {
    putItemWithHashKey();

    String code = "hash1";
    TestClassWithHashKey value = mapper.load(TestClassWithHashKey.class, code);
    Assert.assertNotNull("Value not found.", value);
    Assert.assertEquals("Wrong code.", code, value.getCode());
    Assert.assertEquals("Wrong stringData.", "string1", value.getStringData());
    Assert.assertEquals("Wrong intData.", 1, value.getIntData());
    Assert.assertEquals(
        "Wrong stringSetData.", set("stringSetVal1", "stringSetVal2"), value.getStringSetData());
    Assert.assertEquals("Wrong numberSetData.", set(1, 2), value.getNumberSetData());
  }
  @Test
  public void putItemWithHashKeyOverwriteItem() {
    try {
      createTable(hashTableName, createStringAttributeDefinition("code"));
    } catch (ResourceInUseException riue) {
      // The table is already created, do nothing
    }

    TestClassWithHashKey value2a = new TestClassWithHashKey();
    value2a.setCode("hash2");
    value2a.setStringData("string2a");
    value2a.setIntData(21);
    value2a.setStringSetData(set("stringSetVal2a1", "stringSetVal2a2"));
    value2a.setNumberSetData(set(3, 4));
    mapper.save(value2a);

    TestClassWithHashKey value2b = new TestClassWithHashKey();
    value2b.setCode("hash2");
    value2b.setStringData("string2b");
    value2b.setIntData(22);
    value2b.setStringSetData(set("stringSetVal2b1", "stringSetVal2b2"));
    value2b.setNumberSetData(set(5, 6));
    mapper.save(value2b);
  }