diff --git a/server/src/test/java/org/apache/cloudstack/ca/CABackgroundTaskTest.java b/server/src/test/java/org/apache/cloudstack/ca/CABackgroundTaskTest.java index 063ff343ea2..c59ede2b810 100644 --- a/server/src/test/java/org/apache/cloudstack/ca/CABackgroundTaskTest.java +++ b/server/src/test/java/org/apache/cloudstack/ca/CABackgroundTaskTest.java @@ -20,6 +20,7 @@ package org.apache.cloudstack.ca; import static org.apache.cloudstack.ca.CAManager.AutomaticCertRenewal; +import static org.hamcrest.Matchers.is; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.nullable; @@ -36,6 +37,7 @@ import org.apache.cloudstack.utils.identity.ManagementServerNode; import org.apache.cloudstack.utils.security.CertUtils; import org.junit.After; import org.junit.Assert; +import org.junit.Assume; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -93,7 +95,7 @@ public class CABackgroundTaskTest { @Test public void testNullCert() throws Exception { certMap.put(hostIp, null); - Assert.assertTrue(certMap.size() == 1); + Assume.assumeThat(certMap.size() == 1, is(true)); task.runInContext(); Assert.assertTrue(certMap.size() == 0); } @@ -102,7 +104,7 @@ public class CABackgroundTaskTest { public void testNullHost() throws Exception { Mockito.when(hostDao.findByIp(Mockito.anyString())).thenReturn(null); certMap.put(hostIp, expiredCertificate); - Assert.assertTrue(certMap.size() == 1); + Assume.assumeThat(certMap.size() == 1, is(true)); task.runInContext(); Assert.assertTrue(certMap.size() == 0); } @@ -112,7 +114,7 @@ public class CABackgroundTaskTest { overrideDefaultConfigValue(AutomaticCertRenewal, "_defaultValue", "true"); host.setManagementServerId(ManagementServerNode.getManagementServerId()); certMap.put(hostIp, expiredCertificate); - Assert.assertTrue(certMap.size() == 1); + Assume.assumeThat(certMap.size() == 1, is(true)); task.runInContext(); Mockito.verify(caManager, Mockito.times(1)).provisionCertificate(host, false, null); Mockito.verify(caManager, Mockito.times(0)).sendAlert(Mockito.any(Host.class), Mockito.anyString(), Mockito.anyString()); @@ -124,7 +126,7 @@ public class CABackgroundTaskTest { Mockito.when(caManager.provisionCertificate(any(Host.class), anyBoolean(), nullable(String.class))).thenThrow(new CloudRuntimeException("some error")); host.setManagementServerId(ManagementServerNode.getManagementServerId()); certMap.put(hostIp, expiredCertificate); - Assert.assertTrue(certMap.size() == 1); + Assume.assumeThat(certMap.size() == 1, is(true)); task.runInContext(); Mockito.verify(caManager, Mockito.times(1)).provisionCertificate(host, false, null); Mockito.verify(caManager, Mockito.times(1)).sendAlert(Mockito.any(Host.class), Mockito.anyString(), Mockito.anyString()); @@ -134,7 +136,7 @@ public class CABackgroundTaskTest { public void testAutoRenewalDisabled() throws Exception { overrideDefaultConfigValue(AutomaticCertRenewal, "_defaultValue", "false"); certMap.put(hostIp, expiredCertificate); - Assert.assertTrue(certMap.size() == 1); + Assume.assumeThat(certMap.size() == 1, is(true)); // First round task.runInContext(); Mockito.verify(caManager, Mockito.times(0)).provisionCertificate(Mockito.any(Host.class), anyBoolean(), Mockito.anyString());