use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana by eclipse.
the class DefaultKeyValueEntityTest method shouldCreateInstance.
@Test
public void shouldCreateInstance() {
KeyValueEntity entity = KeyValueEntity.of("key", "value");
assertNotNull(entity);
assertEquals("key", entity.getKey());
assertEquals("value", entity.getValue());
}
use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana by eclipse.
the class DefaultKeyValueEntityTest method shouldGetKeyValueSupplier.
@Test
public void shouldGetKeyValueSupplier() {
String value = "10";
KeyValueEntity entity = KeyValueEntity.of(value, value);
assertEquals(value, entity.getValue());
assertEquals(Integer.valueOf(10), entity.getKey(Integer.class));
assertThat(singletonList(10), Matchers.contains(entity.getValue(new TypeReference<List<Integer>>() {
}).get(0)));
}
use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana by eclipse.
the class DefaultKeyValueEntityTest method shouldGetKeyClass.
@Test
public void shouldGetKeyClass() {
Value value = Value.of("value");
KeyValueEntity entity = KeyValueEntity.of("10", value);
assertNotNull(entity);
assertEquals(Long.valueOf(10L), entity.getKey(Long.class));
}
use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana by eclipse.
the class DefaultKeyValueQueryParserTest method shouldExecutePrepareStatement2.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "put {\"Diana\", @value, 10 second}" })
public void shouldExecutePrepareStatement2(String query) {
KeyValuePreparedStatement prepare = parser.prepare(query, manager);
prepare.bind("value", "Hunt");
prepare.getResult();
ArgumentCaptor<KeyValueEntity> captor = ArgumentCaptor.forClass(KeyValueEntity.class);
ArgumentCaptor<Duration> durationCaptor = ArgumentCaptor.forClass(Duration.class);
Mockito.verify(manager).put(captor.capture(), durationCaptor.capture());
KeyValueEntity entity = captor.getValue();
final Duration duration = durationCaptor.getValue();
assertEquals("Diana", entity.getKey());
assertEquals("Hunt", entity.getValue());
assertEquals(Duration.ofSeconds(10L), duration);
}
use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana by eclipse.
the class DefaultKeyValueQueryParserTest method shouldExecutePrepareStatement1.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "put {\"Diana\", @value}" })
public void shouldExecutePrepareStatement1(String query) {
KeyValuePreparedStatement prepare = parser.prepare(query, manager);
prepare.bind("value", "Hunt");
prepare.getResult();
ArgumentCaptor<KeyValueEntity> captor = ArgumentCaptor.forClass(KeyValueEntity.class);
Mockito.verify(manager).put(captor.capture());
KeyValueEntity entity = captor.getValue();
assertEquals("Diana", entity.getKey());
assertEquals("Hunt", entity.getValue());
}
Aggregations