@Test public void testGetQueryNullValue() throws Exception { final ImpExDescriptorNativeInsertStrategy strategy = new ImpExDescriptorNativeInsertStrategy(); strategy.setProviders(new HashMap<String, LookUpQueryParameterStrategyValueProvider>() {{ put(LookUpQueryParameterStrategy.MASTER_ID, new MasterObjectIdLookUpQueryParameterStrategyValueProviderImpl()); }}); strategy.setDefaultProvider(new ColumnValueLookUpQueryParameterStrategyValueProviderImpl()); final Identifiable master = mockery.mock(Identifiable.class, "master"); final CsvImportDescriptor descriptor = mockery.mock(CsvImportDescriptor.class, "descriptor"); final CsvImportColumn codeColumn = mockery.mock(CsvImportColumn.class, "codeColumn"); final CsvImportTuple tuple = mockery.mock(CsvImportTuple.class, "tuple"); final CsvValueAdapter adapter = mockery.mock(CsvValueAdapter.class, "adapter"); mockery.checking(new Expectations() {{ oneOf(master).getId(); will(returnValue(10L)); oneOf(descriptor).getColumn("code"); will(returnValue(codeColumn)); oneOf(tuple).getColumnValue(codeColumn, adapter); will(returnValue(null)); }}); final LookUpQuery query = strategy.getQuery(descriptor, master, tuple, adapter, "SELECT * FROM TENTITY e WHERE e.PARENT_ID = {masterObjectId} AND e.CODE = {code} "); assertNotNull(query); assertEquals(query.getQueryString(), "SELECT * FROM TENTITY e WHERE e.PARENT_ID = 10 AND e.CODE = NULL "); assertNotNull(query.getParameters()); assertEquals(query.getParameters().length, 0); mockery.assertIsSatisfied(); }
@Override public LookUpQuery getQuery(final ImpExDescriptor descriptor, final Object masterObject, final ImpExTuple tuple, final Object adapter, final String queryTemplate) { final StringBuilder sql = new StringBuilder(); final List params = new ArrayList(); replaceColumnNamesInTemplate(queryTemplate, sql, params, descriptor, masterObject, tuple, adapter); return new NativeSQLQuery(sql.toString(), params.toArray()); }
ImpExDescriptorNativeInsertStrategy extends AbstractByParameterByColumnNameStrategy<ImpExDescriptor, ImpExTuple, Object> implements LookUpQueryParameterStrategy<ImpExDescriptor, ImpExTuple, Object> { @Override public LookUpQuery getQuery(final ImpExDescriptor descriptor, final Object masterObject, final ImpExTuple tuple, final Object adapter, final String queryTemplate) { final StringBuilder sql = new StringBuilder(); final List params = new ArrayList(); replaceColumnNamesInTemplate(queryTemplate, sql, params, descriptor, masterObject, tuple, adapter); return new NativeSQLQuery(sql.toString(), params.toArray()); } }
ImpExDescriptorNativeInsertStrategy extends AbstractByParameterByColumnNameStrategy<ImpExDescriptor, ImpExTuple, Object> implements LookUpQueryParameterStrategy<ImpExDescriptor, ImpExTuple, Object> { @Override public LookUpQuery getQuery(final ImpExDescriptor descriptor, final Object masterObject, final ImpExTuple tuple, final Object adapter, final String queryTemplate) { final StringBuilder sql = new StringBuilder(); final List params = new ArrayList(); replaceColumnNamesInTemplate(queryTemplate, sql, params, descriptor, masterObject, tuple, adapter); return new NativeSQLQuery(sql.toString(), params.toArray()); }  }
ImpExDescriptorNativeInsertStrategy extends AbstractByParameterByColumnNameStrategy<ImpExDescriptor, ImpExTuple, Object> implements LookUpQueryParameterStrategy<ImpExDescriptor, ImpExTuple, Object> { @Override public LookUpQuery getQuery(final ImpExDescriptor descriptor, final Object masterObject, final ImpExTuple tuple, final Object adapter, final String queryTemplate) { final StringBuilder sql = new StringBuilder(); final List params = new ArrayList(); replaceColumnNamesInTemplate(queryTemplate, sql, params, descriptor, masterObject, tuple, adapter); return new NativeSQLQuery(sql.toString(), params.toArray()); }  @Override LookUpQuery getQuery(final ImpExDescriptor descriptor,
                                final Object masterObject,
                                final ImpExTuple tuple,
                                final Object adapter,
                                final String queryTemplate); }
ImpExDescriptorNativeInsertStrategy extends AbstractByParameterByColumnNameStrategy<ImpExDescriptor, ImpExTuple, Object> implements LookUpQueryParameterStrategy<ImpExDescriptor, ImpExTuple, Object> { @Override public LookUpQuery getQuery(final ImpExDescriptor descriptor, final Object masterObject, final ImpExTuple tuple, final Object adapter, final String queryTemplate) { final StringBuilder sql = new StringBuilder(); final List params = new ArrayList(); replaceColumnNamesInTemplate(queryTemplate, sql, params, descriptor, masterObject, tuple, adapter); return new NativeSQLQuery(sql.toString(), params.toArray()); }  @Override LookUpQuery getQuery(final ImpExDescriptor descriptor,
                                final Object masterObject,
                                final ImpExTuple tuple,
                                final Object adapter,
                                final String queryTemplate);  }