Search in sources :

Example 1 with OrganizationImpl

use of io.jenkins.blueocean.service.embedded.rest.OrganizationImpl in project blueocean-plugin by jenkinsci.

the class ChangeSetResourceTest method testChangeSet.

@Test
public void testChangeSet() {
    Reachable reachable = mock(Reachable.class);
    when(reachable.getLink()).thenReturn(new Link("/foo/bar"));
    User user = mock(User.class);
    when(user.getId()).thenReturn("vivek");
    ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);
    when(entry.getAuthor()).thenReturn(user);
    when(entry.getTimestamp()).thenReturn(System.currentTimeMillis());
    when(entry.getCommitId()).thenReturn("12345");
    when(entry.getMsg()).thenReturn("test changeset");
    when(entry.getAffectedPaths()).thenReturn(Collections.singleton("/foo/bar"));
    ChangeSetResource changeSetResource = new ChangeSetResource(new OrganizationImpl("testorg", mock(Folder.class)), entry, reachable);
    assertEquals(user.getId(), changeSetResource.getAuthor().getId());
    assertEquals(entry.getCommitId(), changeSetResource.getCommitId());
    assertEquals(entry.getMsg(), changeSetResource.getMsg());
}
Also used : User(hudson.model.User) ChangeLogSet(hudson.scm.ChangeLogSet) Reachable(io.jenkins.blueocean.rest.Reachable) ChangeSetResource(io.jenkins.blueocean.service.embedded.rest.ChangeSetResource) Link(io.jenkins.blueocean.rest.hal.Link) OrganizationImpl(io.jenkins.blueocean.service.embedded.rest.OrganizationImpl) Test(org.junit.Test)

Example 2 with OrganizationImpl

use of io.jenkins.blueocean.service.embedded.rest.OrganizationImpl 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 3 with OrganizationImpl

use of io.jenkins.blueocean.service.embedded.rest.OrganizationImpl 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

OrganizationImpl (io.jenkins.blueocean.service.embedded.rest.OrganizationImpl)3 Test (org.junit.Test)3 PipelineBaseTest (io.jenkins.blueocean.rest.impl.pipeline.PipelineBaseTest)2 BlueScmConfig (io.jenkins.blueocean.rest.model.BlueScmConfig)2 JSONObject (net.sf.json.JSONObject)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 User (hudson.model.User)1 ChangeLogSet (hudson.scm.ChangeLogSet)1 ServiceException (io.jenkins.blueocean.commons.ServiceException)1 Reachable (io.jenkins.blueocean.rest.Reachable)1 Link (io.jenkins.blueocean.rest.hal.Link)1 ChangeSetResource (io.jenkins.blueocean.service.embedded.rest.ChangeSetResource)1