Skip to content

Commit

Permalink
arangodb#250 deleteById by contract must not throw an exception for u…
Browse files Browse the repository at this point in the history
…nknown id
  • Loading branch information
aburmeis authored and rashtao committed Aug 31, 2023
1 parent b7ba570 commit 762276c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.arangodb.springframework.core.util.AqlUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.InvalidDataAccessResourceUsageException;
import org.springframework.data.domain.*;
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.repository.query.FluentQuery;
Expand Down Expand Up @@ -155,7 +156,11 @@ public long count() {
*/
@Override
public void deleteById(final ID id) {
arangoOperations.delete(id, domainClass);
try {
arangoOperations.delete(id, domainClass);
} catch (InvalidDataAccessResourceUsageException notFound) {
// ignored by contract
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.*;

import org.junit.jupiter.api.Test;
import org.springframework.data.domain.*;
Expand Down Expand Up @@ -90,6 +86,7 @@ public void deleteByIdTest() {
repository.deleteById(johnId);
assertThat(repository.existsById(bob.getId()), equalTo(true));
assertThat(repository.existsById(johnId), equalTo(false));
repository.deleteById("12345678");
}

@Test
Expand Down

0 comments on commit 762276c

Please sign in to comment.