Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ThreadLocalRandom;
Expand All @@ -53,13 +54,13 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.springframework.test.context.TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {DynamoDBLocalResource.class, CRUDOperationsIT.TestAppConfig.class})
@TestExecutionListeners(listeners = TableCreationListener.class, mergeMode = MERGE_WITH_DEFAULTS)
@DynamoDBCreateTable(entityClasses = {User.class})
@Ignore
@DynamoDBCreateTable(entityClasses = {User.class, Playlist.class})
public class CRUDOperationsIT {

@Rule
Expand All @@ -74,11 +75,14 @@ public static class TestAppConfig {
private UserRepository userRepository;
@Autowired
private UserPaginationRepository userPaginationRepository;
@Autowired
private PlaylistRepository playlistRepository;

@Before
public void setUp() {
userRepository.deleteAll();
userPaginationRepository.deleteAll();
playlistRepository.deleteAll();
}

@Test
Expand Down Expand Up @@ -188,6 +192,23 @@ public void testDeleteNonExistent() {
userRepository.deleteById("non-existent");
}

@Test
public void testDeleteHashRangeKey() {
// setup
long rnd = ThreadLocalRandom.current().nextLong();
Playlist p = new Playlist();
p.setPlaylistName("playlistName-" + rnd);
p.setUserName("userName-" + rnd);

playlistRepository.save(p);

PlaylistId id = new PlaylistId("userName-" + rnd, "playlistName-" + rnd);
assertTrue("Entity with id not found: " + id, playlistRepository.findById(id).isPresent());

playlistRepository.deleteById(id);
assertFalse("Entity with id not deleted: " + id, playlistRepository.findById(id).isPresent());
}

@Test
public void testFilterAndPagination() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
*/
package org.socialsignin.spring.data.dynamodb.domain.sample;

import org.socialsignin.spring.data.dynamodb.repository.EnableScan;
import org.springframework.data.repository.CrudRepository;

@EnableScan
public interface PlaylistRepository extends CrudRepository<Playlist, PlaylistId> {

}