use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class InsertQueryParserTest method shouldExecutePrepareStatement.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert God (name = @name)" })
public void shouldExecutePrepareStatement(String query) {
ArgumentCaptor<DocumentEntity> captor = ArgumentCaptor.forClass(DocumentEntity.class);
DocumentPreparedStatement prepare = parser.prepare(query, manager, observer);
prepare.bind("name", "Diana");
prepare.getResult();
Mockito.verify(manager).insert(captor.capture());
DocumentEntity entity = captor.getValue();
assertEquals("God", entity.getName());
assertEquals(Document.of("name", "Diana"), entity.find("name").get());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class InsertQueryParserTest method shouldReturnParserQuery4.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert God (name = \"Diana\") 10 minute" })
public void shouldReturnParserQuery4(String query) {
ArgumentCaptor<DocumentEntity> captor = ArgumentCaptor.forClass(DocumentEntity.class);
ArgumentCaptor<Duration> durationCaptor = ArgumentCaptor.forClass(Duration.class);
parser.query(query, manager, observer);
Mockito.verify(manager).insert(captor.capture(), durationCaptor.capture());
DocumentEntity entity = captor.getValue();
Duration duration = durationCaptor.getValue();
assertEquals("God", entity.getName());
assertEquals(Document.of("name", "Diana"), entity.find("name").get());
assertEquals(Duration.ofMinutes(10L), duration);
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class InsertQueryParserTest method shouldReturnParserQuery5.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert God (name = \"Diana\") 10 second" })
public void shouldReturnParserQuery5(String query) {
ArgumentCaptor<DocumentEntity> captor = ArgumentCaptor.forClass(DocumentEntity.class);
ArgumentCaptor<Duration> durationCaptor = ArgumentCaptor.forClass(Duration.class);
parser.query(query, manager, observer);
Mockito.verify(manager).insert(captor.capture(), durationCaptor.capture());
DocumentEntity entity = captor.getValue();
Duration duration = durationCaptor.getValue();
assertEquals("God", entity.getName());
assertEquals(Document.of("name", "Diana"), entity.find("name").get());
assertEquals(Duration.ofSeconds(10L), duration);
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class InsertQueryParserTest method shouldReturnParserQuery8.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert Person {\"name\":\"Ada Lovelace\"}" })
public void shouldReturnParserQuery8(String query) {
ArgumentCaptor<DocumentEntity> captor = ArgumentCaptor.forClass(DocumentEntity.class);
parser.query(query, manager, observer);
Mockito.verify(manager).insert(captor.capture());
DocumentEntity entity = captor.getValue();
assertEquals("Person", entity.getName());
assertEquals(Document.of("name", "Ada Lovelace"), entity.find("name").get());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class InsertQueryParserTest method shouldReturnParserQuery3.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert God (name = \"Diana\") 10 hour" })
public void shouldReturnParserQuery3(String query) {
ArgumentCaptor<DocumentEntity> captor = ArgumentCaptor.forClass(DocumentEntity.class);
ArgumentCaptor<Duration> durationCaptor = ArgumentCaptor.forClass(Duration.class);
parser.query(query, manager, observer);
Mockito.verify(manager).insert(captor.capture(), durationCaptor.capture());
DocumentEntity entity = captor.getValue();
Duration duration = durationCaptor.getValue();
assertEquals("God", entity.getName());
assertEquals(Document.of("name", "Diana"), entity.find("name").get());
assertEquals(Duration.ofHours(10L), duration);
}
Aggregations