[JAVA-23452] Clean up

This commit is contained in:
panos-kakos 2023-10-07 18:58:23 +03:00
parent 55296d07f4
commit 35be82141f
6 changed files with 14 additions and 126 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>aws-dynamodb</artifactId>
<version>0.1.0-SNAPSHOT</version>
@ -16,14 +16,9 @@
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>${aws-java-sdk.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
@ -32,9 +27,14 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
<version>${aws-java-sdk.version}</version>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
</dependencies>
@ -81,8 +81,6 @@
<properties>
<gson.version>2.8.0</gson.version>
<dynamodblocal.version>1.21.1</dynamodblocal.version>
<commons-codec-version>1.10.L001</commons-codec-version>
<jets3t-version>0.9.4.0006L</jets3t-version>
<maven-plugins-version>3.1.1</maven-plugins-version>
</properties>

View File

@ -1,4 +0,0 @@
db_hostname=<RDS EndPoint>
db_username=username
db_password=password
db_database=mydb

View File

@ -29,7 +29,7 @@ import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
public class ProductInfoRepositoryUnitTest {
public class ProductInfoRepositoryIntegrationTest {
@ClassRule
public static LocalDbCreationRule dynamoDB = new LocalDbCreationRule();

View File

@ -1,51 +0,0 @@
package com.baeldung.dynamodb.entity;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
@DynamoDBTable(tableName = "ProductInfo")
public class ProductInfo {
private String id;
private String msrp;
private String cost;
public ProductInfo() {
}
public ProductInfo(String cost, String msrp) {
this.msrp = msrp;
this.cost = cost;
}
@DynamoDBHashKey
@DynamoDBAutoGeneratedKey
public String getId() {
return id;
}
@DynamoDBAttribute
public String getMsrp() {
return msrp;
}
@DynamoDBAttribute
public String getCost() {
return cost;
}
public void setId(String id) {
this.id = id;
}
public void setMsrp(String msrp) {
this.msrp = msrp;
}
public void setCost(String cost) {
this.cost = cost;
}
}

View File

@ -1,49 +0,0 @@
package com.baeldung.dynamodb.repository;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.util.List;
public abstract class AbstractRepository<T, ID extends Serializable> {
protected DynamoDBMapper mapper;
protected Class<T> entityClass;
protected AbstractRepository() {
ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();
// This entityClass refers to the actual entity class in the subclass declaration.
// For instance, ProductInfoDAO extends AbstractDAO<ProductInfo, String>
// In this case entityClass = ProductInfo, and ID is String type
// which refers to the ProductInfo's partition key string value
this.entityClass = (Class<T>) genericSuperclass.getActualTypeArguments()[0];
}
public void save(T t) {
mapper.save(t);
}
public T findOne(ID id) {
return mapper.load(entityClass, id);
}
/**
* <strong>WARNING:</strong> It is not recommended to perform full table scan
* targeting the real production environment.
*
* @return All items
*/
public List<T> findAll() {
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
return mapper.scan(entityClass, scanExpression);
}
public void setMapper(DynamoDBMapper dynamoDBMapper) {
this.mapper = dynamoDBMapper;
}
}

View File

@ -1,6 +0,0 @@
package com.baeldung.dynamodb.repository;
import com.baeldung.dynamodb.entity.ProductInfo;
public class ProductInfoRepository extends AbstractRepository<ProductInfo, String> {
}