Skip to content

Commit a5e811d

Browse files
committed
Add test cases for RecordBoundaryRemover
1 parent bfba12d commit a5e811d

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2016 Deutsche Nationalbibliothek
3+
*
4+
* Licensed under the Apache License, Version 2.0 the "License";
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.culturegraph.mf.stream.pipe;
17+
18+
import static org.mockito.Mockito.inOrder;
19+
import static org.mockito.Mockito.verifyZeroInteractions;
20+
21+
import org.culturegraph.mf.framework.StreamReceiver;
22+
import org.junit.Before;
23+
import org.junit.Test;
24+
import org.mockito.InOrder;
25+
import org.mockito.Mock;
26+
import org.mockito.MockitoAnnotations;
27+
28+
/**
29+
* Tests for class {@link RecordBounderyRemover}.
30+
*
31+
* @author Christoph Böhme
32+
*/
33+
public class RecordBounderyRemoverTest {
34+
35+
@Mock
36+
private StreamReceiver receiver;
37+
38+
private RecordBounderyRemover bounderyRemover;
39+
40+
@Before
41+
public void init() {
42+
MockitoAnnotations.initMocks(this);
43+
bounderyRemover = new RecordBounderyRemover();
44+
bounderyRemover.setReceiver(receiver);
45+
}
46+
47+
@Test
48+
public void shouldRemoveStartAndEndRecordEvents() {
49+
bounderyRemover.startRecord("1");
50+
bounderyRemover.endRecord();
51+
52+
verifyZeroInteractions(receiver);
53+
}
54+
55+
@Test
56+
public void shouldForwardAllOtherEvents() {
57+
bounderyRemover.startRecord("1");
58+
bounderyRemover.startEntity("entity");
59+
bounderyRemover.literal("literal", "value");
60+
bounderyRemover.endEntity();
61+
bounderyRemover.endRecord();
62+
bounderyRemover.closeStream();
63+
64+
final InOrder ordered = inOrder(receiver);
65+
ordered.verify(receiver).startEntity("entity");
66+
ordered.verify(receiver).literal("literal", "value");
67+
ordered.verify(receiver).endEntity();
68+
ordered.verify(receiver).closeStream();
69+
}
70+
71+
}

0 commit comments

Comments
 (0)