use of com.jcabi.dynamo.Conditions in project jcabi-dynamo by jcabi.
the class H2DataTest method storesAndReadsAttributes.
/**
* H2Data can store and fetch.
* @throws Exception If some problem inside
*/
@Test
public void storesAndReadsAttributes() throws Exception {
final String table = "users";
final String key = "id";
final int number = 43;
final String attr = "desc";
final String value = "some\n\t\u20ac text";
final MkData data = new H2Data().with(table, new String[] { key }, new String[] { attr });
data.put(table, new Attributes().with(key, number).with(attr, value));
MatcherAssert.assertThat(data.iterate(table, new Conditions().with(key, Conditions.equalTo(number))).iterator().next(), Matchers.hasEntry(Matchers.equalTo(attr), Matchers.equalTo(new AttributeValue(value))));
}
use of com.jcabi.dynamo.Conditions in project jcabi-dynamo by jcabi.
the class H2DataTest method updatesTableAttributes.
/**
* H2Data can update table attributes.
* @throws Exception In case test fails
*/
@Test
public void updatesTableAttributes() throws Exception {
final String table = "tests";
final String key = "tid";
final int number = 43;
final String attr = "descr";
final String value = "Dummy\n\t\u20ac text";
final String updated = "Updated";
final MkData data = new H2Data().with(table, new String[] { key }, attr);
data.put(table, new Attributes().with(key, number).with(attr, value));
data.update(table, new Attributes().with(key, number), new AttributeUpdates().with(attr, "something else"));
data.update(table, new Attributes().with(key, number), new AttributeUpdates().with(attr, updated));
final Iterable<Attributes> result = data.iterate(table, new Conditions().with(key, Conditions.equalTo(number)));
MatcherAssert.assertThat(result.iterator().next(), Matchers.hasEntry(Matchers.equalTo(attr), Matchers.equalTo(new AttributeValue(updated))));
MatcherAssert.assertThat(result, Matchers.<Attributes>iterableWithSize(1));
}
Aggregations