JobContextFactory.java

1
package edu.ucsb.cs156.jobs.services;
2
3
import edu.ucsb.cs156.jobs.entities.Job;
4
import edu.ucsb.cs156.jobs.repositories.JobLogRepository;
5
import org.springframework.transaction.PlatformTransactionManager;
6
import org.springframework.transaction.TransactionDefinition;
7
import org.springframework.transaction.support.TransactionTemplate;
8
9
/**
10
 * Creates {@link JobContext} instances; exists as a seam so tests can substitute contexts.
11
 *
12
 * <p>Contexts are given a REQUIRES_NEW transaction template for log writes, so each log line
13
 * commits (and becomes visible to the admin UI) immediately, independent of the job body's
14
 * all-or-nothing transaction.
15
 */
16
public class JobContextFactory {
17
  private final JobLogRepository jobLogRepository;
18
  private final TransactionTemplate logTransactionTemplate;
19
20
  public JobContextFactory(
21
      JobLogRepository jobLogRepository, PlatformTransactionManager transactionManager) {
22
    this.jobLogRepository = jobLogRepository;
23
    this.logTransactionTemplate = new TransactionTemplate(transactionManager);
24 1 1. <init> : removed call to org/springframework/transaction/support/TransactionTemplate::setPropagationBehavior → KILLED
    this.logTransactionTemplate.setPropagationBehavior(
25
        TransactionDefinition.PROPAGATION_REQUIRES_NEW);
26
  }
27
28
  public JobContext createContext(Job job) {
29 1 1. createContext : replaced return value with null for edu/ucsb/cs156/jobs/services/JobContextFactory::createContext → KILLED
    return new JobContext(jobLogRepository, job, logTransactionTemplate);
30
  }
31
}

Mutations

24

1.1
Location : <init>
Killed by : edu.ucsb.cs156.jobs.services.JobContextFactoryTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.jobs.services.JobContextFactoryTests]/[method:createContext_wires_repository_job_and_requires_new_log_transactions()]
removed call to org/springframework/transaction/support/TransactionTemplate::setPropagationBehavior → KILLED

29

1.1
Location : createContext
Killed by : edu.ucsb.cs156.jobs.JobsIntegrationTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.jobs.JobsIntegrationTests]/[method:successful_job_completes_with_live_log_and_creator_stamped()]
replaced return value with null for edu/ucsb/cs156/jobs/services/JobContextFactory::createContext → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0