Skip to content

Commit 5173de7

Browse files
committed
add a if to check that the total amounts needs to be bigger than the amount of mutants selected. Also, create a MutApkException for control
1 parent a73d3a8 commit 5173de7

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

src/main/java/edu/uniandes/tsdl/mutapk/MutAPK.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@
77
import java.io.FileWriter;
88
import java.io.IOException;
99
import java.util.HashMap;
10-
import java.util.HashSet;
1110
import java.util.List;
12-
import java.util.Map;
1311
import java.util.Set;
1412

1513
import org.json.simple.JSONObject;
1614
import org.json.simple.parser.JSONParser;
1715

1816
import edu.uniandes.tsdl.mutapk.detectors.MutationLocationDetector;
1917
import edu.uniandes.tsdl.mutapk.detectors.MutationLocationListBuilder;
20-
import edu.uniandes.tsdl.mutapk.hashfunction.sha3.ApkHash;
18+
import edu.uniandes.tsdl.mutapk.exception.MutAPKException;
2119
import edu.uniandes.tsdl.mutapk.hashfunction.sha3.ApkHashOrder;
2220
import edu.uniandes.tsdl.mutapk.hashfunction.sha3.ApkHashSeparator;
23-
import edu.uniandes.tsdl.mutapk.hashfunction.sha3.Sha3;
2421
import edu.uniandes.tsdl.mutapk.helper.APKToolWrapper;
2522
import edu.uniandes.tsdl.mutapk.helper.Helper;
2623
import edu.uniandes.tsdl.mutapk.model.MutationType;
@@ -45,10 +42,11 @@ public static void main(String[] args) {
4542
// System.out.println(finalTime);
4643
// System.out.println(finalTime-initialTime);
4744

48-
} catch (Exception e) {
45+
}catch (MutAPKException e) {
4946
System.out.println(e.getMessage());
47+
} catch (Exception e) {
5048
e.printStackTrace();
51-
}
49+
}
5250
}
5351

5452
public static void runMutAPK(String[] args) throws NumberFormatException, Exception {
@@ -162,9 +160,10 @@ public static void runMutAPK(String[] args) throws NumberFormatException, Except
162160
// Read selected operators
163161
OperatorBundle operatorBundle = new OperatorBundle(operatorsDir);
164162
System.out.println(operatorBundle.printSelectedOperators());
165-
163+
164+
166165
if (amountMutants > 0 && operatorBundle.getAmountOfSelectedOperators() > amountMutants) {
167-
throw new Exception("you must select as many mutants as selected operators, right now you select "
166+
throw new MutAPKException("you must select as many mutants as selected operators, right now you select "
168167
+ operatorBundle.getAmountOfSelectedOperators() + " operators but only ask for " + amountMutants
169168
+ " mutants");
170169
}
@@ -210,6 +209,10 @@ public static void runMutAPK(String[] args) throws NumberFormatException, Except
210209
// }
211210
}
212211

212+
if(totalMutants < amountMutants) {
213+
throw new MutAPKException("The total of mutants need to be greater than the amount of mutants asked");
214+
}
215+
213216
// 3. Build MutationLocation List
214217
List<MutationLocation> mutationLocationList = MutationLocationListBuilder.buildList(locations);
215218
printLocationList(mutationLocationList, mutantsFolder, appName);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package edu.uniandes.tsdl.mutapk.exception;
2+
3+
public class MutAPKException extends Exception{
4+
5+
private static final long serialVersionUID = 8075021805177742215L;
6+
7+
public MutAPKException(String msg) {
8+
super(msg);
9+
}
10+
11+
}

src/main/java/edu/uniandes/tsdl/mutapk/operators/OperatorBundle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public List<MutationLocationDetector> getTextBasedDetectors() {
7878
public int getAmountOfSelectedOperators() {
7979
return bundle.keySet().size();
8080
}
81+
8182

8283
public String printSelectedOperators() {
8384

0 commit comments

Comments
 (0)