package com.common.service; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertThrows; class FactWriteOwnershipGuardTest { @Test void legacyModeKeepsRollbackWritePathAvailable() { FactWriteOwnershipGuard guard = new FactWriteOwnershipGuard("LEGACY_CHANGE_LOG"); assertDoesNotThrow(() -> guard.assertLocalFactWriteAllowed("test")); } @Test void directModesRejectWritesThatWouldBypassRuleTransaction() { assertThrows(IllegalStateException.class, () -> new FactWriteOwnershipGuard("DIRECT").assertLocalFactWriteAllowed("test")); assertThrows(IllegalStateException.class, () -> new FactWriteOwnershipGuard("DIRECT_SHADOW").assertLocalFactWriteAllowed("test")); assertThrows(IllegalStateException.class, () -> new FactWriteOwnershipGuard("FACT_ONLY_REBUILD_REQUIRED") .assertLocalFactWriteAllowed("test")); } }