svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.h2spatial / org.gvsig.h2spatial.h2gis132 / org.gvsig.h2spatial.h2gis132.provider / src / test / java / org / gvsig / fmap / dal / store / h2 / operations / sql / TestResultSetForSetProvider.java @ 46050
History | View | Annotate | Download (20.5 KB)
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
---|---|
2 |
|
3 |
import java.util.List; |
4 |
import junit.framework.TestCase; |
5 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
6 |
import org.gvsig.fmap.dal.DataTypes; |
7 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
8 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
9 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
10 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
11 |
import org.gvsig.fmap.dal.feature.FeatureType; |
12 |
import org.gvsig.fmap.dal.impl.expressionevaluator.DefaultFeatureAttributeEmulatorExpression; |
13 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
14 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
15 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
16 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
17 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
18 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ResultSetForSetProviderOperation; |
19 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
20 |
import org.slf4j.Logger; |
21 |
import org.slf4j.LoggerFactory; |
22 |
|
23 |
@SuppressWarnings("UseSpecificCatch") |
24 |
public class TestResultSetForSetProvider extends TestCase { |
25 |
|
26 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestResultSetForSetProvider.class); |
27 |
|
28 |
public TestResultSetForSetProvider(String testName) { |
29 |
super(testName);
|
30 |
} |
31 |
|
32 |
@Override
|
33 |
protected void setUp() throws Exception { |
34 |
super.setUp();
|
35 |
new DefaultLibrariesInitializer().fullInitialize();
|
36 |
} |
37 |
|
38 |
@Override
|
39 |
protected void tearDown() throws Exception { |
40 |
super.tearDown();
|
41 |
} |
42 |
|
43 |
public void testSimple() throws Exception { |
44 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
45 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
46 |
OperationsFactory operations = helper.getOperations(); |
47 |
|
48 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
49 |
|
50 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
51 |
|
52 |
TableReference table = operations.createTableReference( |
53 |
"dbtest",
|
54 |
sqlbuilder.default_schema(), |
55 |
"test",
|
56 |
null
|
57 |
); |
58 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
59 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
60 |
table, |
61 |
null,
|
62 |
null,
|
63 |
null,
|
64 |
featureType, |
65 |
featureType, |
66 |
0,
|
67 |
0,
|
68 |
0
|
69 |
); |
70 |
String sql = resultSetForSetProvider.getSQL();
|
71 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(0), sql); |
72 |
} |
73 |
public void testComputedAttribute() throws Exception { |
74 |
try {
|
75 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
76 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
77 |
OperationsFactory operations = helper.getOperations(); |
78 |
|
79 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
80 |
|
81 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
82 |
|
83 |
TableReference table = operations.createTableReference( |
84 |
"dbtest",
|
85 |
sqlbuilder.default_schema(), |
86 |
"test",
|
87 |
null
|
88 |
); |
89 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
90 |
EditableFeatureType eFeatureType = featureType.getEditable(); |
91 |
eFeatureType.add("Compu1", DataTypes.INTEGER, new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("ID*2"))); |
92 |
|
93 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
94 |
table, |
95 |
null,
|
96 |
null,
|
97 |
null,
|
98 |
eFeatureType, |
99 |
eFeatureType, |
100 |
0,
|
101 |
0,
|
102 |
0
|
103 |
); |
104 |
String sql = resultSetForSetProvider.getSQL();
|
105 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(5), sql); |
106 |
} catch (Exception ex) { |
107 |
ex.printStackTrace(); |
108 |
throw ex;
|
109 |
} |
110 |
} |
111 |
|
112 |
public void testComputedAttribute2() throws Exception { |
113 |
try {
|
114 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
115 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
116 |
OperationsFactory operations = helper.getOperations(); |
117 |
|
118 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
119 |
|
120 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
121 |
|
122 |
TableReference table = operations.createTableReference( |
123 |
"dbtest",
|
124 |
sqlbuilder.default_schema(), |
125 |
"test",
|
126 |
null
|
127 |
); |
128 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
129 |
EditableFeatureType eFeatureType = featureType.getEditable(); |
130 |
eFeatureType.add("Compu1", DataTypes.INTEGER, new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("ID*2"))); |
131 |
eFeatureType.add("Compu2", DataTypes.INTEGER, new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("Long+10+Compu1"))); |
132 |
|
133 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
134 |
table, |
135 |
null,
|
136 |
null,
|
137 |
null,
|
138 |
eFeatureType, |
139 |
eFeatureType, |
140 |
0,
|
141 |
0,
|
142 |
0
|
143 |
); |
144 |
String sql = resultSetForSetProvider.getSQL();
|
145 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(6), sql); |
146 |
} catch (Exception ex) { |
147 |
ex.printStackTrace(); |
148 |
throw ex;
|
149 |
} |
150 |
} |
151 |
|
152 |
public void testComputedExtraColumn() throws Exception { |
153 |
try {
|
154 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
155 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
156 |
OperationsFactory operations = helper.getOperations(); |
157 |
|
158 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
159 |
|
160 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
161 |
|
162 |
TableReference table = operations.createTableReference( |
163 |
"dbtest",
|
164 |
sqlbuilder.default_schema(), |
165 |
"test",
|
166 |
null
|
167 |
); |
168 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
169 |
EditableFeatureType eFeatureType = featureType.getEditable(); |
170 |
eFeatureType.add("Compu1", DataTypes.INTEGER, new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("ID*2"))); |
171 |
|
172 |
FeatureQuery query = sourceStore.createFeatureQuery(); |
173 |
EditableFeatureAttributeDescriptor extraColumn1 = query.getExtraColumn().add("Extra1", DataTypes.INTEGER);
|
174 |
extraColumn1.setFeatureAttributeEmulator(new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("Long+10+Compu1"))); |
175 |
|
176 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
177 |
table, |
178 |
null,
|
179 |
null,
|
180 |
query, |
181 |
eFeatureType, |
182 |
eFeatureType, |
183 |
0,
|
184 |
0,
|
185 |
0
|
186 |
); |
187 |
String sql = resultSetForSetProvider.getSQL();
|
188 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(7), sql); |
189 |
} catch (Exception ex) { |
190 |
ex.printStackTrace(); |
191 |
throw ex;
|
192 |
} |
193 |
} |
194 |
|
195 |
public void testComputedExtraColumn2() throws Exception { |
196 |
try {
|
197 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
198 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
199 |
OperationsFactory operations = helper.getOperations(); |
200 |
|
201 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
202 |
|
203 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
204 |
|
205 |
TableReference table = operations.createTableReference( |
206 |
"dbtest",
|
207 |
sqlbuilder.default_schema(), |
208 |
"test",
|
209 |
null
|
210 |
); |
211 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
212 |
EditableFeatureType eFeatureType = featureType.getEditable(); |
213 |
|
214 |
FeatureQuery query = sourceStore.createFeatureQuery(); |
215 |
EditableFeatureAttributeDescriptor extraColumn1 = query.getExtraColumn().add("Extra1", DataTypes.INTEGER);
|
216 |
extraColumn1.setFeatureAttributeEmulator(new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("ID*2"))); |
217 |
EditableFeatureAttributeDescriptor extraColumn2 = query.getExtraColumn().add("Extra2", DataTypes.INTEGER);
|
218 |
extraColumn2.setFeatureAttributeEmulator(new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("Long+10+Extra1"))); |
219 |
|
220 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
221 |
table, |
222 |
null,
|
223 |
null,
|
224 |
query, |
225 |
eFeatureType, |
226 |
eFeatureType, |
227 |
0,
|
228 |
0,
|
229 |
0
|
230 |
); |
231 |
String sql = resultSetForSetProvider.getSQL();
|
232 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(8), sql); |
233 |
} catch (Exception ex) { |
234 |
ex.printStackTrace(); |
235 |
throw ex;
|
236 |
} |
237 |
} |
238 |
|
239 |
public void testComputedExtraColumnWithWhere() throws Exception { |
240 |
try {
|
241 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
242 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
243 |
OperationsFactory operations = helper.getOperations(); |
244 |
|
245 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
246 |
|
247 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
248 |
|
249 |
TableReference table = operations.createTableReference( |
250 |
"dbtest",
|
251 |
sqlbuilder.default_schema(), |
252 |
"test",
|
253 |
null
|
254 |
); |
255 |
|
256 |
StringBuilder filter = new StringBuilder(); |
257 |
filter.append("Extra1 > 10");
|
258 |
|
259 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
260 |
|
261 |
EditableFeatureType eFeatureType = featureType.getEditable(); |
262 |
eFeatureType.add("Compu1", DataTypes.INTEGER, new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("ID*2"))); |
263 |
|
264 |
FeatureQuery query = sourceStore.createFeatureQuery(); |
265 |
EditableFeatureAttributeDescriptor extraColumn1 = query.getExtraColumn().add("Extra1", DataTypes.INTEGER);
|
266 |
extraColumn1.setFeatureAttributeEmulator(new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("Long+10+Compu1"))); |
267 |
query.addFilter(filter.toString()); |
268 |
query.getOrder().add("Extra1");
|
269 |
|
270 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
271 |
table, |
272 |
null,
|
273 |
null,
|
274 |
query, |
275 |
eFeatureType, |
276 |
eFeatureType, |
277 |
0,
|
278 |
0,
|
279 |
0
|
280 |
); |
281 |
String sql = resultSetForSetProvider.getSQL();
|
282 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(9), sql); |
283 |
} catch (Exception ex) { |
284 |
ex.printStackTrace(); |
285 |
throw ex;
|
286 |
} |
287 |
} |
288 |
|
289 |
public void testSimpleGroup() throws Exception { |
290 |
try {
|
291 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
292 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
293 |
OperationsFactory operations = helper.getOperations(); |
294 |
|
295 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
296 |
|
297 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
298 |
|
299 |
TableReference table = operations.createTableReference( |
300 |
"dbtest",
|
301 |
sqlbuilder.default_schema(), |
302 |
"test",
|
303 |
null
|
304 |
); |
305 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
306 |
FeatureQuery query = sourceStore.createFeatureQuery(); |
307 |
query.getGroupByColumns().add("Long");
|
308 |
query.getAggregateFunctions().put("ID", "MIN"); |
309 |
query.getAggregateFunctions().put("Byte", "MAX"); |
310 |
query.getAggregateFunctions().put("Double", "SUM"); |
311 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
312 |
table, |
313 |
null,
|
314 |
null,
|
315 |
query, |
316 |
featureType, |
317 |
featureType, |
318 |
0,
|
319 |
0,
|
320 |
0
|
321 |
); |
322 |
String sql = resultSetForSetProvider.getSQL();
|
323 |
System.out.println("###### SQL:" + sql); |
324 |
System.out.println("###### EXP:" + expectedSQLs.get(1)); |
325 |
|
326 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(1), sql); |
327 |
} catch (Throwable th) { |
328 |
throw th;
|
329 |
} |
330 |
} |
331 |
|
332 |
public void testGroupByComputed() throws Exception { |
333 |
try {
|
334 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
335 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
336 |
OperationsFactory operations = helper.getOperations(); |
337 |
|
338 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
339 |
|
340 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
341 |
|
342 |
TableReference table = operations.createTableReference( |
343 |
"dbtest",
|
344 |
sqlbuilder.default_schema(), |
345 |
"test",
|
346 |
null
|
347 |
); |
348 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
349 |
FeatureQuery query = sourceStore.createFeatureQuery(); |
350 |
EditableFeatureType eFeatureType = featureType.getEditable(); |
351 |
eFeatureType.add("Compu1", DataTypes.INTEGER, new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("ID*2"))); |
352 |
eFeatureType.add("Compu2", DataTypes.INTEGER, new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("Long+300"))); |
353 |
EditableFeatureAttributeDescriptor extraColumn1 = query.getExtraColumn().add("Extra1", DataTypes.INTEGER);
|
354 |
EditableFeatureAttributeDescriptor extraColumn2 = query.getExtraColumn().add("Extra2", DataTypes.INTEGER);
|
355 |
extraColumn1.setFeatureAttributeEmulator(new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("Long+10+Compu1"))); |
356 |
extraColumn2.setFeatureAttributeEmulator(new DefaultFeatureAttributeEmulatorExpression(eFeatureType, ExpressionUtils.createExpression("20+Byte+Compu1"))); |
357 |
query.getGroupByColumns().add("Long");
|
358 |
query.getGroupByColumns().add("Extra1");
|
359 |
query.getGroupByColumns().add("Compu1");
|
360 |
query.getAggregateFunctions().put("ID", "MIN"); |
361 |
query.getAggregateFunctions().put("Byte", "MAX"); |
362 |
query.getAggregateFunctions().put("Double", "SUM"); |
363 |
query.getAggregateFunctions().put("Extra2", "SUM"); |
364 |
query.getAggregateFunctions().put("Compu2", "SUM"); |
365 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
366 |
table, |
367 |
null,
|
368 |
null,
|
369 |
query, |
370 |
eFeatureType, |
371 |
eFeatureType, |
372 |
0,
|
373 |
0,
|
374 |
0
|
375 |
); |
376 |
String sql = resultSetForSetProvider.getSQL();
|
377 |
System.out.println("###### SQL:" + sql); |
378 |
System.out.println("###### EXP:" + expectedSQLs.get(10)); |
379 |
|
380 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(10), sql); |
381 |
} catch (Throwable th) { |
382 |
throw th;
|
383 |
} |
384 |
} |
385 |
|
386 |
public void testSubselect() throws Exception { |
387 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
388 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
389 |
OperationsFactory operations = helper.getOperations(); |
390 |
|
391 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
392 |
|
393 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
394 |
|
395 |
TableReference table = operations.createTableReference( |
396 |
"dbtest",
|
397 |
sqlbuilder.default_schema(), |
398 |
"test",
|
399 |
null
|
400 |
); |
401 |
StringBuilder filter = new StringBuilder(); |
402 |
filter.append("EXISTS(");
|
403 |
filter.append(" SELECT \"ISO_A2\" FROM countries");
|
404 |
filter.append(" WHERE ");
|
405 |
filter.append(" TEST.STRING = countries.CONTINENT AND ");
|
406 |
filter.append(" countries.LASTCENSUS < 0 ");
|
407 |
filter.append(" LIMIT 1;, ");
|
408 |
filter.append(" 'EXISTS62a964cd7bc24f409b97c03b9170408d' ");
|
409 |
filter.append(")");
|
410 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
411 |
FeatureQuery query = sourceStore.createFeatureQuery(); |
412 |
query.addFilter(filter.toString()); |
413 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
414 |
table, |
415 |
null,
|
416 |
null,
|
417 |
query, |
418 |
featureType, |
419 |
featureType, |
420 |
0,
|
421 |
0,
|
422 |
0
|
423 |
); |
424 |
String sql = resultSetForSetProvider.getSQL();
|
425 |
System.out.println("###### SQL:"+sql); |
426 |
System.out.println("###### EXP:"+expectedSQLs.get(2)); |
427 |
|
428 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(2), sql); |
429 |
} |
430 |
|
431 |
public void testGroupAndSubselect() throws Exception { |
432 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
433 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
434 |
OperationsFactory operations = helper.getOperations(); |
435 |
|
436 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
437 |
|
438 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
439 |
|
440 |
TableReference table = operations.createTableReference( |
441 |
"dbtest",
|
442 |
sqlbuilder.default_schema(), |
443 |
"test",
|
444 |
null
|
445 |
); |
446 |
StringBuilder filter = new StringBuilder(); |
447 |
filter.append("EXISTS(");
|
448 |
filter.append(" SELECT \"ISO_A2\" FROM countries");
|
449 |
filter.append(" WHERE ");
|
450 |
filter.append(" TEST.STRING = countries.CONTINENT AND ");
|
451 |
filter.append(" countries.LASTCENSUS < 0 ");
|
452 |
filter.append(" LIMIT 1;, ");
|
453 |
filter.append(" 'EXISTS62a964cd7bc24f409b97c03b9170408d' ");
|
454 |
filter.append(")");
|
455 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
456 |
FeatureQuery query = sourceStore.createFeatureQuery(); |
457 |
query.getGroupByColumns().add("Long");
|
458 |
query.getAggregateFunctions().put("ID", "MIN"); |
459 |
query.getAggregateFunctions().put("Byte", "MAX"); |
460 |
query.getAggregateFunctions().put("Double", "SUM"); |
461 |
query.addFilter(filter.toString()); |
462 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
463 |
table, |
464 |
null,
|
465 |
null,
|
466 |
query, |
467 |
featureType, |
468 |
featureType, |
469 |
0,
|
470 |
0,
|
471 |
0
|
472 |
); |
473 |
String sql = resultSetForSetProvider.getSQL();
|
474 |
System.out.println("###### SQL:"+sql); |
475 |
System.out.println("###### EXP:"+expectedSQLs.get(3)); |
476 |
|
477 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(3), sql); |
478 |
} |
479 |
|
480 |
|
481 |
|
482 |
public void testConstantColumnPrimaryKey() throws Exception { |
483 |
JDBCHelper helper = TestUtils.createJDBCHelper(); |
484 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
485 |
OperationsFactory operations = helper.getOperations(); |
486 |
|
487 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
488 |
|
489 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
490 |
|
491 |
TableReference table = operations.createTableReference( |
492 |
"dbtest",
|
493 |
sqlbuilder.default_schema(), |
494 |
"test",
|
495 |
null
|
496 |
); |
497 |
// meterle como constantCOlumn ID
|
498 |
|
499 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
500 |
FeatureQuery query = sourceStore.createFeatureQuery(); |
501 |
|
502 |
query.setConstantsAttributeNames(new String[]{"ID"}); |
503 |
|
504 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
505 |
table, |
506 |
null,
|
507 |
null,
|
508 |
query, |
509 |
featureType, |
510 |
featureType, |
511 |
0,
|
512 |
0,
|
513 |
0
|
514 |
); |
515 |
String sql = resultSetForSetProvider.getSQL();
|
516 |
System.out.println("###### SQL:"+sql); |
517 |
System.out.println("###### EXP:"+expectedSQLs.get(4)); |
518 |
|
519 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(4), sql); |
520 |
} |
521 |
|
522 |
|
523 |
// TODO: a?adir un test con where, group y order.
|
524 |
} |