use of com.jcabi.dynamo.Attributes in project jcabi-dynamo by jcabi.
the class ReRegionTest method retriesAwsCalls.
/**
* ReRegion can retry on some AWS calls.
* @throws Exception If some problem inside
*/
@Test
public void retriesAwsCalls() throws Exception {
final Table table = Mockito.mock(Table.class);
final Attributes attrs = new Attributes();
final String msg = "hey you";
Mockito.doThrow(new AmazonClientException(msg)).when(table).put(attrs);
final Region origin = Mockito.mock(Region.class);
Mockito.doReturn(table).when(origin).table(Mockito.anyString());
final Region region = new ReRegion(origin);
try {
region.table("test").put(attrs);
Assert.fail("exception expected here");
} catch (final AmazonClientException ex) {
assert ex.getMessage().equals(msg);
}
Mockito.verify(table, Mockito.times(Tv.THREE)).put(attrs);
}
use of com.jcabi.dynamo.Attributes in project jcabi-dynamo by jcabi.
the class H2DataTest method storesToFile.
/**
* H2Data can store to a file.
* @throws Exception If some problem inside
* @see <a href="https://code.google.com/p/h2database/issues/detail?id=447">
* Google Code: DB file extension customizability</a>
*/
@Test
@Ignore
public void storesToFile() throws Exception {
final File file = this.temp.newFile();
final String table = "tbl";
final String key = "key1";
final MkData data = new H2Data(file).with(table, new String[] { key }, new String[0]);
data.put(table, new Attributes().with(key, "x2"));
MatcherAssert.assertThat(file.exists(), Matchers.is(true));
MatcherAssert.assertThat(file.length(), Matchers.greaterThan(0L));
}
use of com.jcabi.dynamo.Attributes 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));
}
use of com.jcabi.dynamo.Attributes in project jcabi-dynamo by jcabi.
the class MkRegionTest method storesAndReadsSingleAttribute.
/**
* MkRegion can store and read items.
* @throws Exception If some problem inside
*/
@Test
public void storesAndReadsSingleAttribute() throws Exception {
final String table = "ideas";
final String key = "number";
final String attr = "total";
final Region region = new MkRegion(new H2Data().with(table, new String[] { key }, attr));
final Table tbl = region.table(table);
tbl.put(new Attributes().with(key, "32443").with(attr, "0"));
final Item item = tbl.frame().iterator().next();
item.put(attr, new AttributeValueUpdate().withValue(new AttributeValue().withN("2")).withAction(AttributeAction.PUT));
MatcherAssert.assertThat(item.get(attr).getN(), Matchers.equalTo("2"));
}
Aggregations