Class EMController

java.lang.Object
org.evomaster.client.java.controller.internal.EMController

@Path("") @Produces("application/json;charset=utf8;version=1") public class EMController extends Object
Note: usually a RESTful webservice would be stateless. Here, however, we have state. Reason is that we need it, and the only client is the EvoMaster process. Furthermore, the code of the controller should be as simple as possible, as we might need to re-implement it in different languages.
  • Constructor Summary

    Constructors
    Constructor
    Description
    EMController(SutController sutController)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    javax.ws.rs.core.Response
    deriveParams(List<org.evomaster.client.java.controller.api.dto.problem.param.DerivedParamChangeReqDto> dtos)
     
    javax.ws.rs.core.Response
    executeDatabaseCommand(org.evomaster.client.java.controller.api.dto.database.operations.DatabaseCommandDto dto, javax.servlet.http.HttpServletRequest httpServletRequest)
     
    javax.ws.rs.core.Response
    executeMongoInsertion(org.evomaster.client.java.controller.api.dto.database.operations.MongoDatabaseCommandDto dto, javax.servlet.http.HttpServletRequest httpServletRequest)
     
    javax.ws.rs.core.Response
    executeRedisInsertion(org.evomaster.client.java.controller.api.dto.database.operations.RedisDatabaseCommandsDto dto, javax.servlet.http.HttpServletRequest httpServletRequest)
     
    static Set<String>
    Only used for debugging/testing
    javax.ws.rs.core.Response
    getControllerInfoDto(javax.servlet.http.HttpServletRequest httpServletRequest, String methodReplacementCategories)
     
    javax.ws.rs.core.Response
    getSutInfo(javax.servlet.http.HttpServletRequest httpServletRequest)
     
    javax.ws.rs.core.Response
    getTestResults(String idList, boolean killSwitch, boolean fullyCovered, boolean descriptiveIds, boolean queryFromDatabase, javax.servlet.http.HttpServletRequest httpServletRequest)
    Return the coverage of the test executed so far, plus the extra heuristics.
    javax.ws.rs.core.Response
    getTestResultsWithIdsInBody(List<Integer> idList, boolean killSwitch, boolean fullyCovered, boolean descriptiveIds, boolean queryFromDatabase, javax.servlet.http.HttpServletRequest httpServletRequest)
    Same as the GET variant, but with the ids of the targets in the body payload instead of in the URI.
    javax.ws.rs.core.Response
     
    javax.ws.rs.core.Response
    newAction(org.evomaster.client.java.controller.api.dto.ActionDto dto, boolean queryFromDatabase, javax.servlet.http.HttpServletRequest httpServletRequest)
     
    javax.ws.rs.core.Response
    newSearch(javax.servlet.http.HttpServletRequest httpServletRequest)
     
    javax.ws.rs.core.Response
    postSearchAction(org.evomaster.client.java.controller.api.dto.PostSearchActionDto dto, javax.servlet.http.HttpServletRequest httpServletRequest)
     
    static void
    Only used debugging/testing
    javax.ws.rs.core.Response
    runSut(org.evomaster.client.java.controller.api.dto.SutRunDto dto, javax.servlet.http.HttpServletRequest httpServletRequest)
     
    javax.ws.rs.core.Response
    scheduleTasksCommand(org.evomaster.client.java.controller.api.dto.problem.rpc.ScheduleTaskInvocationsDto command, boolean killSwitch, boolean queryFromDatabase, javax.servlet.http.HttpServletRequest httpServletRequest)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EMController

      public EMController(SutController sutController)
  • Method Details

    • getConnectedClientsSoFar

      public static Set<String> getConnectedClientsSoFar()
      Only used for debugging/testing
      Returns:
      host:port of all clients connected so far
    • resetConnectedClientsSoFar

      public static void resetConnectedClientsSoFar()
      Only used debugging/testing
    • getWarning

      @Path("/") @GET @Produces("text/html") public javax.ws.rs.core.Response getWarning()
    • getSutInfo

      @Path("/infoSUT") @GET public javax.ws.rs.core.Response getSutInfo(@Context javax.servlet.http.HttpServletRequest httpServletRequest)
    • getControllerInfoDto

      @Path("/controllerInfo") @GET public javax.ws.rs.core.Response getControllerInfoDto(@Context javax.servlet.http.HttpServletRequest httpServletRequest, @QueryParam("methodReplacementCategories") String methodReplacementCategories)
    • newSearch

      @Path("/newSearch") @POST public javax.ws.rs.core.Response newSearch(@Context javax.servlet.http.HttpServletRequest httpServletRequest)
    • postSearchAction

      @Path("/postSearchAction") @POST @Consumes("application/json;charset=utf8;version=1") public javax.ws.rs.core.Response postSearchAction(org.evomaster.client.java.controller.api.dto.PostSearchActionDto dto, @Context javax.servlet.http.HttpServletRequest httpServletRequest)
    • runSut

      @Path("/runSUT") @PUT @Consumes("application/json;charset=utf8;version=1") public javax.ws.rs.core.Response runSut(org.evomaster.client.java.controller.api.dto.SutRunDto dto, @Context javax.servlet.http.HttpServletRequest httpServletRequest)
    • getTestResults

      @Path("/testResults") @GET public javax.ws.rs.core.Response getTestResults(@QueryParam("ids") @DefaultValue("") String idList, @QueryParam("killSwitch") @DefaultValue("false") boolean killSwitch, @QueryParam("fullyCovered") @DefaultValue("false") boolean fullyCovered, @QueryParam("descriptiveIds") @DefaultValue("false") boolean descriptiveIds, @QueryParam("queryFromDatabase") @DefaultValue("true") boolean queryFromDatabase, @Context javax.servlet.http.HttpServletRequest httpServletRequest)
      Return the coverage of the test executed so far, plus the extra heuristics.

      This is kept as the compatibility form of the endpoint. EvoMaster Core no longer calls it: it uses the POST variant below, because the ids of the targets do not always fit in a URI. It is still part of the public contract of the Driver, though, and is what any Core older than this change talks to. It is also the only form usable by hand, eg with curl, to inspect a running Driver.

      Both forms share the exact same logic: see computeTestResults(java.util.Set<java.lang.Integer>, boolean, boolean, boolean, boolean).

    • getTestResultsWithIdsInBody

      @Path("/testResults") @POST @Consumes("application/json") public javax.ws.rs.core.Response getTestResultsWithIdsInBody(List<Integer> idList, @QueryParam("killSwitch") @DefaultValue("false") boolean killSwitch, @QueryParam("fullyCovered") @DefaultValue("false") boolean fullyCovered, @QueryParam("descriptiveIds") @DefaultValue("false") boolean descriptiveIds, @QueryParam("queryFromDatabase") @DefaultValue("true") boolean queryFromDatabase, @Context javax.servlet.http.HttpServletRequest httpServletRequest)
      Same as the GET variant, but with the ids of the targets in the body payload instead of in the URI. This is the form EvoMaster Core uses.

      A search can easily end up asking for thousands of targets at once. Their ids do not fit in the request line: Jetty rejects with a 414 anything above 8192 bytes, well before the request reaches this class. Sending them in the body has no such limit.

      A POST for what is a read is not great REST, but there is no alternative: a GET carrying a body cannot be sent by the HTTP client in use (the JDK rewrites the method to POST on its own as soon as anything is written to the connection).

      Parameters:
      idList - the ids of the targets to return fitness score for. As in the GET variant, an empty (or missing) list means "return everything".
    • scheduleTasksCommand

      @Path("/scheduleTasksCommand") @Consumes("application/json") @POST public javax.ws.rs.core.Response scheduleTasksCommand(org.evomaster.client.java.controller.api.dto.problem.rpc.ScheduleTaskInvocationsDto command, @QueryParam("killSwitch") @DefaultValue("false") boolean killSwitch, @QueryParam("queryFromDatabase") @DefaultValue("true") boolean queryFromDatabase, @Context javax.servlet.http.HttpServletRequest httpServletRequest)
    • deriveParams

      @Path("/deriveParams") @Consumes("application/json") @POST public javax.ws.rs.core.Response deriveParams(List<org.evomaster.client.java.controller.api.dto.problem.param.DerivedParamChangeReqDto> dtos)
    • newAction

      @Path("/newAction") @Consumes("application/json") @PUT public javax.ws.rs.core.Response newAction(org.evomaster.client.java.controller.api.dto.ActionDto dto, @QueryParam("queryFromDatabase") @DefaultValue("true") boolean queryFromDatabase, @Context javax.servlet.http.HttpServletRequest httpServletRequest)
    • executeDatabaseCommand

      @Path("/databaseCommand") @Consumes("application/json;charset=utf8;version=1") @POST public javax.ws.rs.core.Response executeDatabaseCommand(org.evomaster.client.java.controller.api.dto.database.operations.DatabaseCommandDto dto, @Context javax.servlet.http.HttpServletRequest httpServletRequest)
    • executeMongoInsertion

      @Path("/mongoInsertion") @Consumes("application/json;charset=utf8;version=1") @POST public javax.ws.rs.core.Response executeMongoInsertion(org.evomaster.client.java.controller.api.dto.database.operations.MongoDatabaseCommandDto dto, @Context javax.servlet.http.HttpServletRequest httpServletRequest)
    • executeRedisInsertion

      @Path("/redisInsertion") @Consumes("application/json;charset=utf8;version=1") @POST public javax.ws.rs.core.Response executeRedisInsertion(org.evomaster.client.java.controller.api.dto.database.operations.RedisDatabaseCommandsDto dto, @Context javax.servlet.http.HttpServletRequest httpServletRequest)