File tree 2 files changed +5
-4
lines changed
operator-framework-core/src
main/java/io/javaoperatorsdk/operator/processing/event
test/java/io/javaoperatorsdk/operator/processing/event
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 16
16
17
17
class EventSources <R extends HasMetadata > implements Iterable <NamedEventSource > {
18
18
19
+ private static final String CONTROLLER_EVENT_SOURCE_KEY = "0" ;
19
20
private final ConcurrentNavigableMap <String , Map <String , EventSource >> sources =
20
21
new ConcurrentSkipListMap <>();
21
22
private final TimerEventSource <R > retryAndRescheduleTimerEventSource = new TimerEventSource <>();
@@ -80,6 +81,9 @@ private Class<?> getResourceType(EventSource source) {
80
81
}
81
82
82
83
private String keyFor (EventSource source ) {
84
+ if (source instanceof ControllerResourceEventSource ) {
85
+ return CONTROLLER_EVENT_SOURCE_KEY ;
86
+ }
83
87
return keyFor (getResourceType (source ));
84
88
}
85
89
Original file line number Diff line number Diff line change @@ -76,17 +76,14 @@ void retrievingEventSourceForClassShouldWork() {
76
76
77
77
// manager is initialized with a controller configured to handle HasMetadata
78
78
EventSourceManager manager = initManager ();
79
- EventSource source = manager .getResourceEventSourceFor (HasMetadata .class );
80
- assertThat (source ).isInstanceOf (ControllerResourceEventSource .class );
81
-
82
79
assertThatExceptionOfType (IllegalArgumentException .class )
83
80
.isThrownBy (() -> manager .getResourceEventSourceFor (HasMetadata .class , "unknown_name" ));
84
81
85
82
CachingEventSource eventSource = mock (CachingEventSource .class );
86
83
when (eventSource .resourceType ()).thenReturn (String .class );
87
84
manager .registerEventSource (eventSource );
88
85
89
- source = manager .getResourceEventSourceFor (String .class );
86
+ var source = manager .getResourceEventSourceFor (String .class );
90
87
assertThat (source ).isNotNull ();
91
88
assertEquals (eventSource , source );
92
89
}
You can’t perform that action at this time.
0 commit comments