Interface SutHandler
- All Known Implementing Classes:
EmbeddedSutController,ExternalSutController,SutController
-
Method Summary
Modifier and TypeMethodDescriptionorg.evomaster.client.java.controller.api.dto.database.operations.InsertionResultsDtoexecInsertionsIntoDatabase(List<org.evomaster.client.java.controller.api.dto.database.operations.InsertionDto> insertions, org.evomaster.client.java.controller.api.dto.database.operations.InsertionResultsDto... previous) Execute the given data insertions into the database (if any)org.evomaster.client.java.controller.api.dto.database.operations.MongoInsertionResultsDtoexecInsertionsIntoMongoDatabase(List<org.evomaster.client.java.controller.api.dto.database.operations.MongoInsertionDto> insertions) org.evomaster.client.java.controller.api.dto.database.operations.RedisInsertionResultsDtoexecInsertionsIntoRedisDatabase(List<org.evomaster.client.java.controller.api.dto.database.operations.RedisInsertionDto> insertions) default ObjectexecuteRPCEndpoint(String json) execute an RPC endpoint with evomaster driverdefault voidexecute an RPC endpoint with evomaster driverList<org.evomaster.client.java.sql.DbSpecification>If the system under test (SUT) uses a SQL database, we need to have a configured DbSpecification to access/reset it.default Objectdefault Objectdefault ReflectionBasedRedisClientdefault ObjectgetRPCClient(String interfaceName) return an instance of a client of an RPC service.default booleanhandleLocalAuthenticationSetup(String authenticationInfo) authentication setup might be handled locally.default org.evomaster.client.java.controller.api.dto.problem.rpc.ScheduleTaskInvocationResultDtoinvokeScheduleTaskWithCustomizedHandling(String scheduleTaskDto, boolean enabled) a method to employ customized mocking for databasedefault booleanmockDatabasesWithCustomizedHandling(String mockDatabaseObjectDtos, boolean enabled) a method to employ customized mocking for databasedefault booleanmockRPCExternalServicesWithCustomizedHandling(String externalServiceDtos, boolean enabled) a method to employ customized mocking of RPC based external servicesdefault voidregister or execute specified SQL script for initializing data in database there is no need to be enabled.default booleana method to reset mocked external services with customized methoddefault voidresetDatabase(List<String> tablesToClean) reset database if the smart db cleaning is employedvoidMake sure the SUT is in a clean state (eg, reset data in database).default voidThere might be different settings based on when the SUT is run during the search of EvoMaster, and when it is later started in the generated tests.startSut()Start a new instance of the SUT.voidstopSut()Stop the SUT.
-
Method Details
-
setupForGeneratedTest
default void setupForGeneratedTest()There might be different settings based on when the SUT is run during the search of EvoMaster, and when it is later started in the generated tests. -
startSut
String startSut()Start a new instance of the SUT.
This method must be blocking until the SUT is initialized.
How this method is implemented depends on the library/framework in which the application is written. For example, in Spring applications you can use something like:
SpringApplication.run()- Returns:
- the base URL of the running SUT, eg "http://localhost:8080"
-
stopSut
void stopSut()Stop the SUT.
How to implement this method depends on the library/framework in which the application is written. For example, in Spring applications you can save in a variable the
ConfigurableApplicationContextreturned when starting the application, and then callstop()on it here. -
resetStateOfSUT
void resetStateOfSUT()Make sure the SUT is in a clean state (eg, reset data in database).
A possible (likely very inefficient) way to implement this would be to call
stopSUTfollowed bystartSUT.When dealing with databases, you can look at the utility functions from the class
DbCleaner. How to access the database depends on the application. To access ajava.sql.Connection, in Spring applications you can use something like:ctx.getBean(JdbcTemplate.class).getDataSource().getConnection(). -
execInsertionsIntoDatabase
org.evomaster.client.java.controller.api.dto.database.operations.InsertionResultsDto execInsertionsIntoDatabase(List<org.evomaster.client.java.controller.api.dto.database.operations.InsertionDto> insertions, org.evomaster.client.java.controller.api.dto.database.operations.InsertionResultsDto... previous) Execute the given data insertions into the database (if any)- Parameters:
insertions- DTOs for each insertion to executeprevious- an array of insertion results which were executed before this execution- Returns:
- insertion execution results
-
execInsertionsIntoMongoDatabase
org.evomaster.client.java.controller.api.dto.database.operations.MongoInsertionResultsDto execInsertionsIntoMongoDatabase(List<org.evomaster.client.java.controller.api.dto.database.operations.MongoInsertionDto> insertions) -
execInsertionsIntoRedisDatabase
org.evomaster.client.java.controller.api.dto.database.operations.RedisInsertionResultsDto execInsertionsIntoRedisDatabase(List<org.evomaster.client.java.controller.api.dto.database.operations.RedisInsertionDto> insertions) -
getRPCClient
return an instance of a client of an RPC service.
This method must be blocking until the SUT is initialized.
This method is only required when the problem is RPC for the moment, otherwise return null
might change string interfaceName to class interface- Parameters:
interfaceName- a full name of an interface- Returns:
- a client which could send requests to the interface
-
executeRPCEndpoint
execute an RPC endpoint with evomaster driver
- Parameters:
json- contains info of an RPC endpoint- Returns:
- value returned by this execution. it is nullable.
- Throws:
Exception
-
extractRPCSchema
default void extractRPCSchema()execute an RPC endpoint with evomaster driver
TODO remove this later if we do not use test generation with driver -
handleLocalAuthenticationSetup
authentication setup might be handled locally. then we provide this interface to define it.
- Parameters:
authenticationInfo- info for the authentication setup- Returns:
- if the authentication is set up successfully
-
getDbSpecifications
List<org.evomaster.client.java.sql.DbSpecification> getDbSpecifications()If the system under test (SUT) uses a SQL database, we need to have a configured DbSpecification to access/reset it.
When accessing a
Connectionobject to reset the state of the application, we suggest to save it to field (eg when starting the application), and set such field withDbSpecification.connection. This connection object will be used by EvoMaster to analyze the state of the database to create better test cases.To handle db in the context of testing, there might be a need to initialize data into database with a sql script. such info could be specified with
DbSpecification.dbTypeWith EvoMaster, we also support a smart DB cleaner by removing all data in tables which has been accessed after each test. In order to achieve this, we requires user to set a set of info such as database type with
DbSpecification.dbType, schema name withDbSpecification.schemaNames(TODO might remove later). In addition, we also provide an option (default istrue) to configure if such cleaner is preferred withDbSpecification.employSmartDbClean.- Returns:
nullif the SUT does not use any SQL database
-
getMongoConnection
-
getOpenSearchConnection
-
getRedisConnection
-
registerOrExecuteInitSqlCommandsIfNeeded
default void registerOrExecuteInitSqlCommandsIfNeeded()register or execute specified SQL script for initializing data in database there is no need to be enabled.
-
resetDatabase
reset database if the smart db cleaning is employed
- Parameters:
tablesToClean- represents a list of table which will be reset based on specified DbSpecification. note that null tablesToClean means all table will be reset.
-
resetCustomizedMethodForMockObject
default boolean resetCustomizedMethodForMockObject()a method to reset mocked external services with customized method
-
mockRPCExternalServicesWithCustomizedHandling
default boolean mockRPCExternalServicesWithCustomizedHandling(String externalServiceDtos, boolean enabled) a method to employ customized mocking of RPC based external services
- Parameters:
externalServiceDtos- contains info about how to setup responses with json format, note that the json should be able to be converted to a list of MockRPCExternalServiceDtoenabled- reflect to enable (set it true) or disable (set it false) the specified external service dtos. Note that null [externalServiceDtos] with false [enabled] means that all existing external service setup should be disabled.- Returns:
- whether the mocked instance starts successfully,
-
mockDatabasesWithCustomizedHandling
a method to employ customized mocking for database
- Parameters:
mockDatabaseObjectDtos- contains info about how to set up mock object for databases with json format, note that the json should be able to be converted to a list of MockDatabaseDtoenabled- reflect to enable (set it true) or disable (set it false) the specified mock object Note that null [mockDatabaseObjectDtos] with false [enabled] means that all existing mock objects for databases should be disabled.- Returns:
- whether the mocked instance starts successfully,
-
invokeScheduleTaskWithCustomizedHandling
default org.evomaster.client.java.controller.api.dto.problem.rpc.ScheduleTaskInvocationResultDto invokeScheduleTaskWithCustomizedHandling(String scheduleTaskDto, boolean enabled) a method to employ customized mocking for database
- Parameters:
scheduleTaskDto- contains info about schedule tasks should be invokedenabled- reflect to enable (set it true) or terminate (set it false) the schedule task- Returns:
- invocation results of schedule task
-