// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
// 
//     /**
//      * Use this time object whenewer actual time was needed in command.
//      */
//     public final Instant time;
// 
//     public final boolean safe;
// 
//     public PrevalanceContext(final Date date) {
//         this(date.toInstant(), false);
//     }
// 
//     private PrevalanceContext(final Instant time, final boolean safe) {
//         this.time = time;
//         this.safe = safe;
//     }
// 
//     public PrevalanceContext safe() {
//         return new PrevalanceContext(this.time, true);
//     }
// 
//     public PrevalanceContext unsafe() {
//         return new PrevalanceContext(this.time, false);
//     }
// }
// 
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
// 
//     private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
// 
//     public static void setContext(final PrevalanceContext ctx) {
//         assert !hasPrevalanceContext() : "Context was initialized before";
//         CONTEXT_STORE.set(ctx);
//     }
// 
//     public static PrevalanceContext getContext() {
//         return CONTEXT_STORE.get();
//     }
// 
//     public static void clearContext() {
//         assert hasPrevalanceContext() : "Context has to be initialized first";
//         CONTEXT_STORE.remove();
//     }
// 
//     public static boolean hasPrevalanceContext() {
//         return CONTEXT_STORE.get() != null;
//     }
// 
//     public static void enterSafe() {
//         assert hasPrevalanceContext() : "Context has to be initialized first";
//         assert !getContext().safe : "context cannot be safe before";
//         CONTEXT_STORE.set(getContext().safe());
//     }
// 
//     public static void leaveSafe() {
//         assert hasPrevalanceContext() : "Context has to be initialized first";
//         assert getContext().safe : "context must be safe before";
// 
//         CONTEXT_STORE.set(getContext().unsafe());
//     }
// 
// }


import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
import static org.junit.Assert.*;
/*
 *  Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0   http://www.apache.org/licenses/LICENSE-2.0
 */
package pl.setblack.airomem.core.builders;



/**
 * @author jarek ratajski
 */
public class WriteCheckerTest {

    private PrevalanceContext ctx1;
    private PrevalanceContext ctx2;

     @Before
    public void setUp() {
        ctx1 = Mockito.mock(PrevalanceContext.class);
        ctx2 = Mockito.mock(PrevalanceContext.class);
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/PrevalanceContext.java
// public class PrevalanceContext {
// 
//     /**
//      * Use this time object whenewer actual time was needed in command.
//      */
//     public final Instant time;
// 
//     public final boolean safe;
// 
//     public PrevalanceContext(final Date date) {
//         this(date.toInstant(), false);
//     }
// 
//     private PrevalanceContext(final Instant time, final boolean safe) {
//         this.time = time;
//         this.safe = safe;
//     }
// 
//     public PrevalanceContext safe() {
//         return new PrevalanceContext(this.time, true);
//     }
// 
//     public PrevalanceContext unsafe() {
//         return new PrevalanceContext(this.time, false);
//     }
// }
// 
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/WriteChecker.java
// public class WriteChecker {
// 
//     private static final ThreadLocal<PrevalanceContext> CONTEXT_STORE = new ThreadLocal<>();
// 
//     public static void setContext(final PrevalanceContext ctx) {
//         assert !hasPrevalanceContext() : "Context was initialized before";
//         CONTEXT_STORE.set(ctx);
//     }
// 
//     public static PrevalanceContext getContext() {
//         return CONTEXT_STORE.get();
//     }
// 
//     public static void clearContext() {
//         assert hasPrevalanceContext() : "Context has to be initialized first";
//         CONTEXT_STORE.remove();
//     }
// 
//     public static boolean hasPrevalanceContext() {
//         return CONTEXT_STORE.get() != null;
//     }
// 
//     public static void enterSafe() {
//         assert hasPrevalanceContext() : "Context has to be initialized first";
//         assert !getContext().safe : "context cannot be safe before";
//         CONTEXT_STORE.set(getContext().safe());
//     }
// 
//     public static void leaveSafe() {
//         assert hasPrevalanceContext() : "Context has to be initialized first";
//         assert getContext().safe : "context must be safe before";
// 
//         CONTEXT_STORE.set(getContext().unsafe());
//     }
// 
// }


// Path: airomem-core/src/test/java/pl/setblack/airomem/core/builders/WriteCheckerTest.java
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import pl.setblack.airomem.core.PrevalanceContext;
import pl.setblack.airomem.core.WriteChecker;
import static org.junit.Assert.*;

/*
 *  Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0   http://www.apache.org/licenses/LICENSE-2.0
 */
package pl.setblack.airomem.core.builders;



/**
 * @author jarek ratajski
 */
public class WriteCheckerTest {

    private PrevalanceContext ctx1;
    private PrevalanceContext ctx2;

     @Before
    public void setUp() {
        ctx1 = Mockito.mock(PrevalanceContext.class);
        ctx2 = Mockito.mock(PrevalanceContext.class);
        if (WriteChecker.hasPrevalanceContext()) {