package lv.ctco.cukes.ldap.api;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import cucumber.api.java.en.Then;
import lv.ctco.cukes.core.internal.context.InflateContext;
import lv.ctco.cukes.ldap.facade.EntityFacade;

@Singleton
@InflateContext
public class ThenSteps {

    @Inject
    EntityFacade entityFacade;

    @Then("^entity exists$")
    public void entityExists() {
        entityFacade.entityExists();
    }

    @Then("^entity does not exist$")
    public void entityDoesNotExist() {
        entityFacade.entityDoesNotExist();
    }

    @Then("^entity contains attribute \"([a-zA-Z][a-zA-Z0-9\\-]*)\"$")
    public void entityContainsAttribute(String attribute) {
        entityFacade.entityContainsAttribute(attribute);
    }

    @Then("^entity does not contain attribute \"([a-zA-Z][a-zA-Z0-9\\-]*)\"$")
    public void entityDoesNotContainAttribute(String attribute) {
        entityFacade.entityDoesNotContainAttribute(attribute);
    }

    @Then("^entity contains attribute \"([a-zA-Z][a-zA-Z0-9\\-]*)\" with value \"(.+)\"$")
    public void entityHasAttributeWithValue(String attribute, String value) {
        entityFacade.entityHasAttributeWithValue(attribute, value);
    }

    @Then("^entity contains attribute \"([a-zA-Z][a-zA-Z0-9\\-]*)\" with value other than \"(.+)\"$")
    public void entityHasAttributeWithValueOtherThat(String attribute, String value) {
        entityFacade.entityHasAttributeWithValueOtherThat(attribute, value);
    }

    @Then("^entity contains attribute \"([a-zA-Z][a-zA-Z0-9\\-]*)\" with \"(.+)\" values$")
    public void entityHasAttributeAsArrayOfSize(String attribute, int size) {
        entityFacade.entityHasAttributeAsArrayOfSize(attribute, "=", size);
    }

    @Then("^entity contains attribute \"([a-zA-Z][a-zA-Z0-9\\-]*)\" with (>=|>|<=|<|<>) \"(.+)\" values$")
    public void entityHasAttributeAsArrayOfSize(String attribute, String operator, int size) {
        entityFacade.entityHasAttributeAsArrayOfSize(attribute, operator, size);
    }

    @Then("^entity contains attribute \"([a-zA-Z][a-zA-Z0-9\\-]*)\" matching pattern \"(.+)\"$")
    public void entityHasAttributeWithValueMatchingPattern(String attribute, String pattern) {
        entityFacade.entityHasAttributeWithValueMatchingPattern(attribute, pattern);
    }

    @Then("^entity contains attribute \"([a-zA-Z][a-zA-Z0-9\\-]*)\" not matching pattern \"(.+)\"$")
    public void entityHasAttributeWithValueNotMatchingPattern(String attribute, String pattern) {
        entityFacade.entityHasAttributeWithValueNotMatchingPattern(attribute, pattern);
    }

    @Then("^entity matches LDIF:$")
    public void entityMatchesLDIF(String ldif) {
        entityFacade.entityMatchesLDIF(ldif);
    }

}

@@ -1054,25 +1054,25 @@
 h value %5C%22(.
-+
+*
 )%5C%22$%22)%0A    p
@@ -1309,25 +1309,25 @@
 er than %5C%22(.
-+
+*
 )%5C%22$%22)%0A    p
@@ -1565,24 +1565,22 @@
 %5C%22 with 
-%5C%22(.+)%5C%22
+(%5C%5Cd+)
  values$
@@ -1831,24 +1831,22 @@
 =%7C%3C%7C%3C%3E) 
-%5C%22(.+)%5C%22
+(%5C%5Cd+)
  values$

allow checking that attribute value is or is not empty Closes #95