Search in sources :

Example 1 with GiteaIssue

use of org.jenkinsci.plugin.gitea.client.api.GiteaIssue in project gitea-plugin by jenkinsci.

the class MockGiteaConnection method withRepo.

public MockGiteaConnection withRepo(GiteaRepository repo) {
    GiteaRepository clone = repo.clone();
    clone.setId(nextId.incrementAndGet());
    clone.setCreatedAt(new Date());
    clone.setUpdatedAt(new Date());
    this.repositories.put(keyOf(clone), clone);
    this.repoHooks.put(keyOf(clone), new ArrayList<GiteaHook>());
    this.branches.put(keyOf(clone), new HashMap<String, GiteaBranch>());
    this.pulls.put(keyOf(clone), new HashMap<Long, GiteaPullRequest>());
    this.issues.put(keyOf(clone), new HashMap<Long, GiteaIssue>());
    this.collaborators.put(keyOf(clone), new TreeSet<String>());
    this.files.put(keyOf(clone), new TreeMap<String, Map<String, byte[]>>());
    return this;
}
Also used : GiteaIssue(org.jenkinsci.plugin.gitea.client.api.GiteaIssue) GiteaBranch(org.jenkinsci.plugin.gitea.client.api.GiteaBranch) GiteaHook(org.jenkinsci.plugin.gitea.client.api.GiteaHook) Date(java.util.Date) AtomicLong(java.util.concurrent.atomic.AtomicLong) GiteaPullRequest(org.jenkinsci.plugin.gitea.client.api.GiteaPullRequest) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) GiteaRepository(org.jenkinsci.plugin.gitea.client.api.GiteaRepository)

Example 2 with GiteaIssue

use of org.jenkinsci.plugin.gitea.client.api.GiteaIssue in project gitea-plugin by jenkinsci.

the class MockGiteaConnection method withIssue.

public MockGiteaConnection withIssue(GiteaRepository repo, GiteaIssue issue) {
    GiteaIssue clone = issue.clone();
    clone.setId(nextId.incrementAndGet());
    clone.setNumber(clone.getId());
    clone.setCreatedAt(new Date());
    clone.setUpdatedAt(new Date());
    issues.get(keyOf(repo)).put(issue.getId(), issue);
    return this;
}
Also used : GiteaIssue(org.jenkinsci.plugin.gitea.client.api.GiteaIssue) Date(java.util.Date)

Example 3 with GiteaIssue

use of org.jenkinsci.plugin.gitea.client.api.GiteaIssue in project gitea-plugin by jenkinsci.

the class MockGiteaConnection method withPull.

public MockGiteaConnection withPull(GiteaRepository repo, GiteaPullRequest pull) {
    GiteaPullRequest clone = pull.clone();
    clone.setId(nextId.incrementAndGet());
    clone.setNumber(clone.getId());
    clone.setCreatedAt(new Date());
    clone.setUpdatedAt(new Date());
    pulls.get(keyOf(repo)).put(clone.getId(), clone);
    Map<String, byte[]> content = this.files.get(keyOf(repo)).get(pull.getHead().getSha());
    if (content == null) {
        this.files.get(keyOf(repo)).put(pull.getHead().getSha(), new HashMap<String, byte[]>());
    }
    content = this.files.get(keyOf(repo)).get(pull.getBase().getSha());
    if (content == null) {
        this.files.get(keyOf(repo)).put(pull.getBase().getSha(), new HashMap<String, byte[]>());
    }
    GiteaIssue issue = new GiteaIssue();
    issue.setUrl(clone.getUrl());
    issue.setNumber(clone.getNumber());
    issue.setUser(clone.getUser());
    issue.setTitle(clone.getTitle());
    issue.setBody(clone.getBody());
    issue.setLabels(clone.getLabels());
    issue.setMilestone(clone.getMilestone());
    issue.setAssignee(clone.getAssignee());
    issue.setState(clone.getState());
    issue.setComments(clone.getComments());
    issue.setCreatedAt(clone.getCreatedAt());
    issue.setUpdatedAt(clone.getUpdatedAt());
    GiteaIssue.PullSummary summary = new GiteaIssue.PullSummary();
    summary.setMerged(clone.isMerged());
    summary.setMergedAt(clone.getMergedAt());
    issue.setPullRequest(summary);
    issues.get(keyOf(repo)).put(issue.getId(), issue);
    return this;
}
Also used : GiteaIssue(org.jenkinsci.plugin.gitea.client.api.GiteaIssue) GiteaPullRequest(org.jenkinsci.plugin.gitea.client.api.GiteaPullRequest) Date(java.util.Date)

Aggregations

Date (java.util.Date)3 GiteaIssue (org.jenkinsci.plugin.gitea.client.api.GiteaIssue)3 GiteaPullRequest (org.jenkinsci.plugin.gitea.client.api.GiteaPullRequest)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 GiteaBranch (org.jenkinsci.plugin.gitea.client.api.GiteaBranch)1 GiteaHook (org.jenkinsci.plugin.gitea.client.api.GiteaHook)1 GiteaRepository (org.jenkinsci.plugin.gitea.client.api.GiteaRepository)1