package cz.moneta.test.dsl.demo;

import cz.moneta.test.harness.endpoints.demo.DemoEndpoint;

import static org.junit.jupiter.api.Assertions.*;

public class SpiritVerifier {

    private DemoEndpoint demoEndpoint;

    public SpiritVerifier(DemoEndpoint demoEndpoint) {
        this.demoEndpoint = demoEndpoint;
    }

    public SpiritVerifier thatWeAreInPresenceOf(SpiritRef ref) {
        assertTrue(demoEndpoint.spiritPresent(ref.getName()),
                String.format("We have lost contact with the spirit of %s", ref.getName()));
        return this;
    }

    public SpiritVerifier thatThereIsNoSignOf(String name) {
        assertFalse(demoEndpoint.spiritPresent(new SpiritRef(name).getName()),
                String.format("Danger! We are being haunted by the spirit of %s", name));
        return this;
    }

    public SpiritVerifier thatThereIsNoSignOf(SpiritRef ref) {
        return thatThereIsNoSignOf(ref.getName());
    }
}
