4242import java .time .Instant ;
4343import java .util .ArrayList ;
4444import java .util .Arrays ;
45+ import java .util .Collections ;
4546import java .util .List ;
4647import java .util .Optional ;
4748import java .util .concurrent .ThreadLocalRandom ;
5354import static org .junit .Assert .assertNotNull ;
5455import static org .junit .Assert .assertNull ;
5556import static org .junit .Assert .assertThat ;
57+ import static org .junit .Assert .assertTrue ;
5658import static org .springframework .test .context .TestExecutionListeners .MergeMode .MERGE_WITH_DEFAULTS ;
5759
5860@ RunWith (SpringJUnit4ClassRunner .class )
5961@ ContextConfiguration (classes = {DynamoDBLocalResource .class , CRUDOperationsIT .TestAppConfig .class })
6062@ TestExecutionListeners (listeners = TableCreationListener .class , mergeMode = MERGE_WITH_DEFAULTS )
61- @ DynamoDBCreateTable (entityClasses = {User .class })
62- @ Ignore
63+ @ DynamoDBCreateTable (entityClasses = {User .class , Playlist .class })
6364public class CRUDOperationsIT {
6465
6566 @ Rule
@@ -74,11 +75,14 @@ public static class TestAppConfig {
7475 private UserRepository userRepository ;
7576 @ Autowired
7677 private UserPaginationRepository userPaginationRepository ;
78+ @ Autowired
79+ private PlaylistRepository playlistRepository ;
7780
7881 @ Before
7982 public void setUp () {
8083 userRepository .deleteAll ();
8184 userPaginationRepository .deleteAll ();
85+ playlistRepository .deleteAll ();
8286 }
8387
8488 @ Test
@@ -188,6 +192,23 @@ public void testDeleteNonExistent() {
188192 userRepository .deleteById ("non-existent" );
189193 }
190194
195+ @ Test
196+ public void testDeleteHashRangeKey () {
197+ // setup
198+ long rnd = ThreadLocalRandom .current ().nextLong ();
199+ Playlist p = new Playlist ();
200+ p .setPlaylistName ("playlistName-" + rnd );
201+ p .setUserName ("userName-" + rnd );
202+
203+ playlistRepository .save (p );
204+
205+ PlaylistId id = new PlaylistId ("userName-" + rnd , "playlistName-" + rnd );
206+ assertTrue ("Entity with id not found: " + id , playlistRepository .findById (id ).isPresent ());
207+
208+ playlistRepository .deleteById (id );
209+ assertFalse ("Entity with id not deleted: " + id , playlistRepository .findById (id ).isPresent ());
210+ }
211+
191212 @ Test
192213 public void testFilterAndPagination () {
193214
0 commit comments