How to use resetExtraHeuristics method of org.evomaster.client.java.controller.internal.SutController class

Best EvoMaster code snippet using org.evomaster.client.java.controller.internal.SutController.resetExtraHeuristics

Source:SutController.java Github

copy

Full Screen

...142 */143 public final void initSqlHandler() {144 sqlHandler.setConnection(getConnection());145 }146 public final void resetExtraHeuristics() {147 sqlHandler.reset();148 }149 public final List<ExtraHeuristicsDto> getExtraHeuristics() {150 if (extras.size() == actionIndex) {151 extras.add(computeExtraHeuristics());152 }153 return new ArrayList<>(extras);154 }155 public final ExtraHeuristicsDto computeExtraHeuristics() {156 ExtraHeuristicsDto dto = new ExtraHeuristicsDto();157 if(sqlHandler.isCalculateHeuristics()) {158 sqlHandler.getDistances().stream()159 .map(p ->160 new HeuristicEntryDto(161 HeuristicEntryDto.Type.SQL,162 HeuristicEntryDto.Objective.MINIMIZE_TO_ZERO,163 p.sqlCommand,164 p.distance165 ))166 .forEach(h -> dto.heuristics.add(h));167 }168 if (sqlHandler.isCalculateHeuristics() || sqlHandler.isExtractSqlExecution()){169 ExecutionDto executionDto = sqlHandler.getExecutionDto();170 dto.databaseExecutionDto = executionDto;171 }172 return dto;173 }174 /**175 * Extra information about the SQL Database Schema, if any is present.176 * Note: this is extracted by querying the database itself.177 * So the database must be up and running.178 *179 * @return a DTO with the schema information180 * @see SutController#getConnection181 */182 public final DbSchemaDto getSqlDatabaseSchema() {183 if (schemaDto != null) {184 return schemaDto;185 }186 if (getConnection() == null) {187 return null;188 }189 try {190 schemaDto = SchemaExtractor.extract(getConnection());191 } catch (Exception e) {192 SimpleLogger.error("Failed to extract the SQL Database Schema: " + e.getMessage());193 return null;194 }195 return schemaDto;196 }197 /**198 * Either there is no connection, or, if there is, then it must have P6Spy configured.199 * But this might not apply to all kind controllers200 *201 * @return false if the verification failed202 */203 public final boolean verifySqlConnection(){204 Connection connection = getConnection();205 if(connection == null206 //check does not make sense for External207 || !(this instanceof EmbeddedSutController)){208 return true;209 }210 /*211 bit hacky/brittle, but seems there is no easy way to check if a connection is212 using P6Spy.213 However, the name of driver's package would appear when doing a toString on it214 */215 String info = connection.toString();216 return info.contains("p6spy");217 }218 /**219 * Re-initialize all internal data to enable a completely new search phase220 * which should be independent from previous ones221 */222 public abstract void newSearch();223 /**224 * Re-initialize some internal data needed before running a new test225 */226 public final void newTest() {227 actionIndex = -1;228 resetExtraHeuristics();229 extras.clear();230 newTestSpecificHandler();231 }232 /**233 * As some heuristics are based on which action (eg HTTP call, or click of button)234 * in the test sequence is executed, and their order, we need to keep track of which235 * action does cover what.236 *237 * @param dto the DTO with the information about the action (eg its index in the test)238 */239 public final void newAction(ActionDto dto) {240 if (dto.index > extras.size()) {241 extras.add(computeExtraHeuristics());242 }243 this.actionIndex = dto.index;244 resetExtraHeuristics();245 newActionSpecificHandler(dto);246 }247 public abstract void newTestSpecificHandler();248 public abstract void newActionSpecificHandler(ActionDto dto);249 /**250 * Check if bytecode instrumentation is on.251 *252 * @return true if the instrumentation is on253 */254 public abstract boolean isInstrumentationActivated();255 /**256 * Check if the system under test (SUT) is running and fully initialized257 *258 * @return true if the SUT is running...

Full Screen

Full Screen

resetExtraHeuristics

Using AI Code Generation

copy

Full Screen

1import org.evomaster.client.java.controller.api.dto.SutInfoDto;2import org.evomaster.client.java.controller.internal.SutController;3import org.evomaster.client.java.controller.internal.db.SqlScriptRunner;4import org.evomaster.client.java.controller.internal.db.SqlScriptRunnerImpl;5import org.evomaster.client.java.controller.internal.db.SqlScriptRunnerImplTest;6import org.junit.jupiter.api.Test;7import java.sql.Connection;8import java.sql.DriverManager;9import java.sql.SQLException;10import java.util.ArrayList;11import java.util.List;12import static org.junit.jupiter.api.Assertions.assertTrue;13public class ResetExtraHeuristicsTest {14 public void testResetExtraHeuristics() throws Exception {15 Connection connection = DriverManager.getConnection("jdbc:h2:mem:test", "sa", "");16 SqlScriptRunner runner = new SqlScriptRunnerImpl(connection);17 SutController controller = new SutController();18 SutInfoDto dto = controller.startSut();19 assertTrue(dto.isSutRunning());20 String createTable = "CREATE TABLE IF NOT EXISTS test (id INT PRIMARY KEY, name VARCHAR(255));";21 runner.runSqlScript(createTable);22 String insertData = "INSERT INTO test VALUES (1, 'A');";23 runner.runSqlScript(insertData);24 String updateData = "UPDATE test SET name = 'B' WHERE id = 1;";25 runner.runSqlScript(updateData);26 String deleteData = "DELETE FROM test WHERE id = 1;";27 runner.runSqlScript(deleteData);28 String insertData2 = "INSERT INTO test VALUES (1, 'C');";29 runner.runSqlScript(insertData2);30 String updateData2 = "UPDATE test SET name = 'D' WHERE id = 1;";31 runner.runSqlScript(updateData2);32 String deleteData2 = "DELETE FROM test WHERE id = 1;";33 runner.runSqlScript(deleteData2);34 String insertData3 = "INSERT INTO test VALUES (1, 'E');";35 runner.runSqlScript(insertData3);36 String updateData3 = "UPDATE test SET name = 'F' WHERE id = 1;";37 runner.runSqlScript(updateData3);

Full Screen

Full Screen

resetExtraHeuristics

Using AI Code Generation

copy

Full Screen

1import org.evomaster.client.java.controller.internal.SutController;2public class EvoMasterController {3 public static void main(String[] args) {4 SutController.resetExtraHeuristics();5 }6}7import org.evomaster.client.java.controller.internal.SutController;8public class EvoMasterController {9 public static void main(String[] args) {10 SutController.resetExtraHeuristics();11 }12}13import org.evomaster.client.java.controller.internal.SutController;14public class EvoMasterController {15 public static void main(String[] args) {16 SutController.resetExtraHeuristics();17 }18}19import org.evomaster.client.java.controller.internal.SutController;20public class EvoMasterController {21 public static void main(String[] args) {22 SutController.resetExtraHeuristics();23 }24}25import org.evomaster.client.java.controller.internal.SutController;26public class EvoMasterController {27 public static void main(String[] args) {28 SutController.resetExtraHeuristics();29 }30}31import org.evomaster.client.java.controller.internal.SutController;32public class EvoMasterController {33 public static void main(String[] args) {34 SutController.resetExtraHeuristics();35 }36}37import org.evomaster.client.java.controller.internal.SutController;38public class EvoMasterController {39 public static void main(String[] args) {40 SutController.resetExtraHeuristics();41 }42}43import org.evomaster.client.java.controller.internal.SutController;44public class EvoMasterController {45 public static void main(String[] args) {

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run EvoMaster automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful