Permalink
Browse files

output format now defined in SUT controller

  • Loading branch information...
arcuri82 committed Nov 5, 2018
1 parent e1970e2 commit 24b11b9e9e791081405f3a7557408db6915da753
@@ -22,7 +22,7 @@
Note: this enum must be kept in sync with what declared in
org.evomaster.core.output.OutputFormat
*/
enum OutputFormat {
public enum OutputFormat {
JAVA_JUNIT_5,
JAVA_JUNIT_4
}
@@ -48,6 +48,7 @@ public SutInfoDto getSutInfo() {
dto.baseUrlOfSUT = baseUrlOfSUT;
dto.infoForAuthentication = sutController.getInfoForAuthentication();
dto.sqlSchemaDto = sutController.getSqlDatabaseSchema();
dto.defaultOutputFormat = sutController.getPreferredOutputFormat();
ProblemInfo info = sutController.getProblemInfo();
if(info == null){
@@ -14,6 +14,7 @@
import org.evomaster.clientJava.controllerApi.ControllerConstants;
import org.evomaster.clientJava.controllerApi.dto.AuthenticationDto;
import org.evomaster.clientJava.controllerApi.dto.ExtraHeuristicDto;
import org.evomaster.clientJava.controllerApi.dto.SutInfoDto;
import org.evomaster.clientJava.controllerApi.dto.database.execution.ReadDbDataDto;
import org.evomaster.clientJava.controllerApi.dto.database.operations.InsertionDto;
import org.evomaster.clientJava.controllerApi.dto.database.schema.DbSchemaDto;
@@ -292,4 +293,9 @@ public final DbSchemaDto getSqlDatabaseSchema(){
* @return an instance of object with all the needed data for the specific addressed problem
*/
public abstract ProblemInfo getProblemInfo();
/**
* Specify the format in which the test cases should be generated
*/
public abstract SutInfoDto.OutputFormat getPreferredOutputFormat();
}
@@ -328,7 +328,7 @@ class EMConfig {
@Cfg("Specify in which format the tests should be outputted")
var outputFormat = OutputFormat.JAVA_JUNIT_4
var outputFormat = OutputFormat.DEFAULT
@Cfg("Specify if test classes should be created as output of the tool. " +
@@ -5,6 +5,10 @@ package org.evomaster.core.output
*/
enum class OutputFormat {
/**
Use the format specified in the SUT driver
*/
DEFAULT,
JAVA_JUNIT_5,
JAVA_JUNIT_4
;
@@ -7,6 +7,7 @@ import org.evomaster.clientJava.controllerApi.dto.SutInfoDto
import org.evomaster.core.EMConfig
import org.evomaster.core.database.DbAction
import org.evomaster.core.database.SqlInsertBuilder
import org.evomaster.core.output.OutputFormat
import org.evomaster.core.problem.rest.*
import org.evomaster.core.problem.rest.auth.AuthenticationHeader
import org.evomaster.core.problem.rest.auth.AuthenticationInfo
@@ -66,7 +67,7 @@ class RestSampler : Sampler<RestIndividual>() {
}
actionCluster.clear()
RestActionBuilder.addActionsFromSwagger(swagger, actionCluster, infoDto?.restProblem?.endpointsToSkip ?: listOf())
RestActionBuilder.addActionsFromSwagger(swagger, actionCluster, infoDto.restProblem?.endpointsToSkip ?: listOf())
setupAuthentication(infoDto)
@@ -76,6 +77,15 @@ class RestSampler : Sampler<RestIndividual>() {
sqlInsertBuilder = SqlInsertBuilder(infoDto.sqlSchemaDto)
}
if(configuration.outputFormat == OutputFormat.DEFAULT){
try {
val format = OutputFormat.valueOf(infoDto.defaultOutputFormat?.toString()!!)
configuration.outputFormat = format
} catch (e : Exception){
throw SutProblemException("Failed to use test output format: " + infoDto.defaultOutputFormat)
}
}
log.debug("Done initializing {}", RestSampler::class.simpleName)
}
@@ -4,6 +4,7 @@
import org.evomaster.clientJava.controller.problem.ProblemInfo;
import org.evomaster.clientJava.controller.problem.RestProblem;
import org.evomaster.clientJava.controllerApi.dto.AuthenticationDto;
import org.evomaster.clientJava.controllerApi.dto.SutInfoDto;
import java.sql.Connection;
import java.util.List;
@@ -95,4 +96,9 @@ public ProblemInfo getProblemInfo() {
null
);
}
@Override
public SutInfoDto.OutputFormat getPreferredOutputFormat() {
return SutInfoDto.OutputFormat.JAVA_JUNIT_4;
}
}
@@ -4,6 +4,7 @@
import org.evomaster.clientJava.controller.problem.ProblemInfo;
import org.evomaster.clientJava.controller.problem.RestProblem;
import org.evomaster.clientJava.controllerApi.dto.AuthenticationDto;
import org.evomaster.clientJava.controllerApi.dto.SutInfoDto;
import java.sql.Connection;
import java.util.List;
@@ -95,4 +96,9 @@ public ProblemInfo getProblemInfo() {
);
}
@Override
public SutInfoDto.OutputFormat getPreferredOutputFormat() {
return SutInfoDto.OutputFormat.JAVA_JUNIT_5;
}
}
@@ -4,6 +4,7 @@
import org.evomaster.clientJava.controller.problem.ProblemInfo;
import org.evomaster.clientJava.controller.problem.RestProblem;
import org.evomaster.clientJava.controllerApi.dto.AuthenticationDto;
import org.evomaster.clientJava.controllerApi.dto.SutInfoDto;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
@@ -83,4 +84,9 @@ public String getDatabaseDriverName() {
return null;
}
@Override
public SutInfoDto.OutputFormat getPreferredOutputFormat() {
return SutInfoDto.OutputFormat.JAVA_JUNIT_5;
}
}

0 comments on commit 24b11b9

Please sign in to comment.