use of org.hudsonci.service.ProjectService in project hudson-2.x by hudson.
the class ProjectServiceImplTest method createProjectFromXMLToProjectAlreadyExists.
@Test(expected = SystemIntegrityViolationException.class)
public void createProjectFromXMLToProjectAlreadyExists() throws IOException {
ProjectService inst = spy(getInst());
doReturn(true).when(inst).projectExists("toProject");
inst.createProjectFromXML("toProject", input);
}
use of org.hudsonci.service.ProjectService in project hudson-2.x by hudson.
the class ProjectServiceImplTest method getProjectByUUIDNotFound.
@Test(expected = ProjectNotFoundException.class)
public void getProjectByUUIDNotFound() {
ProjectService inst = spy(getInst());
UUID id = UUID.randomUUID();
doReturn(null).when(inst).findProject(id);
inst.getProject(id);
}
use of org.hudsonci.service.ProjectService in project hudson-2.x by hudson.
the class ProjectServiceImplTest method copyProjectSecurity.
@Test
public void copyProjectSecurity() throws IOException {
// mocks
AbstractProject<?, ?> toProject = Mockito.mock(AbstractProject.class);
ProjectService inst = spy(getInst());
// make method succeed
doReturn(false).when(inst).projectExists("toProject");
when(hudson.copy(project, "toProject")).thenReturn(toProject);
// test
inst.copyProject(project, "toProject");
// verify
Mockito.verify(securityService).checkPermission(Item.CREATE);
Mockito.verify(securityService).checkPermission(project, Item.EXTENDED_READ);
}
use of org.hudsonci.service.ProjectService in project hudson-2.x by hudson.
the class ProjectServiceImplTest method findProjectByProjectNameSecurity.
@Test
public void findProjectByProjectNameSecurity() {
ProjectService inst = spy(getInst());
doReturn(project).when(hudson).getItemByFullName("projectName", AbstractProject.class);
@SuppressWarnings("unchecked") Collection<String> names = Mockito.mock(Collection.class);
when(names.contains("projectName")).thenReturn(true);
when(inst.getProjectNames()).thenReturn(names);
AbstractProject<?, ?> result = getInst().findProject("projectName");
assertThat(result, equalTo(project));
Mockito.verify(securityService).checkPermission(project, Item.READ);
}
use of org.hudsonci.service.ProjectService in project hudson-2.x by hudson.
the class ProjectServiceImplTest method createProjectFromXMLIOException.
@Test(expected = ServiceRuntimeException.class)
public void createProjectFromXMLIOException() throws IOException {
// mocks
ProjectService inst = spy(getInst());
// make method succeed
doReturn(false).when(inst).projectExists("toProject");
when(hudson.createProjectFromXML("toProject", input)).thenThrow(new IOException());
// test
inst.createProjectFromXML("toProject", input);
}
Aggregations