|
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 |
|
| 39 | + public static final String RESOURCE_URI = |
| 40 | + "https://kubernetes.docker.internal:6443/apis/tomcatoperator.io/v1/tomcats"; |
| 41 | + |
34 | 42 | @Test
|
35 | 43 | void defaultReconcilerNameShouldWork() {
|
36 | 44 | assertEquals(
|
@@ -113,10 +121,13 @@ private Deployment createTestDeployment() {
|
113 | 121 |
|
114 | 122 | @Test
|
115 | 123 | void handleKubernetesExceptionShouldThrowMissingCRDExceptionWhenAppropriate() {
|
| 124 | + var request = mock(HttpRequest.class); |
| 125 | + when(request.uri()).thenReturn(URI |
| 126 | + .create(RESOURCE_URI)); |
116 | 127 | assertThrows(MissingCRDException.class, () -> handleKubernetesClientException(
|
117 | 128 | new KubernetesClientException(
|
118 |
| - "Failure executing: GET at: https://kubernetes.docker.internal:6443/apis/tomcatoperator.io/v1/tomcats. Message: Not Found.", |
119 |
| - 404, null), |
| 129 | + "Failure executing: GET at: " + RESOURCE_URI + ". Message: Not Found.", |
| 130 | + null, 404, null, request), |
120 | 131 | HasMetadata.getFullResourceName(Tomcat.class)));
|
121 | 132 | }
|
122 | 133 |
|
|
0 commit comments