Search in sources :

Example 11 with Value

use of jakarta.nosql.Value in project jnosql-diana by eclipse.

the class DefaultKeyValueEntityTest method shouldReturnErrorWhenGetKeyClassIsNull.

@Test
public void shouldReturnErrorWhenGetKeyClassIsNull() {
    Value value = Value.of("value");
    KeyValueEntity entity = KeyValueEntity.of("10", value);
    assertNotNull(entity);
    Assertions.assertThrows(NullPointerException.class, () -> entity.getKey((Class<Object>) null));
}
Also used : Value(jakarta.nosql.Value) KeyValueEntity(jakarta.nosql.keyvalue.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Example 12 with Value

use of jakarta.nosql.Value in project jnosql-diana by eclipse.

the class DefaultKeyValueEntityTest method shouldReturnErrorWhenGetKeySupplierIsNull.

@Test
public void shouldReturnErrorWhenGetKeySupplierIsNull() {
    Value value = Value.of("value");
    KeyValueEntity entity = KeyValueEntity.of("10", value);
    assertNotNull(entity);
    Assertions.assertThrows(NullPointerException.class, () -> entity.getKey((TypeReference<Object>) null));
}
Also used : Value(jakarta.nosql.Value) TypeReference(jakarta.nosql.TypeReference) KeyValueEntity(jakarta.nosql.keyvalue.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Example 13 with Value

use of jakarta.nosql.Value in project jnosql-diana by eclipse.

the class GetQueryParserTest method shouldExecutePrepareStatement2.

@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "get @id, @id2" })
public void shouldExecutePrepareStatement2(String query) {
    ArgumentCaptor<Object> captor = ArgumentCaptor.forClass(List.class);
    KeyValuePreparedStatement prepare = parser.prepare(query, manager);
    prepare.bind("id", 10);
    prepare.bind("id2", 11);
    final Stream<Value> stream = prepare.getResult();
    stream.collect(Collectors.toList());
    verify(manager, Mockito.times(2)).get(captor.capture());
    List<Object> value = captor.getAllValues();
    assertEquals(2, value.size());
    MatcherAssert.assertThat(value, Matchers.contains(10, 11));
}
Also used : KeyValuePreparedStatement(jakarta.nosql.keyvalue.KeyValuePreparedStatement) Value(jakarta.nosql.Value) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with Value

use of jakarta.nosql.Value in project jnosql-diana by eclipse.

the class ParamValueTest method shouldSetParameter.

@Test
public void shouldSetParameter() {
    Params params = Params.newParams();
    Value name = params.add("name");
    params.bind("name", "Ada Lovelace");
    assertEquals("Ada Lovelace", name.get());
}
Also used : Value(jakarta.nosql.Value) Params(jakarta.nosql.Params) Test(org.junit.jupiter.api.Test)

Example 15 with Value

use of jakarta.nosql.Value in project jnosql-diana by eclipse.

the class ParamValueTest method shouldNotUseValueWhenIsInvalid.

@Test
public void shouldNotUseValueWhenIsInvalid() {
    Params params = Params.newParams();
    Value name = params.add("name");
    assertThrows(QueryException.class, name::get);
    assertThrows(QueryException.class, () -> name.get(String.class));
}
Also used : Value(jakarta.nosql.Value) Params(jakarta.nosql.Params) Test(org.junit.jupiter.api.Test)

Aggregations

Value (jakarta.nosql.Value)66 Test (org.junit.jupiter.api.Test)53 Params (jakarta.nosql.Params)23 List (java.util.List)16 TypeReference (jakarta.nosql.TypeReference)7 KeyValueEntity (jakarta.nosql.keyvalue.KeyValueEntity)7 KeyValuePreparedStatement (jakarta.nosql.keyvalue.KeyValuePreparedStatement)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 QueryException (jakarta.nosql.QueryException)6 Column (jakarta.nosql.column.Column)6 BigInteger (java.math.BigInteger)6 Collectors.toList (java.util.stream.Collectors.toList)6 Stream (java.util.stream.Stream)6 ColumnQuery (jakarta.nosql.column.ColumnQuery)5 Map (java.util.Map)5 ServiceLoaderProvider (jakarta.nosql.ServiceLoaderProvider)4 BucketManager (jakarta.nosql.keyvalue.BucketManager)4 Person (jakarta.nosql.tck.entities.Person)4 Predicate (com.hazelcast.query.Predicate)3 ColumnCondition (jakarta.nosql.column.ColumnCondition)3