use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class R2dbcTransactionManagerUnitTests method restoresAutoCommit.
@Test
void restoresAutoCommit() {
when(connectionMock.isAutoCommit()).thenReturn(true);
when(connectionMock.setAutoCommit(anyBoolean())).thenReturn(Mono.empty());
when(connectionMock.commitTransaction()).thenReturn(Mono.empty());
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
TransactionalOperator operator = TransactionalOperator.create(tm, definition);
ConnectionFactoryUtils.getConnection(connectionFactoryMock).as(operator::transactional).as(StepVerifier::create).expectNextCount(1).verifyComplete();
verify(connectionMock).beginTransaction();
verify(connectionMock).setAutoCommit(false);
verify(connectionMock).setAutoCommit(true);
verify(connectionMock).commitTransaction();
verify(connectionMock).close();
}
use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class DefaultDatabaseClientUnitTests method selectShouldEmitAllValues.
@Test
void selectShouldEmitAllValues() {
MockRowMetadata metadata = MockRowMetadata.builder().columnMetadata(MockColumnMetadata.builder().name("name").javaType(String.class).build()).build();
MockResult result = MockResult.builder().row(MockRow.builder().identified(0, Object.class, "Walter").metadata(metadata).build(), MockRow.builder().identified(0, Object.class, "White").metadata(metadata).build()).build();
mockStatementFor("SELECT * FROM person", result);
DatabaseClient databaseClient = databaseClientBuilder.build();
databaseClient.sql("SELECT * FROM person").map(row -> row.get(0)).all().as(StepVerifier::create).expectNext("Walter").expectNext("White").verifyComplete();
}
use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class DefaultDatabaseClientUnitTests method shouldApplyStatementFilterFunctions.
@Test
void shouldApplyStatementFilterFunctions() {
MockResult result = MockResult.builder().build();
Statement statement = mockStatement(result);
DatabaseClient databaseClient = databaseClientBuilder.build();
databaseClient.sql("SELECT").filter((s, next) -> next.execute(s.returnGeneratedValues("foo"))).filter((s, next) -> next.execute(s.returnGeneratedValues("bar"))).fetch().all().as(StepVerifier::create).verifyComplete();
InOrder inOrder = inOrder(statement);
inOrder.verify(statement).returnGeneratedValues("foo");
inOrder.verify(statement).returnGeneratedValues("bar");
inOrder.verify(statement).execute();
inOrder.verifyNoMoreInteractions();
}
use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class DefaultDatabaseClientUnitTests method shouldApplySimpleStatementFilterFunctions.
@Test
void shouldApplySimpleStatementFilterFunctions() {
MockResult result = mockSingleColumnEmptyResult();
Statement statement = mockStatement(result);
DatabaseClient databaseClient = databaseClientBuilder.build();
databaseClient.sql("SELECT").filter(s -> s.returnGeneratedValues("foo")).filter(s -> s.returnGeneratedValues("bar")).fetch().all().as(StepVerifier::create).verifyComplete();
InOrder inOrder = inOrder(statement);
inOrder.verify(statement).returnGeneratedValues("foo");
inOrder.verify(statement).returnGeneratedValues("bar");
inOrder.verify(statement).execute();
inOrder.verifyNoMoreInteractions();
}
use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class DefaultDatabaseClientUnitTests method shouldApplyPreparedOperation.
@Test
void shouldApplyPreparedOperation() {
MockResult result = mockSingleColumnResult(MockRow.builder().identified(0, Object.class, "Walter"));
Statement statement = mockStatementFor("SELECT * FROM person", result);
DatabaseClient databaseClient = databaseClientBuilder.build();
databaseClient.sql(new PreparedOperation<String>() {
@Override
public String toQuery() {
return "SELECT * FROM person";
}
@Override
public String getSource() {
return "SELECT";
}
@Override
public void bindTo(BindTarget target) {
target.bind("index", "value");
}
}).fetch().all().as(StepVerifier::create).expectNextCount(1).verifyComplete();
verify(statement).bind("index", "value");
}
Aggregations