use of reactor.test.StepVerifier in project cf-java-client by cloudfoundry.
the class PaginationUtilsTest method requestClientV2ResourcesEmpty.
@Test
public void requestClientV2ResourcesEmpty() {
Spaces spaces = mock(Spaces.class, RETURNS_SMART_NULLS);
requestListSpacesEmpty(spaces);
PaginationUtils.requestClientV2Resources(page -> spaces.list(ListSpacesRequest.builder().page(page).build())).as(StepVerifier::create).expectComplete().verify(Duration.ofSeconds(1));
}
use of reactor.test.StepVerifier in project cf-java-client by cloudfoundry.
the class PaginationUtilsTest method requestUaaResourcesEmpty.
@Test
public void requestUaaResourcesEmpty() {
Users users = mock(Users.class, RETURNS_SMART_NULLS);
requestListUsersEmpty(users, 1, 100);
PaginationUtils.requestUaaResources(startIndex -> users.list(ListUsersRequest.builder().startIndex(startIndex).build())).as(StepVerifier::create).expectComplete().verify(Duration.ofSeconds(1));
}
use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class R2dbcTransactionManagerUnitTests method doesNotSetIsolationLevelIfMatch.
@Test
void doesNotSetIsolationLevelIfMatch() {
when(connectionMock.getTransactionIsolationLevel()).thenReturn(IsolationLevel.READ_COMMITTED);
when(connectionMock.commitTransaction()).thenReturn(Mono.empty());
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
definition.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
TransactionalOperator operator = TransactionalOperator.create(tm, definition);
ConnectionFactoryUtils.getConnection(connectionFactoryMock).as(operator::transactional).as(StepVerifier::create).expectNextCount(1).verifyComplete();
verify(connectionMock).beginTransaction();
verify(connectionMock, never()).setTransactionIsolationLevel(any());
verify(connectionMock).commitTransaction();
}
use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class R2dbcTransactionManagerUnitTests method testBeginFails.
@Test
void testBeginFails() {
reset(connectionFactoryMock);
when(connectionFactoryMock.create()).thenReturn(Mono.error(new R2dbcBadGrammarException("fail")));
when(connectionMock.rollbackTransaction()).thenReturn(Mono.empty());
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
definition.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
TransactionalOperator operator = TransactionalOperator.create(tm, definition);
ConnectionFactoryUtils.getConnection(connectionFactoryMock).as(operator::transactional).as(StepVerifier::create).expectErrorSatisfies(actual -> assertThat(actual).isInstanceOf(CannotCreateTransactionException.class).hasCauseInstanceOf(R2dbcBadGrammarException.class)).verify();
}
use of reactor.test.StepVerifier in project spring-framework by spring-projects.
the class R2dbcTransactionManagerUnitTests method testTransactionSetRollbackOnly.
@Test
void testTransactionSetRollbackOnly() {
when(connectionMock.rollbackTransaction()).thenReturn(Mono.empty());
TestTransactionSynchronization sync = new TestTransactionSynchronization(TransactionSynchronization.STATUS_ROLLED_BACK);
TransactionalOperator operator = TransactionalOperator.create(tm);
operator.execute(tx -> {
tx.setRollbackOnly();
assertThat(tx.isNewTransaction()).isTrue();
return TransactionSynchronizationManager.forCurrentTransaction().doOnNext(synchronizationManager -> {
assertThat(synchronizationManager.hasResource(connectionFactoryMock)).isTrue();
synchronizationManager.registerSynchronization(sync);
}).then();
}).as(StepVerifier::create).verifyComplete();
verify(connectionMock).isAutoCommit();
verify(connectionMock).beginTransaction();
verify(connectionMock).rollbackTransaction();
verify(connectionMock).close();
verifyNoMoreInteractions(connectionMock);
assertThat(sync.beforeCommitCalled).isFalse();
assertThat(sync.afterCommitCalled).isFalse();
assertThat(sync.beforeCompletionCalled).isTrue();
assertThat(sync.afterCompletionCalled).isTrue();
}
Aggregations