use of org.hudsonci.service.ProjectService in project hudson-2.x by hudson.
the class ProjectServiceImplTest method getProjectByProjectNameSecurity.
@Test
public void getProjectByProjectNameSecurity() {
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().getProject("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 createProjectFromXMLSecurity.
@Test
public void createProjectFromXMLSecurity() throws IOException {
// mocks
TopLevelItem toProject = Mockito.mock(TopLevelItem.class);
ProjectService inst = spy(getInst());
// make method succeed
doReturn(false).when(inst).projectExists("toProject");
when(hudson.createProjectFromXML("toProject", input)).thenReturn(toProject);
assertThat(inst.createProjectFromXML("toProject", input), equalTo(toProject));
Mockito.verify(securityService).checkPermission(Item.CREATE);
}
use of org.hudsonci.service.ProjectService in project hudson-2.x by hudson.
the class ProjectServiceImplTest method copyProjectToProjectAlreadyExists.
@Test(expected = SystemIntegrityViolationException.class)
public void copyProjectToProjectAlreadyExists() throws IOException {
ProjectService inst = spy(getInst());
doReturn(true).when(inst).projectExists("toProject");
inst.copyProject(project, "toProject");
}
use of org.hudsonci.service.ProjectService in project hudson-2.x by hudson.
the class ProjectServiceImplTest method copyProjectIOException.
@Test(expected = ServiceRuntimeException.class)
public void copyProjectIOException() throws IOException {
// mocks
ProjectService inst = spy(getInst());
// make method succeed
doReturn(false).when(inst).projectExists("toProject");
when(hudson.copy(project, "toProject")).thenThrow(new IOException());
// test
inst.copyProject(project, "toProject");
}
use of org.hudsonci.service.ProjectService in project hudson-2.x by hudson.
the class ProjectServiceImplTest method projectExistsTrue.
@Test
public void projectExistsTrue() {
ProjectService inst = spy(getInst());
@SuppressWarnings("unchecked") Collection<String> names = Mockito.mock(Collection.class);
when(names.contains("projectName")).thenReturn(true);
when(inst.getProjectNames()).thenReturn(names);
assertThat(inst.projectExists("projectName"), is(true));
}
Aggregations