Resources directly associated with the Line/Job Context API
There are two resources directly associated with the LOB/Job context API:
- Context Factory
- PCRemoteSmokeTestHelper
Context Factory
Context Factory is the name used to refer to two Gosu classes: ContextFactory (an interface) and ContextFactoryImpl (an implementation of the interface). All of the implementations needed for testing (such as implementations for admin testing, activity testing, and so on) are injected into Context Factory. Context Factory is injected into every step file. In this way, Context Factory acts as a dependency object that provides every step definition with the ability to identify and call the appropriate implementation.
For the Line/Job context API, the only interfaces injected into ContextFactoryImpl are the generic job interfaces, such as PolicyChangeContext, RenewalContext, and so on. All of the impls that are specific to a single Line/Job combination (such as WCPolicyChangeContextImpl or PARenewalContextImpl) extend the generic job level, and therefore they are inherently available to ContextFactoryImpl. When you create a new line of business, the new line extends the generic job level. Therefore, you typically do not need to modify Context Factory.
PCRemoteSmokeTestHelper
PCRemoteSmokeTestHelper is a class that binds every context API implementation to one or more impl classes. This class contains the logic used during runtime to identify the correct impl to use for a given interface that has been injected into a step class through Context Factory.
For the Line/Job context API, the impls that are specific to a single Line/Job combination are bound to the <Job>Context interface using map binders. For example, the following code creates the policyChangeContextBinder map binder:
// Policy Change Contexts
var policyChangeContexts = MapBinder.newMapBinder(binder(), ProductCode, PolicyChangeContext)
policyChangeContexts.addBinding(ProductCode.PERSONAL_AUTO).to(PAPolicyChangeContextImpl)
policyChangeContexts.addBinding(ProductCode.WORKERS_COMPENSATION).to(WCPolicyChangeContextImpl)
When PolicyChangeContext is called in a scenario that uses a given policy type, the methods in the appropriate Line/Job-specific impl are used to execute the scenario.
