Skip to content

Commit

Permalink
#113 clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 13, 2022
1 parent dbcfd8c commit 127a5cc
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 48 deletions.
20 changes: 5 additions & 15 deletions src/main/java/com/jcabi/dynamo/AttributeUpdates.java
Expand Up @@ -94,7 +94,7 @@ public AttributeUpdates(final Map<String, AttributeValueUpdate> map) {
public AttributeUpdates with(final String name,
final AttributeValueUpdate value) {
return new AttributeUpdates(
this.attrs.with(String.format(Locale.ENGLISH, name), value)
this.attrs.with(name, value)
);
}

Expand Down Expand Up @@ -136,15 +136,9 @@ public AttributeUpdates with(final String name, final Object value) {
* @return AttributeUpdates
*/
public AttributeUpdates with(final Map<String, AttributeValueUpdate> map) {
final ConcurrentMap<String, AttributeValueUpdate> attribs =
final Map<String, AttributeValueUpdate> attribs =
new ConcurrentHashMap<>(map.size());
for (final Map.Entry<String, AttributeValueUpdate> entry
: map.entrySet()) {
attribs.put(
String.format(Locale.ENGLISH, entry.getKey()),
entry.getValue()
);
}
attribs.putAll(map);
return new AttributeUpdates(this.attrs.with(attribs));
}

Expand Down Expand Up @@ -177,9 +171,7 @@ public boolean isEmpty() {

@Override
public boolean containsKey(final Object key) {
return this.attrs.containsKey(
String.format(Locale.ENGLISH, key.toString())
);
return this.attrs.containsKey(key.toString());
}

@Override
Expand All @@ -189,9 +181,7 @@ public boolean containsValue(final Object value) {

@Override
public AttributeValueUpdate get(final Object key) {
return this.attrs.get(
String.format(Locale.ENGLISH, key.toString())
);
return this.attrs.get(key.toString());
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/jcabi/dynamo/AwsItem.java
Expand Up @@ -110,7 +110,7 @@ final class AwsItem implements Item {

@Override
public boolean has(final String attr) throws IOException {
final String attrib = String.format(Locale.ENGLISH, attr);
final String attrib = attr;
boolean has = this.attributes.containsKey(attrib);
if (!has) {
final AmazonDynamoDB aws = this.credentials.aws();
Expand Down Expand Up @@ -144,7 +144,7 @@ public boolean has(final String attr) throws IOException {

@Override
public AttributeValue get(final String attr) throws IOException {
final String attrib = String.format(Locale.ENGLISH, attr);
final String attrib = attr;
AttributeValue value = this.attributes.get(attrib);
if (value == null) {
final AmazonDynamoDB aws = this.credentials.aws();
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/com/jcabi/dynamo/Conditions.java
Expand Up @@ -283,12 +283,7 @@ private static ArrayMap<String, Condition> array(
final Map<String, Condition> map) {
final ConcurrentMap<String, Condition> cnds =
new ConcurrentHashMap<>(map.size());
for (final Map.Entry<String, Condition> entry : map.entrySet()) {
cnds.put(
entry.getKey(),
entry.getValue()
);
}
cnds.putAll(map);
return new ArrayMap<>(cnds);
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/jcabi/dynamo/mock/H2Data.java
Expand Up @@ -360,9 +360,8 @@ public H2Data with(final String table, final String[] keys,
/**
* Make data source.
* @return Data source for JDBC
* @throws SQLException If fails
*/
private DataSource connection() throws SQLException {
private DataSource connection() {
final JdbcDataSource src = new JdbcDataSource();
src.setURL(this.jdbc);
return src;
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/jcabi/dynamo/AttributeUpdatesTest.java
Expand Up @@ -67,8 +67,8 @@ public void tellsIfEmptyOrNot() {
*/
@Test
public void addsAttributeValueUpdate() {
MatcherAssert.assertThat(0, Matchers.is(0));
final AttributeUpdates attr = new AttributeUpdates();
MatcherAssert.assertThat(attr.size(), Matchers.is(0));
MatcherAssert.assertThat(
attr.with("testkey1", Mockito.mock(AttributeValueUpdate.class))
.size(),
Expand All @@ -81,8 +81,8 @@ public void addsAttributeValueUpdate() {
*/
@Test
public void addsAttributeValue() {
MatcherAssert.assertThat(0, Matchers.is(0));
final AttributeUpdates attr = new AttributeUpdates();
MatcherAssert.assertThat(attr.size(), Matchers.is(0));
MatcherAssert.assertThat(
attr.with("testkey2", Mockito.mock(AttributeValue.class)).size(),
Matchers.is(1)
Expand All @@ -94,8 +94,8 @@ public void addsAttributeValue() {
*/
@Test
public void addsObject() {
MatcherAssert.assertThat(0, Matchers.is(0));
final AttributeUpdates attr = new AttributeUpdates();
MatcherAssert.assertThat(attr.size(), Matchers.is(0));
MatcherAssert.assertThat(
attr.with("testkey3", "value here").size(),
Matchers.is(1)
Expand Down
12 changes: 4 additions & 8 deletions src/test/java/com/jcabi/dynamo/AttributesTest.java
Expand Up @@ -49,10 +49,9 @@ public final class AttributesTest {

/**
* Attributes can work as a map of attributes.
* @throws Exception If some problem inside
*/
@Test
public void workAsMapOfAttributes() throws Exception {
public void workAsMapOfAttributes() {
final String attr = "id";
final AttributeValue value = new AttributeValue("some text value");
final Map<String, AttributeValue> attrs = new Attributes()
Expand All @@ -67,10 +66,9 @@ public void workAsMapOfAttributes() throws Exception {

/**
* Attributes can build expected keys.
* @throws Exception If some problem inside
*/
@Test
public void buildsExpectedKeys() throws Exception {
public void buildsExpectedKeys() {
final String attr = "attr-13";
final String value = "some value \u20ac";
MatcherAssert.assertThat(
Expand All @@ -84,10 +82,9 @@ public void buildsExpectedKeys() throws Exception {

/**
* Attributes can filter out unnecessary keys.
* @throws Exception If some problem inside
*/
@Test
public void filtersOutUnnecessaryKeys() throws Exception {
public void filtersOutUnnecessaryKeys() {
MatcherAssert.assertThat(
new Attributes()
.with("first", "test-1")
Expand All @@ -100,10 +97,9 @@ public void filtersOutUnnecessaryKeys() throws Exception {

/**
* Attributes should be case-sensitive.
* @throws Exception If some problem inside
*/
@Test
public void caseSensitive() throws Exception {
public void caseSensitive() {
final String first = "Alpha";
final String second = "AlPha";
final String third = "Beta";
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/com/jcabi/dynamo/AwsItemTest.java
Expand Up @@ -45,10 +45,9 @@ public final class AwsItemTest {

/**
* AwsTable can compare to itself.
* @throws Exception If some problem inside
*/
@Test
public void comparesToItself() throws Exception {
public void comparesToItself() {
final Credentials creds = new Credentials.Simple("key", "secret");
final Region region = new Region.Simple(creds);
final AwsTable table = new AwsTable(creds, region, "table-name");
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/com/jcabi/dynamo/ConditionsTest.java
Expand Up @@ -46,10 +46,9 @@ public final class ConditionsTest {

/**
* Conditions can work as a map of conditions.
* @throws Exception If some problem inside
*/
@Test
public void workAsMapOfConditions() throws Exception {
public void workAsMapOfConditions() {
final String name = "id";
final Condition condition = new Condition();
final Map<String, Condition> conds = new Conditions()
Expand Down
6 changes: 2 additions & 4 deletions src/test/java/com/jcabi/dynamo/CredentialsTest.java
Expand Up @@ -43,10 +43,9 @@ public final class CredentialsTest {

/**
* Credentials can instantiate AWS client.
* @throws Exception If some problem inside
*/
@Test
public void instantiatesAwsClient() throws Exception {
public void instantiatesAwsClient() {
final Credentials creds = new Credentials.Simple(
"ABABABABABABABABABEF",
"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCEF"
Expand All @@ -56,10 +55,9 @@ public void instantiatesAwsClient() throws Exception {

/**
* Credentials can instantiate AWS client with custom region.
* @throws Exception If some problem inside
*/
@Test
public void instantiatesAwsClientWithCustomRegion() throws Exception {
public void instantiatesAwsClientWithCustomRegion() {
final Credentials creds = new Credentials.Simple(
"ABABABABABABABABABAB",
"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE",
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/com/jcabi/dynamo/RegionTest.java
Expand Up @@ -42,10 +42,9 @@ public final class RegionTest {

/**
* Region.Prefixed can add prefix to table names.
* @throws Exception If some problem inside
*/
@Test
public void appendsPrefixesToTableNames() throws Exception {
public void appendsPrefixesToTableNames() {
final Table table = Mockito.mock(Table.class);
final Region region = Mockito.mock(Region.class);
Mockito.doReturn(table).when(region).table(Mockito.anyString());
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/com/jcabi/dynamo/ThroughputTest.java
Expand Up @@ -43,10 +43,9 @@
public class ThroughputTest {
/**
* Throughput can change throughput of a table.
* @throws Exception If something went wrong
*/
@Test
public final void adjustsThroughput() throws Exception {
public final void adjustsThroughput() {
final Table table = Mockito.mock(Table.class);
final Region region = Mockito.mock(Region.class);
final AmazonDynamoDB aws = Mockito.mock(AmazonDynamoDB.class);
Expand Down

0 comments on commit 127a5cc

Please sign in to comment.