Skip to content

Commit

Permalink
Merge pull request #518 from EMResearch/rpc-improvements
Browse files Browse the repository at this point in the history
Rpc improvements
  • Loading branch information
arcuri82 committed May 19, 2022
2 parents f449606 + 71a49a9 commit d216a6a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.evomaster.client.java.controller.api.dto.problem.rpc;

/**
* a list of RPC type supported by evomaster
* A list of RPC types supported by EvoMaster
*
* with different types, the handling might be different,
* eg, create instance for input, exception handling and extraction
* With different types, the handling might be different,
* eg, create instance for input, exception handling and extraction.
*
* If your type is not listed here, use the default [GENERAL]
*/
public enum RPCType {
/**
Expand All @@ -16,11 +18,11 @@ public enum RPCType {
/**
* thrift
*/
THRIFT,
THRIFT

/**
* gRPC
* TODO, NOT SUPPORT YET
*/
gRPC
//gRPC
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCType;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -51,12 +52,23 @@ public class RPCProblem implements ProblemInfo{
*/
public final Map<String, List<String>> involveEndpointsByAnnotation;


/**
*
* @param interfaceClass an interface with API definition
* @param client an actual client library for the API
* @param type the type of RPC system
*/
public <T,K extends T> RPCProblem(Class<T> interfaceClass, K client, RPCType type){
this(new HashMap<String,Object>(){{put(interfaceClass.getName(),client);}},type);
}

/**
*
* @param mapOfInterfaceAndClient a map of interfaces with their corresponding client
*/
public RPCProblem(Map<String, Object> mapOfInterfaceAndClient) {
this(mapOfInterfaceAndClient, RPCType.THRIFT);
this(mapOfInterfaceAndClient, RPCType.GENERAL);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.thrift.transport.THttpClient;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCType;
import org.evomaster.client.java.controller.problem.ProblemInfo;
import org.evomaster.client.java.controller.problem.RPCProblem;

Expand All @@ -21,9 +22,7 @@ public DbDirectIntController() {

@Override
public ProblemInfo getProblemInfo() {
return new RPCProblem(new HashMap<String, Object>() {{
put(DbDirectIntService.Iface.class.getName(), client);
}});
return new RPCProblem(DbDirectIntService.Iface.class, client, RPCType.THRIFT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.thrift.transport.THttpClient;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCType;
import org.evomaster.client.java.controller.problem.ProblemInfo;
import org.evomaster.client.java.controller.problem.RPCProblem;

Expand All @@ -21,9 +22,7 @@ public HypermutationController(){

@Override
public ProblemInfo getProblemInfo() {
return new RPCProblem(new HashMap<String, Object>() {{
put(HypermutationService.Iface.class.getName(), client);
}});
return new RPCProblem(HypermutationService.Iface.class, client, RPCType.THRIFT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.thrift.transport.THttpClient;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCType;
import org.evomaster.client.java.controller.problem.ProblemInfo;
import org.evomaster.client.java.controller.problem.RPCProblem;

Expand All @@ -21,9 +22,7 @@ public RegexDateController(){

@Override
public ProblemInfo getProblemInfo() {
return new RPCProblem(new HashMap<String, Object>() {{
put(RegexDateService.Iface.class.getName(), client);
}});
return new RPCProblem(RegexDateService.Iface.class, client, RPCType.THRIFT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.thrift.transport.THttpClient;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
import org.evomaster.client.java.controller.api.dto.problem.rpc.RPCType;
import org.evomaster.client.java.controller.problem.ProblemInfo;
import org.evomaster.client.java.controller.problem.RPCProblem;

Expand All @@ -21,9 +22,7 @@ public ThriftExceptionRPCController(){

@Override
public ProblemInfo getProblemInfo() {
return new RPCProblem(new HashMap<String, Object>() {{
put(ThriftExceptionService.Iface.class.getName(), client);
}});
return new RPCProblem(ThriftExceptionService.Iface.class, client, RPCType.THRIFT);
}

@Override
Expand Down

0 comments on commit d216a6a

Please sign in to comment.