Search in sources :

Example 21 with TransactionState

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);
}
Also used : TransactionState(com.scalar.db.api.TransactionState) Test(org.junit.jupiter.api.Test)

Example 22 with TransactionState

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);
}
Also used : TransactionState(com.scalar.db.api.TransactionState) Test(org.junit.jupiter.api.Test)

Example 23 with TransactionState

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);
}
Also used : TransactionState(com.scalar.db.api.TransactionState) Test(org.junit.jupiter.api.Test)

Example 24 with TransactionState

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);
}
Also used : TransactionState(com.scalar.db.api.TransactionState) Test(org.junit.jupiter.api.Test)

Example 25 with TransactionState

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);
}
Also used : TransactionState(com.scalar.db.api.TransactionState) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionState (com.scalar.db.api.TransactionState)37 Test (org.junit.jupiter.api.Test)16 Test (org.junit.Test)12 Put (com.scalar.db.api.Put)4 Key (com.scalar.db.io.Key)4 State (com.scalar.db.transaction.consensuscommit.Coordinator.State)4 GrpcTransaction (com.scalar.db.transaction.rpc.GrpcTransaction)3 GrpcTwoPhaseCommitTransaction (com.scalar.db.transaction.rpc.GrpcTwoPhaseCommitTransaction)3 IntValue (com.scalar.db.io.IntValue)2 CommitException (com.scalar.db.exception.transaction.CommitException)1