@@ -651,7 +651,7 @@ public void testValidateNodeAffinityGroupsAntiAffinityNewNodeOnExistingHost() {
651651 public void testValidateNodeAffinityGroupsAntiAffinityNewNodeOnDifferentHost () {
652652 KubernetesCluster cluster = Mockito .mock (KubernetesCluster .class );
653653 Mockito .when (cluster .getId ()).thenReturn (1L );
654- Mockito .when (cluster .getName ()).thenReturn ("test-cluster" );
654+ Mockito .lenient (). when (cluster .getName ()).thenReturn ("test-cluster" );
655655
656656 Long newNodeId = 100L ;
657657 Long existingWorkerVmId = 200L ;
@@ -660,7 +660,7 @@ public void testValidateNodeAffinityGroupsAntiAffinityNewNodeOnDifferentHost() {
660660
661661 AffinityGroupVO affinityGroup = Mockito .mock (AffinityGroupVO .class );
662662 Mockito .when (affinityGroup .getType ()).thenReturn ("host anti-affinity" );
663- Mockito .when (affinityGroup .getName ()).thenReturn ("anti-affinity-group" );
663+ Mockito .lenient (). when (affinityGroup .getName ()).thenReturn ("anti-affinity-group" );
664664
665665 VMInstanceVO newNode = Mockito .mock (VMInstanceVO .class );
666666 Mockito .when (newNode .getHostId ()).thenReturn (newNodeHostId );
@@ -688,15 +688,15 @@ public void testValidateNodeAffinityGroupsAntiAffinityNewNodeOnDifferentHost() {
688688 public void testValidateNodeAffinityGroupsAffinityNewNodeOnSameHost () {
689689 KubernetesCluster cluster = Mockito .mock (KubernetesCluster .class );
690690 Mockito .when (cluster .getId ()).thenReturn (1L );
691- Mockito .when (cluster .getName ()).thenReturn ("test-cluster" );
691+ Mockito .lenient (). when (cluster .getName ()).thenReturn ("test-cluster" );
692692
693693 Long newNodeId = 100L ;
694694 Long existingWorkerVmId = 200L ;
695695 Long sharedHostId = 1000L ;
696696
697697 AffinityGroupVO affinityGroup = Mockito .mock (AffinityGroupVO .class );
698698 Mockito .when (affinityGroup .getType ()).thenReturn ("host affinity" );
699- Mockito .when (affinityGroup .getName ()).thenReturn ("affinity-group" );
699+ Mockito .lenient (). when (affinityGroup .getName ()).thenReturn ("affinity-group" );
700700
701701 VMInstanceVO newNode = Mockito .mock (VMInstanceVO .class );
702702 Mockito .when (newNode .getHostId ()).thenReturn (sharedHostId );
@@ -775,12 +775,12 @@ public void testValidateNodeAffinityGroupsAntiAffinityMultipleNewNodesOnSameHost
775775 Long sharedHostId = 1000L ;
776776
777777 AffinityGroupVO affinityGroup = Mockito .mock (AffinityGroupVO .class );
778- Mockito .when (affinityGroup .getType ()).thenReturn ("host anti-affinity" );
778+ Mockito .lenient (). when (affinityGroup .getType ()).thenReturn ("host anti-affinity" );
779779 Mockito .when (affinityGroup .getName ()).thenReturn ("anti-affinity-group" );
780780
781781 VMInstanceVO newNode1 = Mockito .mock (VMInstanceVO .class );
782782 Mockito .when (newNode1 .getHostId ()).thenReturn (sharedHostId );
783- Mockito .when (newNode1 .getInstanceName ()).thenReturn ("new-node-vm-1" );
783+ Mockito .lenient (). when (newNode1 .getInstanceName ()).thenReturn ("new-node-vm-1" );
784784
785785 VMInstanceVO newNode2 = Mockito .mock (VMInstanceVO .class );
786786 Mockito .when (newNode2 .getHostId ()).thenReturn (sharedHostId );
@@ -805,16 +805,16 @@ public void testValidateNodeAffinityGroupsAntiAffinityMultipleNewNodesOnSameHost
805805 public void testValidateNodeAffinityGroupsAntiAffinityMultipleNewNodesOnDifferentHosts () {
806806 KubernetesCluster cluster = Mockito .mock (KubernetesCluster .class );
807807 Mockito .when (cluster .getId ()).thenReturn (1L );
808- Mockito .when (cluster .getName ()).thenReturn ("test-cluster" );
808+ Mockito .lenient (). when (cluster .getName ()).thenReturn ("test-cluster" );
809809
810810 Long newNodeId1 = 100L ;
811811 Long newNodeId2 = 101L ;
812812 Long hostId1 = 1000L ;
813813 Long hostId2 = 1001L ;
814814
815815 AffinityGroupVO affinityGroup = Mockito .mock (AffinityGroupVO .class );
816- Mockito .when (affinityGroup .getType ()).thenReturn ("host anti-affinity" );
817- Mockito .when (affinityGroup .getName ()).thenReturn ("anti-affinity-group" );
816+ Mockito .lenient (). when (affinityGroup .getType ()).thenReturn ("host anti-affinity" );
817+ Mockito .lenient (). when (affinityGroup .getName ()).thenReturn ("anti-affinity-group" );
818818
819819 VMInstanceVO newNode1 = Mockito .mock (VMInstanceVO .class );
820820 Mockito .when (newNode1 .getHostId ()).thenReturn (hostId1 );
@@ -839,13 +839,13 @@ public void testValidateNodeAffinityGroupsAntiAffinityMultipleNewNodesOnDifferen
839839 public void testValidateNodeAffinityGroupsNodeWithNullHost () {
840840 KubernetesCluster cluster = Mockito .mock (KubernetesCluster .class );
841841 Mockito .when (cluster .getId ()).thenReturn (1L );
842- Mockito .when (cluster .getName ()).thenReturn ("test-cluster" );
842+ Mockito .lenient (). when (cluster .getName ()).thenReturn ("test-cluster" );
843843
844844 Long newNodeId = 100L ;
845845
846846 AffinityGroupVO affinityGroup = Mockito .mock (AffinityGroupVO .class );
847- Mockito .when (affinityGroup .getType ()).thenReturn ("host anti-affinity" );
848- Mockito .when (affinityGroup .getName ()).thenReturn ("anti-affinity-group" );
847+ Mockito .lenient (). when (affinityGroup .getType ()).thenReturn ("host anti-affinity" );
848+ Mockito .lenient (). when (affinityGroup .getName ()).thenReturn ("anti-affinity-group" );
849849
850850 VMInstanceVO newNode = Mockito .mock (VMInstanceVO .class );
851851 Mockito .when (newNode .getHostId ()).thenReturn (null );
@@ -859,20 +859,20 @@ public void testValidateNodeAffinityGroupsNodeWithNullHost() {
859859
860860 kubernetesClusterManager .validateNodeAffinityGroups (Arrays .asList (newNodeId ), cluster );
861861
862- Mockito .verify (vmInstanceDao ).findById (newNodeId );
862+ Mockito .verify (vmInstanceDao , Mockito . atLeastOnce () ).findById (newNodeId );
863863 }
864864
865865 @ Test
866866 public void testValidateNodeAffinityGroupsNullNode () {
867867 KubernetesCluster cluster = Mockito .mock (KubernetesCluster .class );
868868 Mockito .when (cluster .getId ()).thenReturn (1L );
869- Mockito .when (cluster .getName ()).thenReturn ("test-cluster" );
869+ Mockito .lenient (). when (cluster .getName ()).thenReturn ("test-cluster" );
870870
871871 Long newNodeId = 100L ;
872872
873873 AffinityGroupVO affinityGroup = Mockito .mock (AffinityGroupVO .class );
874- Mockito .when (affinityGroup .getType ()).thenReturn ("host anti-affinity" );
875- Mockito .when (affinityGroup .getName ()).thenReturn ("anti-affinity-group" );
874+ Mockito .lenient (). when (affinityGroup .getType ()).thenReturn ("host anti-affinity" );
875+ Mockito .lenient (). when (affinityGroup .getName ()).thenReturn ("anti-affinity-group" );
876876
877877 Mockito .when (kubernetesClusterAffinityGroupMapDao .listAffinityGroupIdsByClusterIdAndNodeType (1L , WORKER .name ()))
878878 .thenReturn (Arrays .asList (10L ));
@@ -883,21 +883,21 @@ public void testValidateNodeAffinityGroupsNullNode() {
883883
884884 kubernetesClusterManager .validateNodeAffinityGroups (Arrays .asList (newNodeId ), cluster );
885885
886- Mockito .verify (vmInstanceDao ).findById (newNodeId );
886+ Mockito .verify (vmInstanceDao , Mockito . atLeastOnce () ).findById (newNodeId );
887887 }
888888
889889 @ Test
890890 public void testValidateNodeAffinityGroupsAffinityNoExistingWorkers () {
891891 KubernetesCluster cluster = Mockito .mock (KubernetesCluster .class );
892892 Mockito .when (cluster .getId ()).thenReturn (1L );
893- Mockito .when (cluster .getName ()).thenReturn ("test-cluster" );
893+ Mockito .lenient (). when (cluster .getName ()).thenReturn ("test-cluster" );
894894
895895 Long newNodeId = 100L ;
896896 Long newNodeHostId = 1000L ;
897897
898898 AffinityGroupVO affinityGroup = Mockito .mock (AffinityGroupVO .class );
899- Mockito .when (affinityGroup .getType ()).thenReturn ("host affinity" );
900- Mockito .when (affinityGroup .getName ()).thenReturn ("affinity-group" );
899+ Mockito .lenient (). when (affinityGroup .getType ()).thenReturn ("host affinity" );
900+ Mockito .lenient (). when (affinityGroup .getName ()).thenReturn ("affinity-group" );
901901
902902 VMInstanceVO newNode = Mockito .mock (VMInstanceVO .class );
903903 Mockito .when (newNode .getHostId ()).thenReturn (newNodeHostId );
0 commit comments