Search in sources :

Example 1 with UntargettedBinding

use of org.elasticsearch.common.inject.spi.UntargettedBinding in project elasticsearch by elastic.

the class ModuleTestCase method assertBinding.

/** Configures the module and asserts "clazz" is bound to "to". */
public void assertBinding(Module module, Class to, Class clazz) {
    List<Element> elements = Elements.getElements(module);
    for (Element element : elements) {
        if (element instanceof LinkedKeyBinding) {
            LinkedKeyBinding binding = (LinkedKeyBinding) element;
            if (to.equals(binding.getKey().getTypeLiteral().getType())) {
                assertSame(clazz, binding.getLinkedKey().getTypeLiteral().getType());
                return;
            }
        } else if (element instanceof UntargettedBinding) {
            UntargettedBinding binding = (UntargettedBinding) element;
            if (to.equals(binding.getKey().getTypeLiteral().getType())) {
                assertSame(clazz, to);
                return;
            }
        }
    }
    StringBuilder s = new StringBuilder();
    for (Element element : elements) {
        s.append(element + "\n");
    }
    fail("Did not find any binding to " + to.getName() + ". Found these bindings:\n" + s);
}
Also used : UntargettedBinding(org.elasticsearch.common.inject.spi.UntargettedBinding) Element(org.elasticsearch.common.inject.spi.Element) LinkedKeyBinding(org.elasticsearch.common.inject.spi.LinkedKeyBinding)

Aggregations

Element (org.elasticsearch.common.inject.spi.Element)1 LinkedKeyBinding (org.elasticsearch.common.inject.spi.LinkedKeyBinding)1 UntargettedBinding (org.elasticsearch.common.inject.spi.UntargettedBinding)1