@@ -0,0 +1,2164 @@
+/**%0A * Copyright 2016 Palantir Technologies%0A *%0A * Licensed under the BSD-3 License (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://opensource.org/licenses/BSD-3-Clause%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.palantir.timestamp;%0A%0Aimport static java.util.concurrent.TimeUnit.SECONDS;%0A%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.core.Is.is;%0A%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0A%0Aimport org.junit.Test;%0A%0Apublic class LastReturnedTimestampTest %7B%0A    private static final long INITIAL_VALUE = 100;%0A%0A    LastReturnedTimestamp timestamp = new LastReturnedTimestamp(INITIAL_VALUE);%0A    private ExecutorService executor = Executors.newFixedThreadPool(4);%0A%0A    @Test%0A    public void shouldIncreaseTheValueToAHigherNumber() %7B%0A        timestamp.increaseToAtLeast(INITIAL_VALUE + 10);%0A%0A        assertThat(timestamp.get(), is(INITIAL_VALUE + 10));%0A    %7D%0A%0A    @Test%0A    public void shouldNotIncreaseTheValueToALowerNumber() %7B%0A        timestamp.increaseToAtLeast(INITIAL_VALUE - 10);%0A%0A        assertThat(timestamp.get(), is(INITIAL_VALUE));%0A    %7D%0A%0A    @Test%0A    public void handleConcurrentlyIncreasingTheValue() throws InterruptedException %7B%0A        for(int i = 0; i %3C= 100; i++) %7B%0A            final int value = i;%0A            executor.submit(new Runnable() %7B%0A                @Override%0A                public void run() %7B%0A                    timestamp.increaseToAtLeast(INITIAL_VALUE + value);%0A                %7D%0A            %7D);%0A        %7D%0A%0A        waitForExecutorToFinish();%0A%0A        assertThat(timestamp.get(), is(INITIAL_VALUE + 100));%0A    %7D%0A%0A    private void waitForExecutorToFinish() throws InterruptedException %7B%0A        executor.shutdown();%0A        executor.awaitTermination(10, SECONDS);%0A    %7D%0A%7D%0A

Add last returned timestamp tests