Package org.hudsonci.service

Examples of org.hudsonci.service.BuildService


    @Test
    public void deleteBuildSecurity() throws IOException {

        // spy so that we can call real methods
        BuildService buildService = spy(getInst());

        // partial mocking, using doReturn to avoid type safety <?,?> BS
        doReturn(build).when(buildService).getBuild(project, 1);

        // test
        buildService.deleteBuild(project, 1);

        // verify, security before operation
        InOrder inOrder = inOrder(securityService, build);
        inOrder.verify(securityService).checkPermission(build, Run.DELETE);
        inOrder.verify(build).delete();
View Full Code Here


    }

    @Test(expected = ServiceRuntimeException.class)
    public void deleteBuildServiceRuntimeException() throws IOException {
        // spy so that we can call real methods
        BuildService buildService = spy(getInst());

        // partial mocking, using doReturn to avoid type safety <?,?> BS
        doReturn(build).when(buildService).getBuild(project, 1);
        doThrow(new IOException()).when(build).delete();

        // test
        buildService.deleteBuild(project, 1);

    }
View Full Code Here

    @Test
    public void keepBuildSecurity() throws IOException {

        // spy so that we can call real methods
        BuildService buildService = spy(getInst());

        // partial mocking, using doReturn to avoid type safety <?,?> BS
        doReturn(build).when(buildService).getBuild(project, 1);

        // test
        buildService.keepBuild(project, 1, true);

        // verify, security before operation
        InOrder inOrder = inOrder(securityService, build);
        inOrder.verify(securityService).checkPermission(build, Run.UPDATE);
        inOrder.verify(build).keepLog(false);
View Full Code Here

    }

    @Test(expected = ServiceRuntimeException.class)
    public void keepBuildServiceRuntimeException() throws IOException {
        // spy so that we can call real methods
        BuildService buildService = spy(getInst());

        // partial mocking, using doReturn to avoid type safety <?,?> BS
        doReturn(build).when(buildService).getBuild(project, 1);
        doThrow(new IOException()).when(build).keepLog(false);

        // test
        buildService.keepBuild(project, 1, true);

    }
View Full Code Here

    @Test
    public void getBuildByProjectSecurity() throws IOException {

        // spy so that we can call real methods
        BuildService buildService = spy(getInst());

        // partial mocking
        doReturn(build).when(project).getBuildByNumber(1);

        // test
        buildService.getBuild(project, 1);

        // verify
        verify(securityService).checkPermission(build, Item.READ);

    }
View Full Code Here

    @Test
    public void getBuildByProjectNameSecurity() throws IOException {

        // spy so that we can call real methods
        BuildService buildService = spy(getInst());

        // partial mocking
        doReturn(build).when(project).getBuildByNumber(1);
        doReturn(project).when(projectService).getProject("projectName");

        // test
        buildService.getBuild("projectName", 1);

        // verify
        verify(securityService).checkPermission(build, Item.READ);

    }
View Full Code Here

    @Test
    public void findBuildByProjectSecurity() throws IOException {

        // spy so that we can call real methods
        BuildService buildService = spy(getInst());

        // partial mocking
        doReturn(build).when(project).getBuildByNumber(1);

        // test
        buildService.findBuild(project, 1);

        // verify
        verify(securityService).checkPermission(build, Item.READ);

    }
View Full Code Here

    @Test
    public void findBuildByProjectNameSecurity() throws IOException {

        // spy so that we can call real methods
        BuildService buildService = spy(getInst());

        // partial mocking
        doReturn(project).when(projectService).findProject("projectName");
        doReturn(build).when(project).getBuildByNumber(1);

        // test
        buildService.findBuild("projectName", 1);

        // verify
        verify(securityService).checkPermission(build, Item.READ);

    }
View Full Code Here

        //intentionally blank as a note that security is performed internally in Hudson core.
    }

    @Test(expected = ServiceRuntimeException.class)
    public void stopBuildServiceRuntimeException1() throws IOException {
        BuildService inst = spy(getInst());

        doReturn(build).when(inst).getBuild(project, 1);
        try {
            doThrow(new IOException()).when(build).doStop(any(StaplerRequest.class), any(StaplerResponse.class));
        } catch (Exception e) {
View Full Code Here

        getInst().stopBuild(project, 1);
    }

    @Test(expected = ServiceRuntimeException.class)
    public void stopBuildServiceRuntimeException2() throws IOException {
        BuildService inst = spy(getInst());

        doReturn(build).when(inst).getBuild(project, 1);
        try {
            doThrow(new ServletException()).when(build).doStop(any(StaplerRequest.class), any(StaplerResponse.class));
        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.hudsonci.service.BuildService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.