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