@Before public void setUp() { testUser = new User(); testPlaylistId = new PlaylistId(); testPlaylistId.setUserName("michael"); testPlaylistId.setPlaylistName("playlist1"); testPlaylist = new Playlist(testPlaylistId); when(entityWithSimpleIdInformation.getJavaType()).thenReturn(User.class); when(entityWithSimpleIdInformation.getHashKey(1l)).thenReturn(1l); when(mockEnableScanPermissions.isFindAllUnpaginatedScanEnabled()).thenReturn(true); when(mockEnableScanPermissions.isDeleteAllUnpaginatedScanEnabled()).thenReturn(true); when(mockEnableScanPermissions.isCountUnpaginatedScanEnabled()).thenReturn(true); when(entityWithCompositeIdInformation.getJavaType()).thenReturn(Playlist.class); when(entityWithCompositeIdInformation.getHashKey(testPlaylistId)).thenReturn("michael"); when(entityWithCompositeIdInformation.getRangeKey(testPlaylistId)).thenReturn("playlist1"); when(entityWithCompositeIdInformation.isRangeKeyAware()).thenReturn(true); repoForEntityWithOnlyHashKey = new SimpleDynamoDBCrudRepository<User, Long>( entityWithSimpleIdInformation, dynamoDBOperations, mockEnableScanPermissions); repoForEntityWithHashAndRangeKey = new SimpleDynamoDBCrudRepository<Playlist, PlaylistId>( entityWithCompositeIdInformation, dynamoDBOperations, mockEnableScanPermissions); when(dynamoDBOperations.load(User.class, 1l)).thenReturn(testUser); when(dynamoDBOperations.load(Playlist.class, "michael", "playlist1")).thenReturn(testPlaylist); }
/** @see DATAJPA-177 */ @Test(expected = EmptyResultDataAccessException.class) public void throwsExceptionIfEntityWithHashAndRangeKeyToDeleteDoesNotExist() { PlaylistId playlistId = new PlaylistId(); playlistId.setUserName("someUser"); playlistId.setPlaylistName("somePlaylistName"); repoForEntityWithHashAndRangeKey.delete(playlistId); }