@Test public void testExecute_WithAValidExistingPod_LabelIsUpdatedWithExistingPod() throws Exception { CreateK8sLabelPodTask task = this.factoryTask.create(SAME_SG_ALREADY_PROTECTED_K8S_POD, VALID_EXISTING_POD_SGM_LABEL); NetworkElement podPort = SAME_SG_ALREADY_PROTECTED_POD_NETWORK_ELEMENT; registerNetworkElement(VALID_EXISTING_POD_SGM_LABEL.getSecurityGroupMembers().iterator().next(), podPort, SAME_SG_ALREADY_PROTECTED_K8S_POD); task.execute(); Pod updatedPod = PodEntityMgr.findExternalId(this.em, SAME_SG_ALREADY_PROTECTED_K8S_POD.getUid()); Assert.assertNotNull("The updated pod should no be null", updatedPod); Assert.assertTrue("The updated pod is different than expected", isExpectedPod(updatedPod, SAME_SG_ALREADY_PROTECTED_K8S_POD, podPort)); Label updatedLabel = this.em.find(Label.class, VALID_EXISTING_POD_SGM_LABEL.getId()); Assert.assertTrue("The label SGM should contain the created pod", updatedLabel.getPods().contains(updatedPod)); Assert.assertTrue("", updatedPod.getLabels().contains(EXISTING_PROTECTED_POD_SAME_SG_LABEL)); Assert.assertTrue("", updatedPod.getLabels().contains(VALID_EXISTING_POD_SGM_LABEL)); }
public CreateK8sLabelPodTask create(KubernetesPod k8sPod, Label label) { CreateK8sLabelPodTask task = new CreateK8sLabelPodTask(); task.k8sPod = k8sPod; task.label = label; task.apiFactoryService = this.apiFactoryService; task.dbConnectionManager = this.dbConnectionManager; task.txBroadcastUtil = this.txBroadcastUtil; return task; }
CreateK8sLabelPodTask extends TransactionalTask { public CreateK8sLabelPodTask create(KubernetesPod k8sPod, Label label) { CreateK8sLabelPodTask task = new CreateK8sLabelPodTask(); task.k8sPod = k8sPod; task.label = label; task.apiFactoryService = this.apiFactoryService; task.dbConnectionManager = this.dbConnectionManager; task.txBroadcastUtil = this.txBroadcastUtil; return task; } }
CreateK8sLabelPodTask extends TransactionalTask { public CreateK8sLabelPodTask create(KubernetesPod k8sPod, Label label) { CreateK8sLabelPodTask task = new CreateK8sLabelPodTask(); task.k8sPod = k8sPod; task.label = label; task.apiFactoryService = this.apiFactoryService; task.dbConnectionManager = this.dbConnectionManager; task.txBroadcastUtil = this.txBroadcastUtil; return task; }  }
CreateK8sLabelPodTask extends TransactionalTask { public CreateK8sLabelPodTask create(KubernetesPod k8sPod, Label label) { CreateK8sLabelPodTask task = new CreateK8sLabelPodTask(); task.k8sPod = k8sPod; task.label = label; task.apiFactoryService = this.apiFactoryService; task.dbConnectionManager = this.dbConnectionManager; task.txBroadcastUtil = this.txBroadcastUtil; return task; }  @Override void executeTransaction(EntityManager em); CreateK8sLabelPodTask create(KubernetesPod k8sPod, Label label); @Override String getName(); @Override Set<LockObjectReference> getObjects(); }
CreateK8sLabelPodTask extends TransactionalTask { public CreateK8sLabelPodTask create(KubernetesPod k8sPod, Label label) { CreateK8sLabelPodTask task = new CreateK8sLabelPodTask(); task.k8sPod = k8sPod; task.label = label; task.apiFactoryService = this.apiFactoryService; task.dbConnectionManager = this.dbConnectionManager; task.txBroadcastUtil = this.txBroadcastUtil; return task; }  @Override void executeTransaction(EntityManager em); CreateK8sLabelPodTask create(KubernetesPod k8sPod, Label label); @Override String getName(); @Override Set<LockObjectReference> getObjects();  }