facet.setId("_facet");
child.setId("_child");
boolean invocationResult;
final TestCallback callback = new TestCallback();
invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data", new ContextCallback() {
public void invokeContextCallback(FacesContext context, UIComponent target) {
callback.getAndIncrement();
assertEquals(mockDataAdaptor, target);
assertEquals("_data", target.getClientId());
}
});
assertTrue(invocationResult);
assertEquals(1, callback.get());
callback.reset();
final char separatorChar = UINamingContainer.getSeparatorChar(facesContext);
invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "_facet",
new ContextCallback() {
public void invokeContextCallback(FacesContext context, UIComponent target) {
callback.getAndIncrement();
assertEquals(facet, target);
assertEquals("_data" + separatorChar + "_facet", target.getClientId());
}
});
assertTrue(invocationResult);
assertEquals(1, callback.get());
callback.reset();
invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "2" + separatorChar
+ "_child", new ContextCallback() {
public void invokeContextCallback(FacesContext context, UIComponent target) {
callback.getAndIncrement();
assertEquals(child, target);
assertEquals(data.get(2), getVarValue());
assertEquals("_data" + separatorChar + "2" + separatorChar + "_child", target.getClientId());
}
});
assertTrue(invocationResult);
assertEquals(1, callback.get());
callback.reset();
invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "100" + separatorChar
+ "_child", new ContextCallback() {
public void invokeContextCallback(FacesContext context, UIComponent target) {
fail();
}
});
assertFalse(invocationResult);
invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "nonExistentComponent",
new ContextCallback() {
public void invokeContextCallback(FacesContext context, UIComponent target) {
fail();
}
});
assertFalse(invocationResult);