@Test public void testExecute_WhenLabelHasMultipleSGMs_LabelIsNotDelete() throws Exception { Label label = new Label("labelName", "labelValue"); SecurityGroup sg = new SecurityGroup(null, null, null); sg.setName("sgName"); label.getSecurityGroupMembers().add(new SecurityGroupMember(sg, new Label(null, null))); 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, never()).remove(isA(Label.class)); verify(this.em, never()).remove(isA(Pod.class)); verify(this.em, never()).remove(isA(PodPort.class)); }
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();  }