Skip to content

Commit

Permalink
test: create query scenario
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Sep 25, 2023
1 parent 04392b7 commit e524aea
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,28 @@ public void shouldReturnParserQuery29(String query) {
assertEquals(LocalDate.class, params[1]);
}

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = {"select * from my-prefix-user where user_id = 123"})
public void shouldReturnParserQuery30(String query) {
DefaultSelectQuery selectQuery = selectQueryConverter.apply(query);

assertEquals("my-prefix-user", selectQuery.entity());
assertTrue(selectQuery.fields().isEmpty());
assertTrue(selectQuery.orderBy().isEmpty());
assertEquals(0, selectQuery.limit());
assertEquals(0, selectQuery.skip());
assertTrue(selectQuery.where().isPresent());

Where where = selectQuery.where().get();
QueryCondition condition = where.condition();
QueryValue<?> value = condition.value();
Assertions.assertEquals(Condition.EQUALS, condition.condition());
assertEquals("user_id", condition.name());
assertTrue(value instanceof NumberQueryValue);
Number result = NumberQueryValue.class.cast(value).get();
assertThat(result).isEqualTo(123L);
}



private DefaultSelectQuery checkSelectFromStart(String query) {
Expand Down

0 comments on commit e524aea

Please sign in to comment.