Buggy code:
public class MysSqlQueryBuilderTest { protected final MySqlQueryBuilder queryBuilder = new MySqlQueryBuilder ( ) ; @ Test public void testConcreteSelectQuery ( ) { } @ Test public void testConcreteSelectByKeysQuery ( ) { } @ Test public void testConcreteInsertFullQuery ( ) { } @ Test public void testConcreteInsertAnemicQuery ( ) { } @ Test public void testConcreteUpdateQuery ( ) { } @ Test public void testConcreteDeleteQuery ( ) { } @ Test public void testSelectCollectionQuery ( ) { } @ Test public void testSelectListQuery ( ) { } @ Test public void testLinkCollectionQuery ( ) { } @ Test public void testLinkListQuery ( ) { EntityDefinition definition = getConcreteBDefinition ( ) ; CollectionDefinition field = definition . getCollectionField ( "atomicList" ) ; QueryDescriptor query = queryBuilder . buildLinkCollectionQuery ( field ) ; String etalonQuery = "update<seq2seq4repair_space>atomics<seq2seq4repair_space>as<seq2seq4repair_space>atomic<seq2seq4repair_space>join<seq2seq4repair_space>(${ordering})<seq2seq4repair_space>ordering_subquery<seq2seq4repair_space>" + ( "on<seq2seq4repair_space>atomic.atomic_id<seq2seq4repair_space>=<seq2seq4repair_space>ordering_subquery.key_column<seq2seq4repair_space>" + "set<seq2seq4repair_space>atomic.b_ref<seq2seq4repair_space>=<seq2seq4repair_space>?,<seq2seq4repair_space>atomic.b_order<seq2seq4repair_space>=<seq2seq4repair_space>ordering_subquery.order_column" ) ; assertEquals ( etalonQuery , query . getQuery ( ) ) ; assertEquals ( 1 , query . getParameterBinding ( "linkedKeys" ) ) ; assertEquals ( 2 , query . getParameterBinding ( "foreignKey" ) ) ; Map < String , Object > parameters = new HashMap < > ( ) ; parameters . put ( "foreignKey" , new Object ( ) ) ; parameters . put ( "linkedKeys" , Arrays . asList ( new Object ( ) , new Object ( ) ) ) ; String resolvedEtalon = "update<seq2seq4repair_space>atomics<seq2seq4repair_space>as<seq2seq4repair_space>atomic<seq2seq4repair_space>join<seq2seq4repair_space>" + ( ( ( "(select<seq2seq4repair_space>?<seq2seq4repair_space>as<seq2seq4repair_space>key_column,<seq2seq4repair_space>0<seq2seq4repair_space>as<seq2seq4repair_space>order_column<seq2seq4repair_space>from<seq2seq4repair_space>dual<seq2seq4repair_space>union<seq2seq4repair_space>all<seq2seq4repair_space>" + "select<seq2seq4repair_space>?<seq2seq4repair_space>as<seq2seq4repair_space>key_column,<seq2seq4repair_space>1<seq2seq4repair_space>as<seq2seq4repair_space>order_column<seq2seq4repair_space>from<seq2seq4repair_space>dual)<seq2seq4repair_space>ordering_subquery<seq2seq4repair_space>" ) + "on<seq2seq4repair_space>atomic.atomic_id<seq2seq4repair_space>=<seq2seq4repair_space>ordering_subquery.key_column<seq2seq4repair_space>" ) + "set<seq2seq4repair_space>atomic.b_ref<seq2seq4repair_space>=<seq2seq4repair_space>?,<seq2seq4repair_space>atomic.b_order<seq2seq4repair_space>=<seq2seq4repair_space>ordering_subquery.order_column" ) ; QueryDescriptor resolved = queryBuilder . resolveMacros ( query , parameters ) ; assertNotSame ( query , resolved ) ; assertEquals ( resolvedEtalon , resolved . getQuery ( ) ) ; assertEquals ( 1 , resolved . getParameterBinding ( "linkedKeys" ) ) ; <START_BUG> assertEquals ( 2 , resolved . getParameterBinding ( "foreignKey" ) ) ; <END_BUG> } @ Test public void testUnlinkCollectionQuery ( ) { } @ Test public void testUnlinkListQuery ( ) { } @ Test public void testClearCollectionQuery ( ) { } @ Test public void testClearListQuery ( ) { } @ Test public void testRootSelectQuery ( ) { } @ Test public void testSuperSelectByKeysQuery ( ) { } @ Test public void testSuperUpdateQuery ( ) { } @ Test public void testSuperDeleteQuery ( ) { } @ Test public void testSuperInsertFullQuery ( ) { } @ Test public void testSuperInsertAnemicQuery ( ) { } protected EntityDefinition getAtomicDefinition ( ) { } protected EntityDefinition getConcreteADefinition ( ) { } protected EntityDefinition getConcreteBDefinition ( ) { } protected EntityDefinition getSuperDefinition ( ) { } protected EntityDefinition getRootDefinition ( ) { } }

Fix:
assertEquals ( 3 , resolved . getParameterBinding ( "foreignKey" ) ) ;