Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
java-wowa-training
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cylab
java-wowa-training
Commits
b9ca8352
Commit
b9ca8352
authored
5 years ago
by
a.croix
Browse files
Options
Downloads
Patches
Plain Diff
Improve tests
parent
2a662eac
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#2090
passed
5 years ago
Stage: leaks
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/be/cylab/java/wowa/training/Factory.java
+1
-1
1 addition, 1 deletion
src/main/java/be/cylab/java/wowa/training/Factory.java
src/test/java/be/cylab/java/wowa/training/UtilsTest.java
+41
-10
41 additions, 10 deletions
src/test/java/be/cylab/java/wowa/training/UtilsTest.java
with
42 additions
and
11 deletions
src/main/java/be/cylab/java/wowa/training/Factory.java
+
1
−
1
View file @
b9ca8352
...
...
@@ -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"
);
}
}
}
This diff is collapsed.
Click to expand it.
src/test/java/be/cylab/java/wowa/training/UtilsTest.java
+
41
−
10
View file @
b9ca8352
...
...
@@ -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
s
umListElements
()
{
void
testS
umListElements
()
{
List
<
Double
>
weights
=
new
ArrayList
<>();
weights
.
add
(
0.365
);
weights
.
add
(
0.658
);
...
...
@@ -39,7 +40,7 @@ class UtilsTest {
}
@Test
void
n
ormalizeWeights
()
{
void
testN
ormalizeWeights
()
{
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
r
andomInteger
()
{
void
testR
andomInteger
()
{
int
a
=
Utils
.
randomInteger
(
0
,
500
);
assertTrue
(
a
>
0
);
assertTrue
(
a
<
500
);
...
...
@@ -98,18 +129,18 @@ class UtilsTest {
}
@Test
void
c
omputeWOWAScoreWithData
()
{
void
testC
omputeWOWAScoreWithData
()
{
}
@Test
void
c
onvertExpectedToBooleanArrayTrueAlert
()
{
void
testC
onvertExpectedToBooleanArrayTrueAlert
()
{
}
@Test
void
c
onvertListDoubleToArrayDouble
()
{
void
testC
onvertListDoubleToArrayDouble
()
{
}
@Test
void
i
nitializeListWithZeroValues
()
{
void
testI
nitializeListWithZeroValues
()
{
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment