Skip to content

Commit 5f9a097

Browse files
TobiasNxdr0i
authored andcommitted
Enforce unique result #686
1 parent 1b36009 commit 5f9a097

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

metafix/src/main/java/org/metafacture/metafix/FindFixPaths.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@
2525
import org.metafacture.framework.annotations.In;
2626
import org.metafacture.framework.annotations.Out;
2727
import org.metafacture.framework.helpers.DefaultStreamPipe;
28+
import org.metafacture.mangling.DuplicateObjectFilter;
2829
import org.metafacture.mangling.StreamFlattener;
30+
import org.metafacture.triples.AbstractTripleSort.Compare;
2931
import org.metafacture.triples.StreamToTriples;
3032
import org.metafacture.triples.TripleFilter;
33+
import org.metafacture.triples.TripleSort;
3134

3235
import java.io.IOException;
3336

@@ -37,7 +40,7 @@
3740
*
3841
* @author Tobias Bülte
3942
*/
40-
@Description("Finds all paths that have values that match the given pattern. Allows for regex. These paths can be used in a Fix to address fields.")
43+
@Description("Finds all paths that have values that match the given pattern. Allows for regex. These paths can be used in a Fix to address fields.") // checkstyle-disable-line ClassDataAbstractionCoupling
4144
@In(StreamReceiver.class)
4245
@Out(String.class)
4346
@FluxCommand("find-fix-paths")
@@ -67,11 +70,15 @@ public FindFixPaths(final String objectPattern) {
6770
protected void onSetReceiver() {
6871
final TripleFilter tripleFilter = new TripleFilter();
6972
tripleFilter.setObjectPattern(objectPattern);
73+
final TripleSort tripleSort = new TripleSort();
74+
tripleSort.setBy(Compare.PREDICATE);
7075
fix
7176
.setReceiver(new StreamFlattener())
7277
.setReceiver(new StreamToTriples())
7378
.setReceiver(tripleFilter)
79+
.setReceiver(tripleSort)
7480
.setReceiver(new ObjectTemplate<>("${p}\t|\t${o}"))
81+
.setReceiver(new DuplicateObjectFilter<>())
7582
.setReceiver(getReceiver());
7683
}
7784

metafix/src/test/java/org/metafacture/metafix/FindFixPathsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public FindFixPathsTest() {
4646
@Test
4747
public void testShouldFindPaths() {
4848
verify(
49-
"a\t|\tAn ETL test",
49+
"a.1\t|\tAn ETL test",
5050
"c.2\t|\tETL what?");
5151
}
5252

@@ -59,6 +59,7 @@ private void processRecord() {
5959
finder.literal("b", "Dog");
6060
finder.literal("c", "");
6161
finder.literal("c", "ETL what?");
62+
finder.literal("a", "An ETL test");
6263
finder.endRecord();
6364
finder.closeStream();
6465
}
@@ -72,7 +73,6 @@ private void verify(final String... result) throws MockitoAssertionError {
7273
}
7374
ordered.verify(receiver, Mockito.times(2)).closeStream();
7475
ordered.verifyNoMoreInteractions();
75-
Mockito.verifyNoMoreInteractions(receiver);
7676
}
7777
catch (final MockitoAssertionError e) {
7878
System.out.println(Mockito.mockingDetails(receiver).printInvocations());

0 commit comments

Comments
 (0)