Skip to content

Commit 37956e7

Browse files
author
mgeipel
committed
fixed test errors
1 parent f792995 commit 37956e7

File tree

3 files changed

+157
-159
lines changed

3 files changed

+157
-159
lines changed

src/test/java/org/culturegraph/mf/stream/pipe/IdChangePipeTest.java

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,55 +13,54 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.culturegraph.mf.stream.pipe;
17-
18-
import org.culturegraph.mf.exceptions.FormatException;
19-
import org.culturegraph.mf.stream.converter.CGTextDecoder;
20-
import org.culturegraph.mf.stream.pipe.IdChangePipe;
21-
import org.culturegraph.mf.stream.sink.EventList;
22-
import org.culturegraph.mf.stream.sink.StreamValidator;
23-
import org.junit.Assert;
24-
import org.junit.Test;
25-
26-
27-
/**
28-
* tests {@link IdChangePipe}.
29-
*
30-
* @author Christoph Böhme
31-
*
32-
*/
33-
public final class IdChangePipeTest {
34-
35-
private static final String RECORD3 = "3={ name=test }";
36-
37-
@Test
38-
public void test() {
39-
40-
final CGTextDecoder decoder = new CGTextDecoder();
41-
42-
final EventList expected = new EventList();
43-
44-
decoder.setReceiver(expected);
45-
46-
decoder.process("1={ name=test, _id=1, entity={ name=test } }");
47-
decoder.process("2={ name=test, _id=2}");
48-
//decoder.process(RECORD3);
49-
decoder.closeStream();
50-
51-
final IdChangePipe idChangePipe = new IdChangePipe();
52-
idChangePipe.setKeepIdless(false);
53-
final StreamValidator validator = new StreamValidator(expected.getEvents());
54-
55-
decoder.setReceiver(idChangePipe).setReceiver(validator);
56-
57-
try {
58-
decoder.process("one={ name=test, _id=1, entity={ name=test } }");
59-
decoder.process("two={ name=test, _id=2}");
60-
decoder.process(RECORD3);
61-
decoder.closeStream();
62-
} catch(FormatException e) {
63-
Assert.fail(e.toString());
64-
}
65-
}
66-
67-
}
16+
package org.culturegraph.mf.stream.pipe;
17+
18+
import org.culturegraph.mf.exceptions.FormatException;
19+
import org.culturegraph.mf.stream.converter.CGTextDecoder;
20+
import org.culturegraph.mf.stream.sink.EventList;
21+
import org.culturegraph.mf.stream.sink.StreamValidator;
22+
import org.junit.Assert;
23+
import org.junit.Test;
24+
25+
26+
/**
27+
* tests {@link IdChangePipe}.
28+
*
29+
* @author Christoph Böhme
30+
*
31+
*/
32+
public final class IdChangePipeTest {
33+
34+
private static final String RECORD3 = "3={ name=test }";
35+
36+
@Test
37+
public void test() {
38+
39+
final CGTextDecoder decoder = new CGTextDecoder();
40+
41+
final EventList expected = new EventList();
42+
43+
decoder.setReceiver(expected);
44+
45+
decoder.process("1={ name=test, _id=1, entity={ name=test } }");
46+
decoder.process("2={ name=test, _id=2}");
47+
//decoder.process(RECORD3);
48+
//decoder.closeStream();
49+
50+
final IdChangePipe idChangePipe = new IdChangePipe();
51+
idChangePipe.setKeepIdless(false);
52+
final StreamValidator validator = new StreamValidator(expected.getEvents());
53+
54+
decoder.setReceiver(idChangePipe).setReceiver(validator);
55+
56+
try {
57+
decoder.process("one={ name=test, _id=1, entity={ name=test } }");
58+
decoder.process("two={ name=test, _id=2}");
59+
decoder.process(RECORD3);
60+
decoder.closeStream();
61+
} catch(FormatException e) {
62+
Assert.fail(e.toString());
63+
}
64+
}
65+
66+
}

src/test/java/org/culturegraph/mf/stream/pipe/IdentityStreamPipeTest.java

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,50 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.culturegraph.mf.stream.pipe;
17-
18-
import org.culturegraph.mf.exceptions.FormatException;
19-
import org.culturegraph.mf.stream.converter.CGTextDecoder;
20-
import org.culturegraph.mf.stream.pipe.IdentityStreamPipe;
21-
import org.culturegraph.mf.stream.sink.EventList;
22-
import org.culturegraph.mf.stream.sink.StreamValidator;
23-
import org.junit.Assert;
24-
import org.junit.Test;
25-
26-
27-
/**
28-
* @author Christoph Böhme
29-
*
30-
*/
31-
public final class IdentityStreamPipeTest {
32-
33-
private static final String INPUT1 = "1={lit1=C, ent1={ent1lit1=X}}";
34-
private static final String INPUT2 = "2={lit2=D}";
35-
36-
@Test
37-
public void test() {
38-
final CGTextDecoder decoder = new CGTextDecoder();
39-
final EventList buffer = new EventList();
40-
41-
decoder.setReceiver(buffer);
42-
43-
decoder.process(INPUT1);
44-
decoder.process(INPUT2);
45-
decoder.closeStream();
46-
47-
final IdentityStreamPipe identityPipe = new IdentityStreamPipe();
48-
final StreamValidator validator = new StreamValidator(buffer.getEvents());
49-
50-
decoder.setReceiver(identityPipe).setReceiver(validator);
51-
52-
try {
53-
decoder.process(INPUT1);
54-
decoder.process(INPUT2);
55-
decoder.closeStream();
56-
} catch(FormatException e) {
57-
Assert.fail(e.toString());
58-
}
59-
60-
}
61-
62-
}
16+
package org.culturegraph.mf.stream.pipe;
17+
18+
import org.culturegraph.mf.exceptions.FormatException;
19+
import org.culturegraph.mf.stream.converter.CGTextDecoder;
20+
import org.culturegraph.mf.stream.sink.EventList;
21+
import org.culturegraph.mf.stream.sink.StreamValidator;
22+
import org.junit.Assert;
23+
import org.junit.Test;
24+
25+
26+
/**
27+
* @author Christoph Böhme
28+
*
29+
*/
30+
public final class IdentityStreamPipeTest {
31+
32+
private static final String INPUT1 = "1={lit1=C, ent1={ent1lit1=X}}";
33+
private static final String INPUT2 = "2={lit2=D}";
34+
35+
@Test
36+
public void test() {
37+
final CGTextDecoder decoder = new CGTextDecoder();
38+
final EventList buffer = new EventList();
39+
40+
decoder.setReceiver(buffer);
41+
42+
decoder.process(INPUT1);
43+
decoder.process(INPUT2);
44+
// decoder.closeStream();
45+
// decoder.resetStream();
46+
47+
final IdentityStreamPipe identityPipe = new IdentityStreamPipe();
48+
final StreamValidator validator = new StreamValidator(buffer.getEvents());
49+
50+
decoder.setReceiver(identityPipe).setReceiver(validator);
51+
52+
try {
53+
decoder.process(INPUT1);
54+
decoder.process(INPUT2);
55+
decoder.closeStream();
56+
} catch(FormatException e) {
57+
Assert.fail(e.toString());
58+
}
59+
60+
}
61+
62+
}

src/test/java/org/culturegraph/mf/stream/pipe/StreamBatchMergerTest.java

Lines changed: 59 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -13,63 +13,62 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.culturegraph.mf.stream.pipe;
17-
18-
import org.culturegraph.mf.exceptions.FormatException;
19-
import org.culturegraph.mf.stream.converter.CGTextDecoder;
20-
import org.culturegraph.mf.stream.pipe.StreamBatchMerger;
21-
import org.culturegraph.mf.stream.sink.EventList;
22-
import org.culturegraph.mf.stream.sink.StreamValidator;
23-
import org.junit.Assert;
24-
import org.junit.Test;
25-
26-
27-
/**
28-
* Test {@link StreamBatchMerger}.
29-
*
30-
* @author Christoph Böhme
31-
*
32-
*/
33-
public final class StreamBatchMergerTest {
34-
35-
private static final String INPUT1 = "0={lit0=A}";
36-
private static final String INPUT2 = "1={lit1=B}";
37-
private static final String INPUT3 = "2={lit2=C, ent2={ent2lit1=X}}";
38-
private static final String INPUT4 = "3={lit3=D}";
39-
private static final String INPUT5 = "4={lit4=E}";
40-
41-
private static final String EXPECTED_RESULT1 = "0={lit0=A, lit1=B}";
42-
private static final String EXPECTED_RESULT2 = "2={lit2=C, ent2={ent2lit1=X}, lit3=D}";
43-
private static final String EXPECTED_RESULT3 = INPUT5;
44-
45-
@Test
46-
public void test() {
47-
final CGTextDecoder decoder = new CGTextDecoder();
48-
final EventList buffer = new EventList();
49-
50-
decoder.setReceiver(buffer);
51-
52-
decoder.process(EXPECTED_RESULT1);
53-
decoder.process(EXPECTED_RESULT2);
54-
decoder.process(EXPECTED_RESULT3);
55-
decoder.closeStream();
56-
57-
final StreamBatchMerger merger = new StreamBatchMerger();
58-
merger.setBatchSize(2);
59-
final StreamValidator validator = new StreamValidator(buffer.getEvents());
60-
61-
decoder.setReceiver(merger).setReceiver(validator);
62-
63-
try {
64-
decoder.process(INPUT1);
65-
decoder.process(INPUT2);
66-
decoder.process(INPUT3);
67-
decoder.process(INPUT4);
68-
decoder.process(INPUT5);
69-
decoder.closeStream();
70-
} catch(FormatException e) {
71-
Assert.fail(e.toString());
72-
}
73-
}
74-
75-
}
16+
package org.culturegraph.mf.stream.pipe;
17+
18+
import org.culturegraph.mf.exceptions.FormatException;
19+
import org.culturegraph.mf.stream.converter.CGTextDecoder;
20+
import org.culturegraph.mf.stream.sink.EventList;
21+
import org.culturegraph.mf.stream.sink.StreamValidator;
22+
import org.junit.Assert;
23+
import org.junit.Test;
24+
25+
26+
/**
27+
* Test {@link StreamBatchMerger}.
28+
*
29+
* @author Christoph Böhme
30+
*
31+
*/
32+
public final class StreamBatchMergerTest {
33+
34+
private static final String INPUT1 = "0={lit0=A}";
35+
private static final String INPUT2 = "1={lit1=B}";
36+
private static final String INPUT3 = "2={lit2=C, ent2={ent2lit1=X}}";
37+
private static final String INPUT4 = "3={lit3=D}";
38+
private static final String INPUT5 = "4={lit4=E}";
39+
40+
private static final String EXPECTED_RESULT1 = "0={lit0=A, lit1=B}";
41+
private static final String EXPECTED_RESULT2 = "2={lit2=C, ent2={ent2lit1=X}, lit3=D}";
42+
private static final String EXPECTED_RESULT3 = INPUT5;
43+
44+
@Test
45+
public void test() {
46+
final CGTextDecoder decoder = new CGTextDecoder();
47+
final EventList buffer = new EventList();
48+
49+
decoder.setReceiver(buffer);
50+
51+
decoder.process(EXPECTED_RESULT1);
52+
decoder.process(EXPECTED_RESULT2);
53+
decoder.process(EXPECTED_RESULT3);
54+
//decoder.closeStream();
55+
56+
final StreamBatchMerger merger = new StreamBatchMerger();
57+
merger.setBatchSize(2);
58+
final StreamValidator validator = new StreamValidator(buffer.getEvents());
59+
60+
decoder.setReceiver(merger).setReceiver(validator);
61+
62+
try {
63+
decoder.process(INPUT1);
64+
decoder.process(INPUT2);
65+
decoder.process(INPUT3);
66+
decoder.process(INPUT4);
67+
decoder.process(INPUT5);
68+
decoder.closeStream();
69+
} catch(FormatException e) {
70+
Assert.fail(e.toString());
71+
}
72+
}
73+
74+
}

0 commit comments

Comments
 (0)