-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
- Loading branch information
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...ork-core/src/test/java/io/javaoperatorsdk/operator/api/reconciler/DefaultContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.javaoperatorsdk.operator.api.reconciler; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.fabric8.kubernetes.api.model.ConfigMap; | ||
import io.fabric8.kubernetes.api.model.Secret; | ||
import io.javaoperatorsdk.operator.processing.Controller; | ||
import io.javaoperatorsdk.operator.processing.event.EventSourceManager; | ||
import io.javaoperatorsdk.operator.processing.event.NoEventSourceForClassException; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class DefaultContextTest { | ||
|
||
Secret primary = new Secret(); | ||
Controller<Secret> mockController = mock(Controller.class); | ||
|
||
DefaultContext<?> context = new DefaultContext<>(null, mockController, primary); | ||
|
||
@Test | ||
void getSecondaryResourceReturnsEmptyOptionalOnNonActivatedDRType() { | ||
var mockManager = mock(EventSourceManager.class); | ||
when(mockController.getEventSourceManager()).thenReturn(mockManager); | ||
when(mockController.workflowContainsDependentForType(ConfigMap.class)).thenReturn(true); | ||
when(mockManager.getEventSourceFor(any(), any())) | ||
.thenThrow(new NoEventSourceForClassException(ConfigMap.class)); | ||
|
||
var res = context.getSecondaryResource(ConfigMap.class); | ||
|
||
assertThat(res).isEmpty(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters