Search in sources :

Example 1 with BlueScmConfig

use of io.jenkins.blueocean.rest.model.BlueScmConfig in project blueocean-plugin by jenkinsci.

the class GithubPipelineCreateRequestTest method createPipelineNoJenkinsFile.

@Test
public void createPipelineNoJenkinsFile() throws UnirestException, IOException {
    // AbstractMultiBranchCreateRequest.JenkinsfileCriteria criteria = Mockito.mock(AbstractMultiBranchCreateRequest.JenkinsfileCriteria.class);
    // when(criteria.isJenkinsfileFound()).thenReturn(true);
    OrganizationImpl organization = new OrganizationImpl("jenkins", j.jenkins);
    String credentialId = createGithubCredential(user);
    JSONObject config = JSONObject.fromObject(MapsHelper.of("repoOwner", "vivek", "repository", "empty1"));
    GithubPipelineCreateRequest request = new GithubPipelineCreateRequest("empty1", new BlueScmConfig(GithubScm.ID, githubApiUrl, credentialId, config));
    request.create(organization, organization);
// verify(criteria, atLeastOnce()).isJenkinsfileFound();
}
Also used : JSONObject(net.sf.json.JSONObject) BlueScmConfig(io.jenkins.blueocean.rest.model.BlueScmConfig) OrganizationImpl(io.jenkins.blueocean.service.embedded.rest.OrganizationImpl) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) PipelineBaseTest(io.jenkins.blueocean.rest.impl.pipeline.PipelineBaseTest) Test(org.junit.Test)

Example 2 with BlueScmConfig

use of io.jenkins.blueocean.rest.model.BlueScmConfig in project blueocean-plugin by jenkinsci.

the class GithubPipelineCreateRequestTest method shouldFailCreatePipelineNoJenkinsFile.

@Test
public void shouldFailCreatePipelineNoJenkinsFile() throws UnirestException, IOException {
    boolean thrown = false;
    OrganizationImpl organization = new OrganizationImpl("jenkins", j.jenkins);
    String credentialId = createGithubCredential(user);
    JSONObject config = JSONObject.fromObject(MapsHelper.of("repoOwner", "vivek", "repository", "empty1"));
    GithubPipelineCreateRequest request = new GithubPipelineCreateRequest("empty1/empty2", new BlueScmConfig(GithubScm.ID, githubApiUrl, credentialId, config));
    try {
        request.create(organization, organization);
    } catch (ServiceException.BadRequestException e) {
        thrown = true;
    }
    assertTrue(thrown);
}
Also used : JSONObject(net.sf.json.JSONObject) ServiceException(io.jenkins.blueocean.commons.ServiceException) BlueScmConfig(io.jenkins.blueocean.rest.model.BlueScmConfig) OrganizationImpl(io.jenkins.blueocean.service.embedded.rest.OrganizationImpl) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) PipelineBaseTest(io.jenkins.blueocean.rest.impl.pipeline.PipelineBaseTest) Test(org.junit.Test)

Aggregations

PipelineBaseTest (io.jenkins.blueocean.rest.impl.pipeline.PipelineBaseTest)2 BlueScmConfig (io.jenkins.blueocean.rest.model.BlueScmConfig)2 OrganizationImpl (io.jenkins.blueocean.service.embedded.rest.OrganizationImpl)2 JSONObject (net.sf.json.JSONObject)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ServiceException (io.jenkins.blueocean.commons.ServiceException)1