package leigh.eo;

import leigh.eo.util.EOUtil;
import leigh.mecha.log.MechaLogger;
import leigh.mecha.log.MechaLoggerFactory;
import org.junit.Test;

import java.util.HashSet;

public class EOUtilTest {
    private static final MechaLogger logger = MechaLoggerFactory.getLogger(EOUtilTest.class);

    @Test
    public void scannerTest() {
        EO person = new EO("person");
        EOLoop emails = person.getValueLoop("emails");
        emails.add(new EO("email").setValue("addr", "foo@bar.com"));
        emails.add(new EO("email").setValue("addr", "bar@foo.com"));

        HashSet<EO> scan = new HashSet<>();
        EOUtil.scan(scan, person, false);

        logger.info("Scan result: {}", scan);

        assert (scan.size() == 2);

        scan.clear();

        EOUtil.scan(scan, person, true);

        assert (scan.size() == 3);
    }
}
