|
1 | 1 | package io.javaoperatorsdk.operator; |
2 | 2 |
|
| 3 | +import java.net.URI; |
| 4 | + |
3 | 5 | import org.junit.jupiter.api.Test; |
4 | 6 |
|
5 | 7 | import io.fabric8.kubernetes.api.model.ContainerBuilder; |
|
13 | 15 | import io.fabric8.kubernetes.api.model.apps.DeploymentSpec; |
14 | 16 | import io.fabric8.kubernetes.client.CustomResource; |
15 | 17 | import io.fabric8.kubernetes.client.KubernetesClientException; |
| 18 | +import io.fabric8.kubernetes.client.http.HttpRequest; |
16 | 19 | import io.fabric8.kubernetes.model.annotation.Group; |
17 | 20 | import io.fabric8.kubernetes.model.annotation.ShortNames; |
18 | 21 | import io.fabric8.kubernetes.model.annotation.Version; |
|
28 | 31 | import static org.junit.jupiter.api.Assertions.assertEquals; |
29 | 32 | import static org.junit.jupiter.api.Assertions.assertThrows; |
30 | 33 | import static org.junit.jupiter.api.Assertions.assertTrue; |
| 34 | +import static org.mockito.Mockito.mock; |
| 35 | +import static org.mockito.Mockito.when; |
31 | 36 |
|
32 | 37 | class ReconcilerUtilsTest { |
33 | 38 |
|
@@ -116,10 +121,13 @@ private Deployment createTestDeployment() { |
116 | 121 |
|
117 | 122 | @Test |
118 | 123 | void handleKubernetesExceptionShouldThrowMissingCRDExceptionWhenAppropriate() { |
| 124 | + var request = mock(HttpRequest.class); |
| 125 | + when(request.uri()).thenReturn(URI |
| 126 | + .create(RESOURCE_URI)); |
119 | 127 | assertThrows(MissingCRDException.class, () -> handleKubernetesClientException( |
120 | 128 | new KubernetesClientException( |
121 | | - "Failure executing: GET at: https://kubernetes.docker.internal:6443/apis/tomcatoperator.io/v1/tomcats. Message: Not Found.", |
122 | | - 404, null), |
| 129 | + "Failure executing: GET at: " + RESOURCE_URI + ". Message: Not Found.", |
| 130 | + null, 404, null, request), |
123 | 131 | HasMetadata.getFullResourceName(Tomcat.class))); |
124 | 132 | } |
125 | 133 |
|
|
0 commit comments