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);
}
Aggregations