package it.com.atlassian.stash.hosting;

import com.atlassian.bitbucket.hook.HookResponse;
import com.atlassian.bitbucket.hook.PreReceiveHook;
import com.atlassian.bitbucket.repository.RefChange;
import com.atlassian.bitbucket.repository.Repository;

import javax.annotation.Nonnull;
import java.util.Collection;

public class TestPreReceiveHook implements PreReceiveHook {

    private final TestHookMessageProvider testHookMessageProvider;

    public TestPreReceiveHook(TestHookMessageProvider testHookMessageProvider) {
        this.testHookMessageProvider = testHookMessageProvider;
    }

    @Override
    public boolean onReceive(@Nonnull Repository repository, @Nonnull Collection<RefChange> refChanges, @Nonnull HookResponse response) {
        return testHookMessageProvider.onHook(HostingTestConstants.PRE_RECEIVE_HOOK_KEY, response);
    }
}
