Search in sources :

Example 1 with ClassMockery

use of com.thoughtworks.go.util.ClassMockery in project gocd by gocd.

the class WorkFinderTest method before.

@Before
public void before() {
    context = new ClassMockery();
    workAssigner = context.mock(BuildAssignmentService.class);
    assignedWorkTopic = context.mock(WorkAssignedTopic.class, "assignedWork");
    idleAgentTopic = context.mock(IdleAgentTopic.class, "idleAgent");
    workAssignmentPerformanceLogger = mock(WorkAssignmentPerformanceLogger.class);
    context.checking(new Expectations() {

        {
            one(idleAgentTopic).addListener(with(any(WorkFinder.class)));
        }
    });
    finder = new WorkFinder(workAssigner, idleAgentTopic, assignedWorkTopic, workAssignmentPerformanceLogger);
}
Also used : Expectations(org.jmock.Expectations) WorkAssignmentPerformanceLogger(com.thoughtworks.go.server.perf.WorkAssignmentPerformanceLogger) ClassMockery(com.thoughtworks.go.util.ClassMockery) BuildAssignmentService(com.thoughtworks.go.server.service.BuildAssignmentService) Before(org.junit.Before)

Example 2 with ClassMockery

use of com.thoughtworks.go.util.ClassMockery in project gocd by gocd.

the class JobStatusListenerTest method setUp.

@Before
public void setUp() throws Exception {
    goCache.clear();
    dbHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    PipelineConfig pipelineConfig = withSingleStageWithMaterials(PIPELINE_NAME, STAGE_NAME, withBuildPlans(JOB_NAME));
    configHelper.addPipeline(PIPELINE_NAME, STAGE_NAME);
    savedPipeline = scheduleHelper.schedule(pipelineConfig, BuildCause.createWithModifications(modifyOneFile(pipelineConfig), ""), GoConstants.DEFAULT_APPROVED_BY);
    JobInstance job = savedPipeline.getStages().first().getJobInstances().first();
    job.setAgentUuid(UUID);
    mockery = new ClassMockery();
    stageStatusTopic = mockery.mock(StageStatusTopic.class);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) JobInstance(com.thoughtworks.go.domain.JobInstance) ClassMockery(com.thoughtworks.go.util.ClassMockery) Before(org.junit.Before)

Example 3 with ClassMockery

use of com.thoughtworks.go.util.ClassMockery in project gocd by gocd.

the class StageAuthorizationCheckerTest method setUp.

@Before
public void setUp() throws Exception {
    mockery = new ClassMockery();
    securityService = mockery.mock(SecurityService.class);
    pipelineName = "cruise";
    stageName = "dev";
    username = "gli";
    checker = new StageAuthorizationChecker(pipelineName, stageName, username, securityService);
}
Also used : ClassMockery(com.thoughtworks.go.util.ClassMockery) Before(org.junit.Before)

Example 4 with ClassMockery

use of com.thoughtworks.go.util.ClassMockery in project gocd by gocd.

the class UniqueEmailSenderTest method shouldSendEmailIfNotEnoughSpaceForFirstTime.

@Test
public void shouldSendEmailIfNotEnoughSpaceForFirstTime() {
    ClassMockery mockery = new ClassMockery();
    final EmailNotificationTopic topic = mockery.mock(EmailNotificationTopic.class);
    final SendEmailMessage message = new SendEmailMessage("pavan", "hu kai", "someone");
    mockery.checking(new Expectations() {

        {
            one(topic).post(message);
        }
    });
    EmailSender sender = new AsynchronousEmailSender(topic);
    sender.sendEmail(message);
}
Also used : Expectations(org.jmock.Expectations) SendEmailMessage(com.thoughtworks.go.server.messaging.SendEmailMessage) EmailNotificationTopic(com.thoughtworks.go.server.messaging.EmailNotificationTopic) ClassMockery(com.thoughtworks.go.util.ClassMockery) Test(org.junit.Test)

Example 5 with ClassMockery

use of com.thoughtworks.go.util.ClassMockery in project gocd by gocd.

the class DiskSpaceWarningCheckerTest method shouldReturnSuccessWhenTheArtifactsFolderIsNotPresent.

@Test
public void shouldReturnSuccessWhenTheArtifactsFolderIsNotPresent() {
    ClassMockery mockery = new ClassMockery();
    final GoConfigService service = mockery.mock(GoConfigService.class);
    mockery.checking(new Expectations() {

        {
            allowing(service).artifactsDir();
            will(returnValue(new File("/pavan")));
        }
    });
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    new ArtifactsDiskSpaceWarningChecker(new SystemEnvironment(), sender, service, new SystemDiskSpaceChecker(), serverHealthService).check(result);
    assertThat(result.getServerHealthState().isSuccess(), is(true));
}
Also used : Expectations(org.jmock.Expectations) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ClassMockery(com.thoughtworks.go.util.ClassMockery) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) File(java.io.File) Test(org.junit.Test)

Aggregations

ClassMockery (com.thoughtworks.go.util.ClassMockery)11 Before (org.junit.Before)7 Expectations (org.jmock.Expectations)6 Test (org.junit.Test)4 EmailNotificationTopic (com.thoughtworks.go.server.messaging.EmailNotificationTopic)2 SendEmailMessage (com.thoughtworks.go.server.messaging.SendEmailMessage)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 JobInstance (com.thoughtworks.go.domain.JobInstance)1 PipelineIdentifier (com.thoughtworks.go.domain.PipelineIdentifier)1 Stage (com.thoughtworks.go.domain.Stage)1 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)1 WorkAssignmentPerformanceLogger (com.thoughtworks.go.server.perf.WorkAssignmentPerformanceLogger)1 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)1 BuildAssignmentService (com.thoughtworks.go.server.service.BuildAssignmentService)1 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)1 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 File (java.io.File)1