Skip to content

Commit 1fb60f2

Browse files
committed
test: increate arangodb tests
Signed-off-by: Otavio Santana <[email protected]>
1 parent 21be392 commit 1fb60f2

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/mapping/ArangoDBDocumentRepositoryProxyTest.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ public class ArangoDBDocumentRepositoryProxyTest {
6565

6666
private PersonRepository personRepository;
6767

68+
@SuppressWarnings("rawtypes")
6869
@BeforeEach
6970
public void setUp() {
7071
this.template = Mockito.mock(ArangoDBTemplate.class);
7172

7273
PersonRepository personRepository = producer.get(PersonRepository.class, template);
73-
ArangoDBDocumentRepositoryProxy handler = new ArangoDBDocumentRepositoryProxy(template,
74+
ArangoDBDocumentRepositoryProxy handler = new ArangoDBDocumentRepositoryProxy<>(template,
7475
PersonRepository.class, personRepository, converters, entitiesMetadata);
7576

7677
when(template.insert(any(Person.class))).thenReturn(new Person());
@@ -98,6 +99,28 @@ public void shouldFindByNameAQL() {
9899
assertEquals("Ada", value.get("name"));
99100
}
100101

102+
@Test
103+
public void shouldSave() {
104+
Person person = Person.of("Ada", 10);
105+
personRepository.save(person);
106+
verify(template).insert(eq(person));
107+
}
108+
109+
@Test
110+
public void shouldDelete(){
111+
personRepository.deleteById("id");
112+
verify(template).delete(Person.class, "id");
113+
}
114+
115+
116+
@Test
117+
public void shouldDeleteEntity(){
118+
Person person = Person.of("Ada", 10);
119+
personRepository.delete(person);
120+
verify(template).delete(Person.class, person.getName());
121+
}
122+
123+
101124
interface PersonRepository extends ArangoDBRepository<Person, String> {
102125

103126
@AQL("FOR p IN Person RETURN p")

jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/mapping/Person.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,13 @@ public int hashCode() {
7070

7171
@Override
7272
public String toString() {
73-
String sb = "Person{" + "name='" + name + '\'' +
73+
return "Person{" +
74+
"name='" + name + '\'' +
7475
", age=" + age +
7576
'}';
76-
return sb;
77+
}
78+
79+
public static Person of(String name, Integer age) {
80+
return new Person(name, age);
7781
}
7882
}

0 commit comments

Comments
 (0)