File tree Expand file tree Collapse file tree 3 files changed +13
-9
lines changed
metafacture-flowcontrol/src
main/java/org/metafacture/flowcontrol
test/java/org/metafacture/flowcontrol Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2013, 2014 Deutsche Nationalbibliothek
2
+ * Copyright 2013-2019 Deutsche Nationalbibliothek and others
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 the "License";
5
5
* you may not use this file except in compliance with the License.
33
33
* @param <T> Object type
34
34
*
35
35
* @author Markus Micheal Geipel
36
+ * @author Pascal Christoph (dr0i)
36
37
*/
37
38
@ In (Object .class )
38
39
@ Out (Object .class )
Original file line number Diff line number Diff line change 1
- /* Copyright 2019 hbz, Pascal Christoph.
1
+ /* Copyright 2019 Pascal Christoph, hbz.
2
2
*
3
3
* Licensed under the Apache License, Version 2.0 the "License";
4
4
* you may not use this file except in compliance with the License.
34
34
*
35
35
* @param <T> Object type
36
36
*
37
- * @author Pascal Christoph(dr0i)
37
+ * @author Pascal Christoph (dr0i)
38
38
*
39
39
*/
40
40
@ In (Object .class )
41
41
@ Out (Object .class )
42
- @ Description ("incoming objects are distributed to the added receivers, running in their own threads" )
42
+ @ Description ("Incoming objects are distributed to the added receivers, running in their own threads. " )
43
43
@ FluxCommand ("thread-object-tee" )
44
44
public class ObjectThreader <T > extends DefaultTee <ObjectReceiver <T >> implements ObjectPipe <T , ObjectReceiver <T >> {
45
45
@@ -49,10 +49,11 @@ public class ObjectThreader<T> extends DefaultTee<ObjectReceiver<T>> implements
49
49
@ Override
50
50
public void process (final T obj ) {
51
51
getReceivers ().get (objectNumber ).process (obj );
52
- if (objectNumber == getReceivers ().size () - 1 )
52
+ if (objectNumber == getReceivers ().size () - 1 ) {
53
53
objectNumber = 0 ;
54
- else
54
+ } else {
55
55
objectNumber ++;
56
+ }
56
57
}
57
58
58
59
@ Override
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2019 hbz
2
+ * Copyright 2019 Pascal Christoph, hbz.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 the "License";
5
5
* you may not use this file except in compliance with the License.
15
15
*/
16
16
package org .metafacture .flowcontrol ;
17
17
18
+ import static org .assertj .core .api .Assertions .assertThat ;
19
+
18
20
import static org .mockito .Mockito .verify ;
19
21
import static org .mockito .Mockito .atMost ;
20
22
import static org .mockito .Mockito .atLeast ;
31
33
* Tests for class {@link ObjectThreader} (which itself uses
32
34
* {@link org.metafacture.flowcontrol.ObjectPipeDecoupler} to thread receivers).
33
35
*
34
- * @author Pascal Christoph(dr0i)
36
+ * @author Pascal Christoph (dr0i)
35
37
*
36
38
*/
37
39
public final class ObjectThreaderTest {
@@ -59,7 +61,7 @@ public void shouldSplitAllObjectsToAllThreadedDownStreamReceivers() throws Inter
59
61
objectThreader .process ("a" );
60
62
objectThreader .process ("c" );
61
63
// check if two more threads were indeed created
62
- assert (Thread .getAllStackTraces ().keySet ().size () - ACTIVE_THREADS_AT_BEGINNING == 2 );
64
+ assertThat (Thread .getAllStackTraces ().keySet ().size () - ACTIVE_THREADS_AT_BEGINNING ). isEqualTo ( 2 );
63
65
objectThreader .closeStream ();
64
66
// verify thread 1
65
67
verify (receiverThread1 , atLeast (2 )).process ("a" );
You can’t perform that action at this time.
0 commit comments