Search in sources :

Example 1 with BuildTriggerServlet

use of com.palantir.stash.stashbot.servlet.BuildTriggerServlet in project stashbot by palantir.

the class BuildTriggerServletTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    verifyCommitType = JobType.VERIFY_COMMIT;
    verifyPRType = JobType.VERIFY_PR;
    publishType = JobType.PUBLISH;
    Mockito.when(repositoryService.getById(REPO_ID)).thenReturn(repo);
    Mockito.when(prs.getById(REPO_ID, PULL_REQUEST_ID)).thenReturn(pr);
    Mockito.when(pr.getId()).thenReturn(PULL_REQUEST_ID);
    Mockito.when(repo.getId()).thenReturn(REPO_ID);
    Mockito.when(cpm.getRepositoryConfigurationForRepository(repo)).thenReturn(rc);
    Mockito.when(jt1.getJobType()).thenReturn(verifyCommitType);
    Mockito.when(jt2.getJobType()).thenReturn(verifyPRType);
    Mockito.when(jt3.getJobType()).thenReturn(publishType);
    Mockito.when(jtm.getJenkinsJobsForRepository(rc)).thenReturn(ImmutableList.of(jt1, jt2, jt3));
    Mockito.when(jtm.fromString(rc, verifyCommitType.toString())).thenReturn(jt1);
    Mockito.when(jtm.fromString(rc, verifyPRType.toString())).thenReturn(jt2);
    Mockito.when(jtm.fromString(rc, publishType.toString())).thenReturn(jt3);
    mockWriter = new StringWriter();
    Mockito.when(res.getWriter()).thenReturn(new PrintWriter(mockWriter));
    jtf = new MockJobTemplateFactory(jtm);
    jtf.generateDefaultsForRepo(repo, rc);
    bsrs = new BuildTriggerServlet(repositoryService, prs, jtm, cpm, jenkinsManager, lf);
}
Also used : MockJobTemplateFactory(com.palantir.stash.stashbot.mocks.MockJobTemplateFactory) StringWriter(java.io.StringWriter) BuildTriggerServlet(com.palantir.stash.stashbot.servlet.BuildTriggerServlet) PrintWriter(java.io.PrintWriter) Before(org.junit.Before)

Aggregations

MockJobTemplateFactory (com.palantir.stash.stashbot.mocks.MockJobTemplateFactory)1 BuildTriggerServlet (com.palantir.stash.stashbot.servlet.BuildTriggerServlet)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Before (org.junit.Before)1