Search in sources :

Example 81 with Expectations

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));
}
Also used : Expectations(org.jmock.Expectations) LogFile(com.thoughtworks.go.server.domain.LogFile) JobInstance(com.thoughtworks.go.domain.JobInstance) HashMap(java.util.HashMap) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) LogFile(com.thoughtworks.go.server.domain.LogFile) File(java.io.File) Test(org.junit.Test)

Example 82 with Expectations

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(""));
}
Also used : Expectations(org.jmock.Expectations) Test(org.junit.Test)

Example 83 with Expectations

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(""));
}
Also used : Expectations(org.jmock.Expectations) Test(org.junit.Test)

Example 84 with Expectations

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));
}
Also used : Expectations(org.jmock.Expectations) File(java.io.File) Test(org.junit.Test)

Example 85 with Expectations

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));
}
Also used : Expectations(org.jmock.Expectations) Test(org.junit.Test)

Aggregations

Expectations (org.jmock.Expectations)651 Test (org.junit.Test)443 UnitTest (org.apache.geode.test.junit.categories.UnitTest)109 File (java.io.File)41 ConfigurationServiceImpl (org.nhindirect.config.service.impl.ConfigurationServiceImpl)41 InternalCache (org.apache.geode.internal.cache.InternalCache)35 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)33 SlingHttpServletResponse (org.apache.sling.api.SlingHttpServletResponse)32 Resource (org.apache.sling.api.resource.Resource)31 RewriterResponse (org.apache.sling.security.impl.ContentDispositionFilter.RewriterResponse)31 ArrayList (java.util.ArrayList)27 DiskStore (org.apache.geode.cache.DiskStore)23 ValueMap (org.apache.sling.api.resource.ValueMap)21 Before (org.junit.Before)20 CertificateGetOptions (org.nhindirect.config.service.impl.CertificateGetOptions)20 Sequence (org.jmock.Sequence)19 Cache (org.apache.geode.cache.Cache)18 Region (org.apache.geode.cache.Region)18 DistributedMember (org.apache.geode.distributed.DistributedMember)18 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)17