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());
}
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();
}
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);
}
Aggregations