Revision 48697
Added by Claudio Atzori almost 7 years ago
XsltRowTransformerFactoryTest.java | ||
---|---|---|
340 | 340 |
duplicates.add(getOafBody(puma2)); |
341 | 341 |
final Oaf.Builder oafMerge = OafEntityMerger.merge(mergeId, duplicates); |
342 | 342 |
|
343 |
final Row mergeRow = new Row("result", mergeId, Lists.<Column<String,byte[]>>newArrayList(new Column("body", oafMerge.build().toByteArray())));
|
|
343 |
final Row mergeRow = new Row("result", mergeId, Lists.newArrayList(new Column("body", oafMerge.build().toByteArray()))); |
|
344 | 344 |
|
345 | 345 |
rows.add(mergeRow); |
346 | 346 |
|
... | ... | |
432 | 432 |
printAll(mapAll(buildTable(rows))); |
433 | 433 |
} |
434 | 434 |
|
435 |
@Test |
|
436 |
public void testParseSoftwareFromODF() throws Exception { |
|
437 |
final List<Row> rows = Lists.newArrayList(); |
|
438 |
rows.addAll(asRows(loadFromTransformationProfile("odf2hbase.xml"), load("softwareODF.xml"))); |
|
439 |
rows.addAll(asRows(loadFromTransformationProfile("projects_2_hbase.xsl"), load("projectRecordCorda.xml"))); |
|
440 |
printAll(mapAll(buildTable(rows))); |
|
441 |
} |
|
442 |
|
|
443 |
@Test(expected = AssertionError.class) |
|
444 |
public void testParseSoftwareFromOAF() throws Exception { |
|
445 |
final List<Row> rows = Lists.newArrayList(); |
|
446 |
rows.addAll(asRows(loadFromTransformationProfile("oaf2hbase.xml"), load("recordOAFsoftware.xml"))); |
|
447 |
printAll(mapAll(buildTable(rows))); |
|
448 |
} |
|
449 |
|
|
435 | 450 |
private void doTest(final InputStream xsltStream, final InputStream recordStream) throws Exception { |
436 | 451 |
try { |
437 | 452 |
final List<Row> rows = asRows(xsltStream, recordStream); |
... | ... | |
498 | 513 |
} |
499 | 514 |
|
500 | 515 |
private List<Row> asRows(final InputStream xsltStream, final InputStream recordStream, final Function<Row, Row> p) throws Exception { |
501 |
return asRows(xsltStream, new HashMap<String, Object>(), recordStream, p);
|
|
516 |
return asRows(xsltStream, new HashMap<>(), recordStream, p); |
|
502 | 517 |
} |
503 | 518 |
|
504 | 519 |
private List<Row> asRows(final InputStream xsltStream, final InputStream recordStream) throws Exception { |
505 |
return asRows(xsltStream, new HashMap<String, Object>(), recordStream);
|
|
520 |
return asRows(xsltStream, new HashMap<>(), recordStream); |
|
506 | 521 |
} |
507 | 522 |
|
508 | 523 |
private List<Row> asRows(final InputStream xsltStream, final Map<String, Object> params, final InputStream recordStream) throws Exception { |
... | ... | |
579 | 594 |
final String rowKey = row.getKey(); |
580 | 595 |
final String cf = row.getColumnFamily(); |
581 | 596 |
if (!table.containsKey(rowKey)) { |
582 |
table.put(rowKey, new HashMap<String, Map<String, byte[]>>());
|
|
597 |
table.put(rowKey, new HashMap<>()); |
|
583 | 598 |
} |
584 | 599 |
if (!table.get(rowKey).containsKey(cf)) { |
585 |
table.get(rowKey).put(row.getColumnFamily(), new HashMap<String, byte[]>());
|
|
600 |
table.get(rowKey).put(row.getColumnFamily(), new HashMap<>()); |
|
586 | 601 |
} |
587 | 602 |
for (final Column<String, byte[]> c : row.getColumns()) { |
588 | 603 |
// System.out.println(String.format("ADDING K:%s CF:%s Q:%s", rowKey, cf, c.getName())); |
Also available in: Unified diff
some java8 refactorings, added more tests for the software entities mapping