[framework] TxCore → common-framework (ACM-FW-001)
This commit is contained in:
parent
bcc27280dc
commit
a40de37bcd
1 changed files with 50 additions and 0 deletions
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.klaro.acquirecore.framework;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class TxContextTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void defaultConstructorSetsInitialState() {
|
||||||
|
TxContext ctx = new TxContext();
|
||||||
|
assertNotNull(ctx.getTransactionId());
|
||||||
|
assertEquals(TxStatus.INITIAL, ctx.getStatus());
|
||||||
|
assertNotNull(ctx.getStartedAt());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void constructorWithServiceName() {
|
||||||
|
TxContext ctx = new TxContext("myService");
|
||||||
|
assertEquals("myService", ctx.getServiceName());
|
||||||
|
assertEquals(TxStatus.INITIAL, ctx.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void markCommittedUpdatesStatusAndTimestamp() {
|
||||||
|
TxContext ctx = new TxContext();
|
||||||
|
assertNull(ctx.getCommittedAt());
|
||||||
|
ctx.markCommitted();
|
||||||
|
assertEquals(TxStatus.COMMITTED, ctx.getStatus());
|
||||||
|
assertNotNull(ctx.getCommittedAt());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void markRolledBackUpdatesStatus() {
|
||||||
|
TxContext ctx = new TxContext();
|
||||||
|
ctx.markRolledBack();
|
||||||
|
assertEquals(TxStatus.ROLLED_BACK, ctx.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void settersAndGetters() {
|
||||||
|
TxContext ctx = new TxContext();
|
||||||
|
ctx.setTransactionId("tx-123");
|
||||||
|
ctx.setServiceName("testService");
|
||||||
|
ctx.setStatus(TxStatus.ACTIVE);
|
||||||
|
assertEquals("tx-123", ctx.getTransactionId());
|
||||||
|
assertEquals("testService", ctx.getServiceName());
|
||||||
|
assertEquals(TxStatus.ACTIVE, ctx.getStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in a new issue