Skip to content

Commit

Permalink
split it into two files
Browse files Browse the repository at this point in the history
  • Loading branch information
man-zhang committed Nov 1, 2023
1 parent f18ed7d commit 3f9ddbc
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,37 @@
import org.evomaster.client.java.controller.problem.RPCProblem;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HypermutationController extends SpringController {

private HypermutationService.Client client;

private Map<String, List<String>> skipped;

public HypermutationController(){
super(HypermutationApp.class);
skipped = null;
}

public HypermutationController(Map<String, List<String>> skippedFunctions){
super(HypermutationApp.class);
skipped = skippedFunctions;
}

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

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.evomaster.e2etests.spring.rpc.examples.hypermutation;

import com.foo.rpc.examples.spring.hypermutation.HypermutationController;
import com.foo.rpc.examples.spring.hypermutation.HypermutationService;
import org.evomaster.core.problem.rpc.RPCCallResultCategory;
import org.evomaster.core.problem.rpc.RPCIndividual;
import org.evomaster.core.search.Solution;
import org.evomaster.e2etests.spring.rpc.examples.SpringRPCTestBase;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertTrue;

public class AdaptiveHypermutationEMTest extends SpringRPCTestBase {


@BeforeAll
public static void initClass() throws Exception {
SpringRPCTestBase.initClass(new HypermutationController(new HashMap<String, List<String>>(){{
put(HypermutationService.Iface.class.getName(), new ArrayList<String>(){{add("differentWeight");}});
}}));
}

@Test
public void testRunEM() throws Throwable {
runTestHandlingFlakyAndCompilation(
"AdaptiveHypermutationEM",
"org.bar.AdaptiveHypermutationEM",
25_000,
(args) -> {
args.add("--baseTaintAnalysisProbability");
args.add("0.9");

Solution<RPCIndividual> solution = initAndRun(args);

assertTrue(solution.getIndividuals().size() >= 1);

assertRPCEndpointResult(solution, HypermutationService.Iface.class.getName()+":lowWeightHighCoverage", RPCCallResultCategory.HANDLED.name());
assertAllContentInResponseForEndpoint(solution,HypermutationService.Iface.class.getName()+":lowWeightHighCoverage" , Arrays.asList("x1","x2","x3","x4","x5", "y", "z"));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertTrue;

Expand All @@ -18,7 +21,9 @@ public class HypermutationEMTest extends SpringRPCTestBase {

@BeforeAll
public static void initClass() throws Exception {
SpringRPCTestBase.initClass(new HypermutationController());
SpringRPCTestBase.initClass(new HypermutationController(new HashMap<String, List<String>>(){{
put(HypermutationService.Iface.class.getName(), new ArrayList<String>(){{add("lowWeightHighCoverage");}});
}}));
}

@Test
Expand All @@ -37,8 +42,6 @@ public void testRunEM() throws Throwable {

assertRPCEndpointResult(solution, HypermutationService.Iface.class.getName()+":differentWeight", RPCCallResultCategory.HANDLED.name());
assertAllContentInResponseForEndpoint(solution,HypermutationService.Iface.class.getName()+":differentWeight" , Arrays.asList("x", "y", "z"));
assertRPCEndpointResult(solution, HypermutationService.Iface.class.getName()+":lowWeightHighCoverage", RPCCallResultCategory.HANDLED.name());
assertAllContentInResponseForEndpoint(solution,HypermutationService.Iface.class.getName()+":lowWeightHighCoverage" , Arrays.asList("x1","x2","x3","x4","x5", "y", "z"));
});
}
}

0 comments on commit 3f9ddbc

Please sign in to comment.