Source:
<code>public void testCreateOrReplace() throws IOException { String jsonObject = "{\"apiVersion\": \"test.fabric8.io/v1alpha1\",\"kind\": \"Hello\"," + <START> "\"metadata\": {\"resourceVersion\":\"1\", \"name\": \"example-hello\"},\"spec\": {\"size\": 3, \"scope\": \"Namespaced\"}}"; <END> server.expect().post().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos").andReturn(HttpURLConnection.HTTP_INTERNAL_ERROR, new StatusBuilder().build()).once(); server.expect().post().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos").andReturn(HttpURLConnection.HTTP_CREATED, jsonObject).once(); server.expect().post().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos").andReturn(HttpURLConnection.HTTP_CONFLICT, jsonObject).once(); server.expect().put().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, jsonObject).once(); server.expect().get().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, jsonObject).once(); KubernetesClient client = server.getClient(); KubernetesClientException exception = Assertions.assertThrows(KubernetesClientException.class, () -> client.customResource(customResourceDefinitionContext).createOrReplace("ns1", jsonObject)); assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, exception.getCode()); Map<String, Object> resource = client.customResource(customResourceDefinitionContext).createOrReplace("ns1", jsonObject); assertEquals("example-hello", ((Map<String, Object>)resource.get("metadata")).get("name").toString()); resource = client.customResource(customResourceDefinitionContext).createOrReplace("ns1", jsonObject); assertEquals("example-hello", ((Map<String, Object>)resource.get("metadata")).get("name").toString()); }</code><technical_language>Hi, added scope: Namespaced in CustomResource's body? Is this intentional</technical_language>

Target:
public void testCreateOrReplace() throws IOException { String jsonObject = "{\"apiVersion\": \"test.fabric8.io/v1alpha1\",\"kind\": \"Hello\"," + "\"metadata\": {\"resourceVersion\":\"1\", \"name\": \"example-hello\"},\"spec\": {\"size\": 3}}"; server.expect().post().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos").andReturn(HttpURLConnection.HTTP_INTERNAL_ERROR, new StatusBuilder().build()).once(); server.expect().post().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos").andReturn(HttpURLConnection.HTTP_CREATED, jsonObject).once(); server.expect().post().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos").andReturn(HttpURLConnection.HTTP_CONFLICT, jsonObject).once(); server.expect().put().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, jsonObject).once(); server.expect().get().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello").andReturn(HttpURLConnection.HTTP_OK, jsonObject).once(); KubernetesClient client = server.getClient(); KubernetesClientException exception = Assertions.assertThrows(KubernetesClientException.class, () -> client.customResource(customResourceDefinitionContext).createOrReplace("ns1", jsonObject)); assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, exception.getCode()); Map<String, Object> resource = client.customResource(customResourceDefinitionContext).createOrReplace("ns1", jsonObject); assertEquals("example-hello", ((Map<String, Object>)resource.get("metadata")).get("name").toString()); resource = client.customResource(customResourceDefinitionContext).createOrReplace("ns1", jsonObject); assertEquals("example-hello", ((Map<String, Object>)resource.get("metadata")).get("name").toString()); }