use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana by eclipse.
the class DefaultKeyValueEntityTest method shouldAliasOnValue.
@Test
public void shouldAliasOnValue() {
String value = "10";
KeyValueEntity entity = KeyValueEntity.of("key", value);
assertEquals(value, entity.getValue());
assertEquals(Integer.valueOf(10), entity.getValue(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 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));
}
use of jakarta.nosql.keyvalue.KeyValueEntity 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));
}
use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana by eclipse.
the class PutQueryParserTest method shouldReturnParserQuery2.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "put {\"Diana\", \"goddess of hunt\", 10 hour}" })
public void shouldReturnParserQuery2(String query) {
ArgumentCaptor<KeyValueEntity> captor = ArgumentCaptor.forClass(KeyValueEntity.class);
ArgumentCaptor<Duration> durationCaptor = ArgumentCaptor.forClass(Duration.class);
parser.query(query, manager);
Mockito.verify(manager).put(captor.capture(), durationCaptor.capture());
KeyValueEntity entity = captor.getValue();
Duration ttl = durationCaptor.getValue();
assertEquals(Duration.ofHours(10), ttl);
assertEquals("Diana", entity.getKey());
assertEquals("goddess of hunt", entity.getValue());
}
use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana by eclipse.
the class DefaultKeyValueEntityConverterTest method shouldConvertToKeyWhenThereIsConverterAnnotation.
@Test
public void shouldConvertToKeyWhenThereIsConverterAnnotation() {
Car car = new Car();
car.setPlate(Plate.of("123-BRL"));
car.setName("Ferrari");
KeyValueEntity entity = converter.toKeyValue(car);
Assertions.assertEquals("123-BRL", entity.getKey());
Assertions.assertEquals(car, entity.getValue());
}
Aggregations