use of org.jmock.Expectations in project gocd by gocd.
the class JobDetailServiceTest method shouldCreateBuildInstanceDetailFromLogFileForCompletedBuild.
@Test
public void shouldCreateBuildInstanceDetailFromLogFileForCompletedBuild() throws Exception {
final String jobConfigName = "jobConfig1";
final int id = 1;
final JobInstance completed = JobInstanceMother.completed(jobConfigName, JobResult.Failed);
completed.setId(id);
completed.setIdentifier(new JobIdentifier("pipeline", "1", "stage", "1", jobConfigName));
final HashMap properties = new HashMap();
final File artifactsRoot = new File("artifacts");
context.checking(new Expectations() {
{
one(artifactsService).getInstanceLogFile(completed.getIdentifier());
LogFile buildLogFile = new LogFile(DataUtils.getFailedBuildLbuildAsFile().getFile());
will(returnValue(buildLogFile));
one(artifactsService).parseLogFile(buildLogFile, completed.isPassed());
will(returnValue(properties));
one(artifactsService).findArtifact(completed.getIdentifier(), "");
will(returnValue(artifactsRoot));
}
});
jobDetailService.loadBuildInstanceLog(completed);
assertThat(completed.getName(), is(jobConfigName));
assertThat(properties.get("artifactfolder"), is(artifactsRoot));
}
use of org.jmock.Expectations in project gocd by gocd.
the class JobDetailPresentationModelJMockTest method shouldReturnEmptyStringForServerFailurePage.
@Test
public void shouldReturnEmptyStringForServerFailurePage() throws Exception {
context.checking(new Expectations() {
{
allowing(stubJobInstance).getServerFailurePage();
will(returnValue(null));
}
});
String path = jobDetailPresenter.getServerFailurePageURL();
assertThat(path, is(""));
}
use of org.jmock.Expectations in project gocd by gocd.
the class JobDetailPresentationModelJMockTest method shouldReturnEmptyStringForIndexPage.
@Test
public void shouldReturnEmptyStringForIndexPage() throws Exception {
context.checking(new Expectations() {
{
allowing(stubJobInstance).getTestIndexPage();
will(returnValue(null));
}
});
String path = jobDetailPresenter.getIndexPageURL();
assertThat(path, is(""));
}
use of org.jmock.Expectations in project gocd by gocd.
the class JobDetailPresentationModelJMockTest method shouldGetServerFailurePage.
@Test
public void shouldGetServerFailurePage() throws Exception {
final File file = new File("home" + File.separator + "user" + File.separator + ArtifactLogUtil.CRUISE_OUTPUT_FOLDER + File.separator + ArtifactLogUtil.SERVER_FAILURE_PAGE);
context.checking(new Expectations() {
{
allowing(stubJobInstance).getServerFailurePage();
will(returnValue(file));
}
});
String path = jobDetailPresenter.getServerFailurePageURL();
assertThat(path, is("files/pipeline/1/stageName/0/build/" + ArtifactLogUtil.CRUISE_OUTPUT_FOLDER + "/" + ArtifactLogUtil.SERVER_FAILURE_PAGE));
}
use of org.jmock.Expectations in project gocd by gocd.
the class JobDetailPresentationModelJMockTest method hasFailedTestsShouldBeFalseWhenIndexPageURLIsNull.
@Test
public void hasFailedTestsShouldBeFalseWhenIndexPageURLIsNull() throws Exception {
context.checking(new Expectations() {
{
allowing(stubJobInstance).getTestIndexPage();
will(returnValue(null));
}
});
assertThat(jobDetailPresenter.hasFailedTests(), is(false));
}
Aggregations