Skip to content

Commit

Permalink
test: create scenario to return invalid when it is long
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <[email protected]>
  • Loading branch information
otaviojava committed Aug 28, 2024
1 parent 18e14e3 commit 66ec9e4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,4 +436,24 @@ void shouldExecuteExistBy() {
});

}

@Test
void shouldReturnNotSupportedWhenQueryIsNotSelectAsDelete() {
var preparedStatement = Mockito.mock(org.eclipse.jnosql.mapping.semistructured.PreparedStatement.class);
Mockito.when(template.prepare(Mockito.anyString())).thenReturn(preparedStatement);
Mockito.when(template.query(Mockito.anyString()))
.thenReturn(Stream.of(Person.builder().age(26).name("Ada").build()));
Assertions.assertThatThrownBy(() ->people.deleteByNameReturnInt())
.isInstanceOf(UnsupportedOperationException.class);
}

@Test
void shouldReturnNotSupportedWhenQueryIsNotSelectAsUpdate() {
var preparedStatement = Mockito.mock(org.eclipse.jnosql.mapping.semistructured.PreparedStatement.class);
Mockito.when(template.prepare(Mockito.anyString())).thenReturn(preparedStatement);
Mockito.when(template.query(Mockito.anyString()))
.thenReturn(Stream.of(Person.builder().age(26).name("Ada").build()));
Assertions.assertThatThrownBy(() ->people.updateReturnInt())
.isInstanceOf(UnsupportedOperationException.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@ public interface People {
default String defaultMethod() {
return "default";
}

@Query("delete from Person where name = :name")
long deleteByNameReturnInt();

@Query("update Person where name = :name")
long updateReturnInt();
}

0 comments on commit 66ec9e4

Please sign in to comment.