@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 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()); }