/**
 * Copyright (C) Posten Norge AS
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package no.digipost.concurrent;

import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class OneTimeToggleTest {

    private final OneTimeToggle done = new OneTimeToggle();

    @Test
    public void toggleIsAllowedSeveralTimes() {
        assertThat(done.yet(), is(false));
        done.now();
        assertThat(done.yet(), is(true));
        done.now();
        assertThat(done.yet(), is(true));
    }

    @Test
    public void toggleOnceOrThrowException() {
        assertThat(done.yet(), is(false));
        done.nowOrIfAlreadyThenThrow(IllegalStateException::new);
        assertThat(done.yet(), is(true));

        assertThrows(IllegalStateException.class, () -> done.nowOrIfAlreadyThenThrow(IllegalStateException::new));
    }
}

@@ -661,24 +661,135 @@
 .api.Test;%0A%0A
+import static co.unruly.matchers.Java8Matchers.where;%0Aimport static co.unruly.matchers.Java8Matchers.whereNot;%0A
 import stati
@@ -1107,32 +1107,45 @@
 hat(done
-.yet(), is(false
+, whereNot(OneTimeToggle::yet
 ));%0A    
@@ -1179,39 +1179,50 @@
 ertThat(done
-.yet(), is(true
+, where(OneTimeToggle::yet
 ));%0A        
@@ -1252,39 +1252,50 @@
 ertThat(done
-.yet(), is(true
+, where(OneTimeToggle::yet
 ));%0A    %7D%0A%0A 
@@ -1377,24 +1377,37 @@
 done
-.yet(), is(false
+, whereNot(OneTimeToggle::yet
 ));%0A
@@ -1499,23 +1499,34 @@
 done
-.yet(), is(true
+, where(OneTimeToggle::yet
 ));%0A

Use where-matchers in OneTimeToggleTest