// Path: stecker-plugin-loader/src/main/java/org/meridor/stecker/interfaces/ResourceChangedHandler.java
// public interface ResourceChangedHandler {
// 
//     void onResourceChanged(Path resource);
// 
// }


import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.meridor.stecker.interfaces.ResourceChangedHandler;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Timer;
import java.util.TimerTask;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
        Thread.sleep(1500);
        assertThat(testHandler.getChangesCount(), equalTo(1)); //Event should occur only once

    }

    private void scheduleFileChange() {
        final long SCHEDULE_DELAY = 1000;
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                try {
                    Files.write(temporaryFile, randomString().getBytes());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }, SCHEDULE_DELAY);
    }

    private String randomString() {
        return String.valueOf(1e6 * Math.random());
    }

    @After
    public void after() {
        if (resourcesWatcher != null) {
            resourcesWatcher.stop();
        }
    }

// Path: stecker-plugin-loader/src/main/java/org/meridor/stecker/interfaces/ResourceChangedHandler.java
// public interface ResourceChangedHandler {
// 
//     void onResourceChanged(Path resource);
// 
// }


// Path: stecker-plugin-loader/src/test/java/org/meridor/stecker/ResourcesWatcherTest.java
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.meridor.stecker.interfaces.ResourceChangedHandler;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Timer;
import java.util.TimerTask;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

        Thread.sleep(1500);
        assertThat(testHandler.getChangesCount(), equalTo(1)); //Event should occur only once

    }

    private void scheduleFileChange() {
        final long SCHEDULE_DELAY = 1000;
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                try {
                    Files.write(temporaryFile, randomString().getBytes());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }, SCHEDULE_DELAY);
    }

    private String randomString() {
        return String.valueOf(1e6 * Math.random());
    }

    @After
    public void after() {
        if (resourcesWatcher != null) {
            resourcesWatcher.stop();
        }
    }

    private static class TestHandler implements ResourceChangedHandler {