Search in sources :

Example 1 with DeleteKubernetesSupportedVersionCmd

use of org.apache.cloudstack.api.command.admin.kubernetes.version.DeleteKubernetesSupportedVersionCmd in project cloudstack by apache.

the class KubernetesVersionServiceTest method deleteKubernetesSupportedVersionExistingClustersTest.

@Test(expected = CloudRuntimeException.class)
public void deleteKubernetesSupportedVersionExistingClustersTest() {
    DeleteKubernetesSupportedVersionCmd cmd = Mockito.mock(DeleteKubernetesSupportedVersionCmd.class);
    AccountVO account = new AccountVO("admin", 1L, "", Account.ACCOUNT_TYPE_ADMIN, "uuid");
    UserVO user = new UserVO(1, "adminuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
    CallContext.register(user, account);
    when(kubernetesSupportedVersionDao.findById(Mockito.anyLong())).thenReturn(Mockito.mock(KubernetesSupportedVersionVO.class));
    List<KubernetesClusterVO> clusters = new ArrayList<>();
    clusters.add(Mockito.mock(KubernetesClusterVO.class));
    when(kubernetesClusterDao.listAllByKubernetesVersion(Mockito.anyLong())).thenReturn(clusters);
    kubernetesVersionService.deleteKubernetesSupportedVersion(cmd);
}
Also used : UserVO(com.cloud.user.UserVO) KubernetesClusterVO(com.cloud.kubernetes.cluster.KubernetesClusterVO) ArrayList(java.util.ArrayList) DeleteKubernetesSupportedVersionCmd(org.apache.cloudstack.api.command.admin.kubernetes.version.DeleteKubernetesSupportedVersionCmd) AccountVO(com.cloud.user.AccountVO) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with DeleteKubernetesSupportedVersionCmd

use of org.apache.cloudstack.api.command.admin.kubernetes.version.DeleteKubernetesSupportedVersionCmd in project cloudstack by apache.

the class KubernetesVersionServiceTest method deleteKubernetesSupportedVersionTest.

@Test
public void deleteKubernetesSupportedVersionTest() {
    DeleteKubernetesSupportedVersionCmd cmd = Mockito.mock(DeleteKubernetesSupportedVersionCmd.class);
    AccountVO account = new AccountVO("admin", 1L, "", Account.ACCOUNT_TYPE_ADMIN, "uuid");
    UserVO user = new UserVO(1, "adminuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
    CallContext.register(user, account);
    when(kubernetesSupportedVersionDao.findById(Mockito.anyLong())).thenReturn(Mockito.mock(KubernetesSupportedVersionVO.class));
    List<KubernetesClusterVO> clusters = new ArrayList<>();
    when(kubernetesClusterDao.listAllByKubernetesVersion(Mockito.anyLong())).thenReturn(clusters);
    when(templateDao.findById(Mockito.anyLong())).thenReturn(Mockito.mock(VMTemplateVO.class));
    PowerMockito.mockStatic(ComponentContext.class);
    when(ComponentContext.inject(Mockito.any(DeleteIsoCmd.class))).thenReturn(new DeleteIsoCmd());
    when(templateService.deleteIso(Mockito.any(DeleteIsoCmd.class))).thenReturn(true);
    when(kubernetesClusterDao.remove(Mockito.anyLong())).thenReturn(true);
    kubernetesVersionService.deleteKubernetesSupportedVersion(cmd);
}
Also used : UserVO(com.cloud.user.UserVO) KubernetesClusterVO(com.cloud.kubernetes.cluster.KubernetesClusterVO) ArrayList(java.util.ArrayList) VMTemplateVO(com.cloud.storage.VMTemplateVO) DeleteKubernetesSupportedVersionCmd(org.apache.cloudstack.api.command.admin.kubernetes.version.DeleteKubernetesSupportedVersionCmd) AccountVO(com.cloud.user.AccountVO) DeleteIsoCmd(org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

KubernetesClusterVO (com.cloud.kubernetes.cluster.KubernetesClusterVO)2 AccountVO (com.cloud.user.AccountVO)2 UserVO (com.cloud.user.UserVO)2 ArrayList (java.util.ArrayList)2 DeleteKubernetesSupportedVersionCmd (org.apache.cloudstack.api.command.admin.kubernetes.version.DeleteKubernetesSupportedVersionCmd)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 VMTemplateVO (com.cloud.storage.VMTemplateVO)1 DeleteIsoCmd (org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd)1