@Test public void testExecute_WhenLabelHasExclusivePod_WhenPodPortHasAssignedDAI_ProtectedPodPortIsUnassignedFromDAI() throws Exception { Label label = new Label("labelName", "labelValue"); Pod pod = new Pod("name", "namespace", "node", "externalId"); pod.setId(101L); pod.getLabels().add(label); PodPort podPort = new PodPort("externalId", "macAddress", "ipAddress", "parentId"); podPort.setId(102L); pod.getPorts().add(podPort); DistributedApplianceInstance dai = new DistributedApplianceInstance(); dai.addProtectedPort(podPort); dai.setId(200L); podPort.getDais().add(dai); label.getPods().add(pod); SecurityGroup sg = new SecurityGroup(null, null, null); sg.setName("sgName"); SecurityGroupMember sgm = new SecurityGroupMember(sg, label); label.getSecurityGroupMembers().add(sgm); sgm.setId(100L); when(this.em.find(SecurityGroupMember.class, sgm.getId())).thenReturn(sgm); SecurityGroupMemberDeleteTask task = this.factoryTask.create(sgm); task.execute(); verify(this.em, times(1)).remove(sgm); verify(this.em, times(1)).remove(label); verify(this.em, times(1)).remove(pod); verify(this.em, times(1)).remove(podPort); verify(this.em, times(1)).merge(dai); Assert.assertTrue("The DAI should not have any protected port.", dai.getProtectedPorts().isEmpty()); }
public SecurityGroupMemberDeleteTask create(SecurityGroupMember sgm) { SecurityGroupMemberDeleteTask task = new SecurityGroupMemberDeleteTask(); task.sgm = sgm; task.dbConnectionManager = this.dbConnectionManager; task.txBroadcastUtil = this.txBroadcastUtil; return task; }
SecurityGroupMemberDeleteTask extends TransactionalTask { public SecurityGroupMemberDeleteTask create(SecurityGroupMember sgm) { SecurityGroupMemberDeleteTask task = new SecurityGroupMemberDeleteTask(); task.sgm = sgm; task.dbConnectionManager = this.dbConnectionManager; task.txBroadcastUtil = this.txBroadcastUtil; return task; } }
SecurityGroupMemberDeleteTask extends TransactionalTask { public SecurityGroupMemberDeleteTask create(SecurityGroupMember sgm) { SecurityGroupMemberDeleteTask task = new SecurityGroupMemberDeleteTask(); task.sgm = sgm; task.dbConnectionManager = this.dbConnectionManager; task.txBroadcastUtil = this.txBroadcastUtil; return task; }  }
SecurityGroupMemberDeleteTask extends TransactionalTask { public SecurityGroupMemberDeleteTask create(SecurityGroupMember sgm) { SecurityGroupMemberDeleteTask task = new SecurityGroupMemberDeleteTask(); task.sgm = sgm; task.dbConnectionManager = this.dbConnectionManager; task.txBroadcastUtil = this.txBroadcastUtil; return task; }  SecurityGroupMemberDeleteTask create(SecurityGroupMember sgm); @Override void executeTransaction(EntityManager em); @Override String getName(); @Override Set<LockObjectReference> getObjects(); }
SecurityGroupMemberDeleteTask extends TransactionalTask { public SecurityGroupMemberDeleteTask create(SecurityGroupMember sgm) { SecurityGroupMemberDeleteTask task = new SecurityGroupMemberDeleteTask(); task.sgm = sgm; task.dbConnectionManager = this.dbConnectionManager; task.txBroadcastUtil = this.txBroadcastUtil; return task; }  SecurityGroupMemberDeleteTask create(SecurityGroupMember sgm); @Override void executeTransaction(EntityManager em); @Override String getName(); @Override Set<LockObjectReference> getObjects();  }