use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class SharedProcessorTest method testListenerAddition.
@Test
public void testListenerAddition() throws InterruptedException {
SharedProcessor<V1Pod> sharedProcessor = new SharedProcessor<>();
V1Pod foo1 = new V1Pod().metadata(new V1ObjectMeta().name("foo1").namespace("default"));
ProcessorListener.Notification<V1Pod> addNotification = new ProcessorListener.AddNotification<V1Pod>(foo1);
ProcessorListener.Notification<V1Pod> updateNotification = new ProcessorListener.UpdateNotification<V1Pod>(null, foo1);
ProcessorListener.Notification<V1Pod> deleteNotification = new ProcessorListener.DeleteNotification<V1Pod>(foo1);
ExpectingNoticationHandler<V1Pod> expectAddHandler = new ExpectingNoticationHandler<V1Pod>(addNotification);
ExpectingNoticationHandler<V1Pod> expectUpdateHandler = new ExpectingNoticationHandler<V1Pod>(updateNotification);
ExpectingNoticationHandler<V1Pod> expectDeleteHandler = new ExpectingNoticationHandler<V1Pod>(deleteNotification);
sharedProcessor.addAndStartListener(expectAddHandler);
sharedProcessor.addAndStartListener(expectUpdateHandler);
sharedProcessor.addAndStartListener(expectDeleteHandler);
sharedProcessor.distribute(addNotification, false);
sharedProcessor.distribute(updateNotification, false);
sharedProcessor.distribute(deleteNotification, false);
// sleep 1s for notification distribution completing
Thread.sleep(1000);
assertTrue(expectAddHandler.isSatisfied());
assertTrue(expectUpdateHandler.isSatisfied());
assertTrue(expectDeleteHandler.isSatisfied());
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class GenericKubernetesApiForCoreApiTest method createNamespacedPodReturningObject.
@Test
public void createNamespacedPodReturningObject() {
V1Pod foo1 = new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
stubFor(post(urlEqualTo("/api/v1/namespaces/default/pods")).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Pod> podListResp = podClient.create(foo1);
assertTrue(podListResp.isSuccess());
assertEquals(foo1, podListResp.getObject());
assertNull(podListResp.getStatus());
verify(1, postRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/pods")));
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class GenericKubernetesApiTest method createNamespacedJobReturningObject.
@Test
public void createNamespacedJobReturningObject() {
V1Job foo1 = new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
stubFor(post(urlEqualTo("/apis/batch/v1/namespaces/default/jobs")).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Job> jobListResp = jobClient.create(foo1);
assertTrue(jobListResp.isSuccess());
assertEquals(foo1, jobListResp.getObject());
assertNull(jobListResp.getStatus());
verify(1, postRequestedFor(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs")));
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class GenericKubernetesApiTest method updateNamespacedJobReturningObject.
@Test
public void updateNamespacedJobReturningObject() {
V1Job foo1 = new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
stubFor(put(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1")).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Job> jobListResp = jobClient.update(foo1);
assertTrue(jobListResp.isSuccess());
assertEquals(foo1, jobListResp.getObject());
assertNull(jobListResp.getStatus());
verify(1, putRequestedFor(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1")));
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class GenericKubernetesApiTest method patchNamespacedJobReturningObject.
@Test
public void patchNamespacedJobReturningObject() {
V1Patch v1Patch = new V1Patch("{}");
V1Job foo1 = new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
stubFor(patch(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1")).withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH)).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Job> jobPatchResp = jobClient.patch("default", "foo1", V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH, v1Patch);
assertTrue(jobPatchResp.isSuccess());
assertEquals(foo1, jobPatchResp.getObject());
assertNull(jobPatchResp.getStatus());
verify(1, patchRequestedFor(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1")));
}
Aggregations