Skip to content
Snippets Groups Projects
Commit b9ca8352 authored by a.croix's avatar a.croix
Browse files

Improve tests

parent 2a662eac
No related branches found
No related tags found
No related merge requests found
Pipeline #2090 passed
......@@ -24,7 +24,7 @@ public class Factory {
return new SolutionAUC(a);
} else {
throw new IllegalArgumentException(
"Provide o correct type of Solution");
"Provide a correct type of Solution");
}
}
}
......@@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import static org.junit.jupiter.api.Assertions.*;
......@@ -20,7 +21,7 @@ class UtilsTest {
}
@Test
void sumListElements() {
void testSumListElements() {
List<Double> weights = new ArrayList<>();
weights.add(0.365);
weights.add(0.658);
......@@ -39,7 +40,7 @@ class UtilsTest {
}
@Test
void normalizeWeights() {
void testNormalizeWeights() {
List<Double> weights = new ArrayList<>();
weights.add(0.365);
weights.add(0.658);
......@@ -74,19 +75,49 @@ class UtilsTest {
}
@Test
void findMaxDistance() {
void testFindMinDistance() {
List<AbstractSolution> population = new ArrayList<>();
Random rnd = new Random(5478);
List<List<Double>> data = Utils.convertJsonToDataForTrainer("./ressources/webshell_data.json");
List<Double> expected = Utils.convertJsonToExpectedForTrainer("./ressources/webshell_expected.json");
for (int i = 0; i < 50; i++) {
SolutionDistance solution = new SolutionDistance(5,rnd.nextInt());
solution.computeScoreTo(data, expected);
population.add(solution);
}
assertEquals(8.668597844797882, Utils.findMinDistance(population));
}
@Test
void findMinDistance() {
void testFindMaxDistance() {
List<AbstractSolution> population = new ArrayList<>();
Random rnd = new Random(5478);
List<List<Double>> data = Utils.convertJsonToDataForTrainer("./ressources/webshell_data.json");
List<Double> expected = Utils.convertJsonToExpectedForTrainer("./ressources/webshell_expected.json");
for (int i = 0; i < 50; i++) {
SolutionDistance solution = new SolutionDistance(5,rnd.nextInt());
solution.computeScoreTo(data, expected);
population.add(solution);
}
assertEquals(34.18904600152107, Utils.findMaxDistance(population));
}
@Test
void sumTotalDistance() {
void testSumTotalDistance() {
List<AbstractSolution> population = new ArrayList<>();
Random rnd = new Random(5478);
List<List<Double>> data = Utils.convertJsonToDataForTrainer("./ressources/webshell_data.json");
List<Double> expected = Utils.convertJsonToExpectedForTrainer("./ressources/webshell_expected.json");
for (int i = 0; i < 50; i++) {
SolutionDistance solution = new SolutionDistance(5,rnd.nextInt());
solution.computeScoreTo(data, expected);
population.add(solution);
}
assertEquals(781.5916287000892, Utils.sumTotalDistance(population));
}
@Test
void randomInteger() {
void testRandomInteger() {
int a = Utils.randomInteger(0, 500);
assertTrue(a > 0);
assertTrue(a < 500);
......@@ -98,18 +129,18 @@ class UtilsTest {
}
@Test
void computeWOWAScoreWithData() {
void testComputeWOWAScoreWithData() {
}
@Test
void convertExpectedToBooleanArrayTrueAlert() {
void testConvertExpectedToBooleanArrayTrueAlert() {
}
@Test
void convertListDoubleToArrayDouble() {
void testConvertListDoubleToArrayDouble() {
}
@Test
void initializeListWithZeroValues() {
void testInitializeListWithZeroValues() {
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment