1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package com.jcabi.dynamo;
31
32 import com.jcabi.aspects.Tv;
33 import java.util.Iterator;
34 import org.apache.commons.lang3.RandomStringUtils;
35 import org.hamcrest.MatcherAssert;
36 import org.hamcrest.Matchers;
37 import org.junit.jupiter.api.Assumptions;
38 import org.junit.jupiter.api.BeforeEach;
39 import org.junit.jupiter.api.Test;
40
41
42
43
44
45
46 @SuppressWarnings("PMD.AvoidDuplicateLiterals")
47 final class DynamodbLocalITCase {
48
49 @BeforeEach
50 void itTestCheck() {
51 Assumptions.assumeFalse(
52 System.getProperty("failsafe.ddl.port", "").isEmpty()
53 || System.getProperty("failsafe.ddl.key", "").isEmpty()
54 || System.getProperty("failsafe.ddl.secret", "").isEmpty(),
55 "DynamoDbLocal is not up and running, that's why this test is skipped"
56 );
57 }
58
59 @Test
60 @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
61 void worksWithAmazon() throws Exception {
62 final Table tbl = new Region.Simple(
63 new Credentials.Direct(
64 new Credentials.Simple(
65 System.getProperty("failsafe.ddl.key"),
66 System.getProperty("failsafe.ddl.secret")
67 ),
68 Integer.parseInt(System.getProperty("failsafe.ddl.port"))
69 )
70 ).table("talks");
71 for (int idx = 0; idx < Tv.FIVE; ++idx) {
72 tbl.put(
73 new Attributes()
74 .with("room", idx)
75 .with("title", RandomStringUtils.randomAlphanumeric(Tv.TEN))
76 );
77 }
78 MatcherAssert.assertThat(
79 tbl.frame()
80 .where("room", Conditions.equalTo(0))
81 .through(new QueryValve().withLimit(1)),
82 Matchers.hasSize(1)
83 );
84 MatcherAssert.assertThat(
85 tbl.frame()
86 .where("room", Conditions.equalTo(0))
87 .through(new ScanValve())
88 .iterator().next()
89 .get("room")
90 .getN(),
91 Matchers.equalTo("0")
92 );
93 final Iterator<Item> items = tbl.frame().iterator();
94 items.next();
95 items.remove();
96 }
97
98 }