use of com.scalar.db.api.TransactionState in project scalardb by scalar-labs.
the class ConsensusCommitManagerTest method check_StateIsEmpty_ReturnUnknown.
@Test
public void check_StateIsEmpty_ReturnUnknown() throws CoordinatorException {
// Arrange
when(coordinator.getState(ANY_TX_ID)).thenReturn(Optional.empty());
// Act
TransactionState actual = manager.getState(ANY_TX_ID);
// Assert
assertThat(actual).isEqualTo(TransactionState.UNKNOWN);
}
use of com.scalar.db.api.TransactionState in project scalardb by scalar-labs.
the class ConsensusCommitManagerTest method abort_CommitHandlerReturnsAborted_ShouldReturnTheState.
@Test
public void abort_CommitHandlerReturnsAborted_ShouldReturnTheState() throws UnknownTransactionStatusException {
// Arrange
TransactionState expected = TransactionState.ABORTED;
when(commit.abort(ANY_TX_ID)).thenReturn(expected);
// Act
TransactionState actual = manager.abort(ANY_TX_ID);
// Assert
assertThat(actual).isEqualTo(expected);
}
use of com.scalar.db.api.TransactionState in project scalardb by scalar-labs.
the class ConsensusCommitManagerTest method abort_CommitHandlerReturnsCommitted_ShouldReturnTheState.
@Test
public void abort_CommitHandlerReturnsCommitted_ShouldReturnTheState() throws UnknownTransactionStatusException {
// Arrange
TransactionState expected = TransactionState.COMMITTED;
when(commit.abort(ANY_TX_ID)).thenReturn(expected);
// Act
TransactionState actual = manager.abort(ANY_TX_ID);
// Assert
assertThat(actual).isEqualTo(expected);
}
use of com.scalar.db.api.TransactionState in project scalardb by scalar-labs.
the class TwoPhaseConsensusCommitManagerTest method check_StateIsEmpty_ReturnUnknown.
@Test
public void check_StateIsEmpty_ReturnUnknown() throws CoordinatorException {
// Arrange
when(coordinator.getState(ANY_TX_ID)).thenReturn(Optional.empty());
// Act
TransactionState actual = manager.getState(ANY_TX_ID);
// Assert
assertThat(actual).isEqualTo(TransactionState.UNKNOWN);
}
use of com.scalar.db.api.TransactionState in project scalardb by scalar-labs.
the class TwoPhaseConsensusCommitManagerTest method abort_CommitHandlerThrowsUnknownTransactionStatusException_ShouldReturnUnknown.
@Test
public void abort_CommitHandlerThrowsUnknownTransactionStatusException_ShouldReturnUnknown() throws UnknownTransactionStatusException {
// Arrange
when(commit.abort(ANY_TX_ID)).thenThrow(UnknownTransactionStatusException.class);
// Act
TransactionState actual = manager.abort(ANY_TX_ID);
// Assert
assertThat(actual).isEqualTo(TransactionState.UNKNOWN);
}
Aggregations