assertEquals(Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ), parentContext.getCurrentRow(resultSetName)); //$NON-NLS-1$
assertEquals(Arrays.asList( new Object[] { "Lamp2", new Integer(54), null } ), childContext.getCurrentRow(resultSetName)); //$NON-NLS-1$
}
public void testGetReferenceValues() throws Exception {
XMLContext context = new XMLContext();
String FOO = "Foo"; //$NON-NLS-1$
String BAR = "Bar"; //$NON-NLS-1$
ElementSymbol X = new ElementSymbol("Foo.X"); //$NON-NLS-1$
ElementSymbol Y = new ElementSymbol("Foo.Y"); //$NON-NLS-1$
GroupSymbol Foo = new GroupSymbol(FOO);
X.setGroupSymbol(Foo);
Y.setGroupSymbol(Foo);
ElementSymbol AX = new ElementSymbol("Bar.X"); //$NON-NLS-1$
ElementSymbol AY = new ElementSymbol("Bar.Y"); //$NON-NLS-1$
GroupSymbol Bar = new GroupSymbol(BAR);
AX.setGroupSymbol(Bar);
AY.setGroupSymbol(Bar);
List fooSchema = Arrays.asList( new Object[] {X, Y});
List barSchema = Arrays.asList( new Object[] {AX,AY});
List[] fooRows = new List[] {
Arrays.asList( new Object[] { "Lamp", new Integer(5)} ), //$NON-NLS-1$
Arrays.asList( new Object[] { "Screwdriver", new Integer(100)} ), //$NON-NLS-1$
Arrays.asList( new Object[] { "Goat", new Integer(4) } ) //$NON-NLS-1$
};
List[] barRows = new List[] {
Arrays.asList( new Object[] { "Lamp2", new Integer(54)} ), //$NON-NLS-1$
Arrays.asList( new Object[] { "Screwdriver2", new Integer(1000)} ), //$NON-NLS-1$
Arrays.asList( new Object[] { "Goat2", new Integer(43)} ) //$NON-NLS-1$
};
FakePlanExecutor executorFoo = new FakePlanExecutor(FOO, fooSchema, fooRows);
context.setResultSet(FOO, executorFoo);
context.setVariableValues(FOO, context.getNextRow(FOO));
XMLContext childContext = new XMLContext(context);
FakePlanExecutor executorBar = new FakePlanExecutor(BAR, barSchema, barRows);
childContext.setResultSet(FOO, executorBar);
childContext.setVariableValues(FOO, childContext.getNextRow(FOO));
// THIS is the TEST.. we need the Foo elements with Bar values
Map referenceValues = childContext.getReferenceValues();
assertEquals(2, referenceValues.size());
assertEquals("Lamp2", referenceValues.get(X)); //$NON-NLS-1$
assertEquals(new Integer(54), referenceValues.get(Y));
// advance BAR and get new results for the references.
childContext.setVariableValues(FOO, childContext.getNextRow(FOO));
referenceValues = childContext.getReferenceValues();
assertEquals("Screwdriver2", referenceValues.get(X)); //$NON-NLS-1$
assertEquals(new Integer(1000), referenceValues.get(Y));
}