Package hudson.model

Examples of hudson.model.AbstractProject


     * gets called with correct change owner and uploader parameters when there are no default parameters present.
     * And sets the event.patchSet.uploader to null keeping event.uploader set.
     */
    @Test
    public void testScheduleWithOwnerAndOtherUploaderNull() {
        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.getFullDisplayName()).thenReturn("MockedProject");
        when(project.getFullName()).thenReturn("MockedProject");
        ParametersDefinitionProperty parameters = mock(ParametersDefinitionProperty.class);
        when(parameters.getParameterDefinitions()).thenReturn(Collections.EMPTY_LIST);
        when(project.getProperty(ParametersDefinitionProperty.class)).thenReturn(parameters);

        Account owner = new Account("Bobby", "bobby@somewhere.com");
        Account uploader = new Account("Nisse", "nisse@acme.org");

        PowerMockito.mockStatic(PluginImpl.class);
        PluginImpl plugin = PowerMockito.mock(PluginImpl.class);
        PowerMockito.when(PluginImpl.getInstance()).thenReturn(plugin);
        GerritServer server = mock(GerritServer.class);
        when(plugin.getServer(any(String.class))).thenReturn(server);
        GerritHandler handler = mock(GerritHandler.class);
        when(plugin.getHandler()).thenReturn(handler);

        GerritTrigger trigger = Setup.createDefaultTrigger(project);
        when(project.getTrigger(GerritTrigger.class)).thenReturn(trigger);
        trigger.setEscapeQuotes(false);
        PatchsetCreated event = Setup.createPatchsetCreatedWithAccounts(owner, null, uploader);
        GerritCause gerritCause = new GerritCause(event, true);
        gerritCause = spy(gerritCause);
        doReturn("http://mock.url").when(gerritCause).getUrl();
View Full Code Here


     * @return a mock.
     * @throws Exception if so.
     */
    private AbstractBuild mockBuild(String projectFullName, int buildNumber) throws Exception {
        System.out.println("mockBuild");
        AbstractProject project = mockProject(projectFullName);
        AbstractBuild build = mock(AbstractBuild.class);
        when(build.getProject()).thenReturn(project);
        when(build.getNumber()).thenReturn(buildNumber);
        EnvVars envVars = Setup.createEnvVars();

View Full Code Here

     *
     * @throws Exception if so.
     */
    @Test
    public void testOnTriggered() throws Exception {
        AbstractProject project = mockProject("projectX");
        ManualPatchsetCreated event = Setup.createManualPatchsetCreated();
        event = spy(event);

        ToGerritRunListener toGerritRunListener = new ToGerritRunListener();

View Full Code Here

     *
     * @throws Exception if so.
     */
    @Test
    public void testOnRetriggered() throws Exception {
        AbstractProject project = mockProject("projectX");
        ManualPatchsetCreated event = Setup.createManualPatchsetCreated();
        event = spy(event);

        ToGerritRunListener toGerritRunListener = new ToGerritRunListener();

View Full Code Here

     * gets called with correct change owner and uploader parameters when there are no default parameters present.
     * And sets the event.patchSet.uploader and event.uploader to null.
     */
    @Test
    public void testScheduleWithOwnerAndBothUploadersNull() {
        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.getFullDisplayName()).thenReturn("MockedProject");
        when(project.getFullName()).thenReturn("MockedProject");
        ParametersDefinitionProperty parameters = mock(ParametersDefinitionProperty.class);
        when(parameters.getParameterDefinitions()).thenReturn(Collections.EMPTY_LIST);
        when(project.getProperty(ParametersDefinitionProperty.class)).thenReturn(parameters);

        Account owner = new Account("Bobby", "bobby@somewhere.com");

        PowerMockito.mockStatic(PluginImpl.class);
        PluginImpl plugin = PowerMockito.mock(PluginImpl.class);
        PowerMockito.when(PluginImpl.getInstance()).thenReturn(plugin);
        GerritServer server = mock(GerritServer.class);
        when(plugin.getServer(any(String.class))).thenReturn(server);
        GerritHandler handler = mock(GerritHandler.class);
        when(plugin.getHandler()).thenReturn(handler);

        GerritTrigger trigger = Setup.createDefaultTrigger(project);
        when(project.getTrigger(GerritTrigger.class)).thenReturn(trigger);
        trigger.setEscapeQuotes(false);
        PatchsetCreated event = Setup.createPatchsetCreatedWithAccounts(owner, null, null);
        GerritCause gerritCause = new GerritCause(event, true);
        gerritCause = spy(gerritCause);
        doReturn("http://mock.url").when(gerritCause).getUrl();
View Full Code Here

     * gets called with correct change owner and uploader parameters when there are no default parameters present.
     * And sets the event.patchSet.uploader and event.uploader to null.
     */
    @Test
    public void testScheduleWithOwnerAndPartOfUploadersNull() {
        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.getFullDisplayName()).thenReturn("MockedProject");
        when(project.getFullName()).thenReturn("MockedProject");
        ParametersDefinitionProperty parameters = mock(ParametersDefinitionProperty.class);
        when(parameters.getParameterDefinitions()).thenReturn(Collections.EMPTY_LIST);
        when(project.getProperty(ParametersDefinitionProperty.class)).thenReturn(parameters);

        Account owner = new Account("Bobby", "bobby@somewhere.com");
        Account uploader = new Account("Bobby", null);

        PowerMockito.mockStatic(PluginImpl.class);
        PluginImpl plugin = PowerMockito.mock(PluginImpl.class);
        PowerMockito.when(PluginImpl.getInstance()).thenReturn(plugin);
        GerritServer server = mock(GerritServer.class);
        when(plugin.getServer(any(String.class))).thenReturn(server);
        GerritHandler handler = mock(GerritHandler.class);
        when(plugin.getHandler()).thenReturn(handler);

        GerritTrigger trigger = Setup.createDefaultTrigger(project);
        when(project.getTrigger(GerritTrigger.class)).thenReturn(trigger);
        trigger.setEscapeQuotes(false);
        PatchsetCreated event = Setup.createPatchsetCreatedWithAccounts(owner, uploader, uploader);
        GerritCause gerritCause = new GerritCause(event, true);
        gerritCause = spy(gerritCause);
        doReturn("http://mock.url").when(gerritCause).getUrl();
View Full Code Here

        mockPluginConfig();
        PowerMockito.mockStatic(ToGerritRunListener.class);
        ToGerritRunListener listener = PowerMockito.mock(ToGerritRunListener.class);
        PowerMockito.when(ToGerritRunListener.getInstance()).thenReturn(listener);

        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.getFullDisplayName()).thenReturn("MockedProject");
        when(project.isBuildable()).thenReturn(true);

        AbstractBuild build = mock(AbstractBuild.class);
        when(build.getNumber()).thenReturn(1);
        when(build.getProject()).thenReturn(project);

        PatchsetCreated event = Setup.createPatchsetCreated();

        when(listener.isBuilding(project, event)).thenReturn(false);
        GerritTrigger trigger = Setup.createDefaultTrigger(null);
        when(project.getTrigger(GerritTrigger.class)).thenReturn(trigger);
        trigger.setGerritProjects(Collections.EMPTY_LIST);
        trigger.setEscapeQuotes(false);
        trigger.setSilentMode(false);

        TriggerContext context = new TriggerContext(build, event, Collections.EMPTY_LIST);
View Full Code Here

        mockPluginConfig();
        PowerMockito.mockStatic(ToGerritRunListener.class);
        ToGerritRunListener listener = PowerMockito.mock(ToGerritRunListener.class);
        PowerMockito.when(ToGerritRunListener.getInstance()).thenReturn(listener);

        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.getFullDisplayName()).thenReturn("MockedProject");
        when(project.isBuildable()).thenReturn(true);

        AbstractBuild build = mock(AbstractBuild.class);
        when(build.getNumber()).thenReturn(1);
        when(build.getProject()).thenReturn(project);

        PatchsetCreated event = Setup.createPatchsetCreated();

        when(listener.isBuilding(project, event)).thenReturn(false);

        GerritTrigger trigger = Setup.createDefaultTrigger(null);
        when(project.getTrigger(GerritTrigger.class)).thenReturn(trigger);
        trigger.setGerritProjects(Collections.EMPTY_LIST);

        TriggerContext context = new TriggerContext(build, event, Collections.EMPTY_LIST);

        trigger.retriggerThisBuild(context);
View Full Code Here

        PowerMockito.mockStatic(ToGerritRunListener.class);
        ToGerritRunListener listener = PowerMockito.mock(ToGerritRunListener.class);
        PowerMockito.when(ToGerritRunListener.getInstance()).thenReturn(listener);

        AbstractProject thisProject = PowerMockito.mock(AbstractProject.class);
        when(thisProject.getFullDisplayName()).thenReturn("MockedProject");
        when(thisProject.isBuildable()).thenReturn(true);

        AbstractProject otherProject = PowerMockito.mock(AbstractProject.class);
        when(otherProject.getFullDisplayName()).thenReturn("Other_MockedProject");
        when(otherProject.isBuildable()).thenReturn(true);

        AbstractBuild thisBuild = mock(AbstractBuild.class);
        when(thisBuild.getNumber()).thenReturn(1);
        when(thisBuild.getProject()).thenReturn(thisProject);
View Full Code Here

        mockPluginConfig();
        PowerMockito.mockStatic(ToGerritRunListener.class);
        ToGerritRunListener listener = PowerMockito.mock(ToGerritRunListener.class);
        PowerMockito.when(ToGerritRunListener.getInstance()).thenReturn(listener);

        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.isBuildable()).thenReturn(true);

        GerritProject gP = mock(GerritProject.class);
        doReturn(true).when(gP).isInteresting(any(String.class), any(String.class), any(String.class));
        when(gP.getFilePaths()).thenReturn(null);

        GerritTrigger trigger = Setup.createDefaultTrigger(null);
        when(project.getTrigger(GerritTrigger.class)).thenReturn(trigger);
        trigger.setGerritProjects(Collections.nCopies(1, gP));
        trigger.setEscapeQuotes(false);
        trigger.setSilentMode(false);
        Whitebox.setInternalState(trigger, "myProject", project);
View Full Code Here

TOP

Related Classes of hudson.model.AbstractProject

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.