[JAVA-23452] Clean up
This commit is contained in:
parent
55296d07f4
commit
35be82141f
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>aws-dynamodb</artifactId>
|
<artifactId>aws-dynamodb</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
@ -16,14 +16,9 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>com.amazonaws</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>aws-java-sdk</artifactId>
|
||||||
<version>${commons-io.version}</version>
|
<version>${aws-java-sdk.version}</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
<version>${gson.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.amazonaws</groupId>
|
<groupId>com.amazonaws</groupId>
|
||||||
@ -32,9 +27,14 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.amazonaws</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>aws-java-sdk-dynamodb</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>${aws-java-sdk.version}</version>
|
<version>${commons-io.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>${gson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -81,8 +81,6 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<gson.version>2.8.0</gson.version>
|
<gson.version>2.8.0</gson.version>
|
||||||
<dynamodblocal.version>1.21.1</dynamodblocal.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>
|
<maven-plugins-version>3.1.1</maven-plugins-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
db_hostname=<RDS EndPoint>
|
|
||||||
db_username=username
|
|
||||||
db_password=password
|
|
||||||
db_database=mydb
|
|
@ -29,7 +29,7 @@ import static org.hamcrest.core.Is.is;
|
|||||||
import static org.hamcrest.core.IsEqual.equalTo;
|
import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
public class ProductInfoRepositoryUnitTest {
|
public class ProductInfoRepositoryIntegrationTest {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static LocalDbCreationRule dynamoDB = new LocalDbCreationRule();
|
public static LocalDbCreationRule dynamoDB = new LocalDbCreationRule();
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
package com.baeldung.dynamodb.repository;
|
|
||||||
|
|
||||||
import com.baeldung.dynamodb.entity.ProductInfo;
|
|
||||||
|
|
||||||
public class ProductInfoRepository extends AbstractRepository<ProductInfo, String> {
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user