Package com.exonum.binding.testkit
Class TestKit.Builder
- java.lang.Object
-
- com.exonum.binding.testkit.TestKit.Builder
-
-
Method Summary
Modifier and Type Method Description TestKitbuild()Creates the TestKit instance.TestKit.Buildercopy()Returns a copy of this TestKit builder.TestKit.BuilderwithNodeType(EmulatedNodeType nodeType)Sets the type of the main TestKit node - either validator or auditor.TestKit.BuilderwithService(Class<? extends ServiceModule> serviceModule)Adds a service with which the TestKit would be instantiated.TestKit.BuilderwithServices(Class<? extends ServiceModule> serviceModule, Class<? extends ServiceModule>... serviceModules)Adds services with which the TestKit would be instantiated.TestKit.BuilderwithServices(Iterable<Class<? extends ServiceModule>> serviceModules)Adds services with which the TestKit would be instantiated.TestKit.BuilderwithTimeService(TimeProvider timeProvider)If called, will create a TestKit with time service enabled.TestKit.BuilderwithValidators(short validatorCount)Sets number of validator nodes in the TestKit network, should be positive.
-
-
-
Method Detail
-
copy
public TestKit.Builder copy()
Returns a copy of this TestKit builder.
-
withNodeType
public TestKit.Builder withNodeType(EmulatedNodeType nodeType)
Sets the type of the main TestKit node - either validator or auditor. Note thatService.afterCommit(BlockCommittedEvent)logic will only be called on the main TestKit node of this type
-
withValidators
public TestKit.Builder withValidators(short validatorCount)
Sets number of validator nodes in the TestKit network, should be positive. Note that regardless of the configured number of validators, only a single service will be instantiated. Equal to one by default.Note that validator count should be 3 or less if time service is enabled.
- Throws:
IllegalArgumentException- if validatorCount is less than one
-
withService
public TestKit.Builder withService(Class<? extends ServiceModule> serviceModule)
Adds a service with which the TestKit would be instantiated. Several services can be added.
-
withServices
@SafeVarargs public final TestKit.Builder withServices(Class<? extends ServiceModule> serviceModule, Class<? extends ServiceModule>... serviceModules)
Adds services with which the TestKit would be instantiated.
-
withServices
public TestKit.Builder withServices(Iterable<Class<? extends ServiceModule>> serviceModules)
Adds services with which the TestKit would be instantiated.
-
withTimeService
public TestKit.Builder withTimeService(TimeProvider timeProvider)
If called, will create a TestKit with time service enabled. The time service will use the given TimeProvider as a time source.Note that validator count should be 3 or less if time service is enabled.
-
build
public TestKit build()
Creates the TestKit instance.- Throws:
IllegalArgumentException- if validator count is invalidIllegalArgumentException- if service number is invalid
-
-