use of com.cloud.projects.ProjectService in project cloudstack by apache.
the class ActivateProjectCmdTest method testGetEntityOwnerIdForProject.
@Test
public void testGetEntityOwnerIdForProject() {
Project project = Mockito.mock(Project.class);
Mockito.when(project.getId()).thenReturn(2L);
ProjectService projectService = Mockito.mock(ProjectService.class);
Account account = Mockito.mock(Account.class);
Mockito.when(account.getId()).thenReturn(2L);
Mockito.when(projectService.getProject(Matchers.anyLong())).thenReturn(project);
Mockito.when(projectService.getProjectOwner(Matchers.anyLong())).thenReturn(account);
activateProjectCmd._projectService = projectService;
Assert.assertEquals(2L, activateProjectCmd.getEntityOwnerId());
}
use of com.cloud.projects.ProjectService in project cloudstack by apache.
the class ActivateProjectCmdTest method testGetEntityOwnerIdForNullProject.
@Test
public void testGetEntityOwnerIdForNullProject() {
ProjectService projectService = Mockito.mock(ProjectService.class);
Mockito.when(projectService.getProject(Matchers.anyLong())).thenReturn(null);
activateProjectCmd._projectService = projectService;
try {
activateProjectCmd.getEntityOwnerId();
} catch (InvalidParameterValueException exception) {
Assert.assertEquals("Unable to find project by id 2", exception.getLocalizedMessage());
}
}
use of com.cloud.projects.ProjectService in project cloudstack by apache.
the class AddAccountToProjectCmdTest method testGetEntityOwnerIdForProject.
/****
* Condition not handled in the code
*
*****/
/*
* @Test public void testGetEntityOwnerIdForNullProject() {
*
* ProjectService projectService = Mockito.mock(ProjectService.class);
* Mockito
* .when(projectService.getProject(Mockito.anyLong())).thenReturn(null);
* addAccountToProjectCmd._projectService = projectService;
*
* try { addAccountToProjectCmd.getEntityOwnerId(); }
* catch(InvalidParameterValueException exception) {
* Assert.assertEquals("Unable to find project by id 2",
* exception.getLocalizedMessage()); }
*
* }
*/
@Test
public void testGetEntityOwnerIdForProject() {
Project project = Mockito.mock(Project.class);
Mockito.when(project.getId()).thenReturn(2L);
ProjectService projectService = Mockito.mock(ProjectService.class);
Account account = Mockito.mock(Account.class);
Mockito.when(account.getId()).thenReturn(2L);
Mockito.when(projectService.getProject(Matchers.anyLong())).thenReturn(project);
Mockito.when(projectService.getProjectOwner(Matchers.anyLong())).thenReturn(account);
addAccountToProjectCmd._projectService = projectService;
Assert.assertEquals(2L, addAccountToProjectCmd.getEntityOwnerId());
}
Aggregations