Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Classification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Matisse DEKEISER
Classification
Commits
61f09125
Commit
61f09125
authored
6 months ago
by
Maxence Antoine
Browse files
Options
Downloads
Patches
Plain Diff
ajout des tests pour ClassificationModel
parent
594b42d4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/fr/univlille/sae/classification/model/ClassificationModelTest.java
+61
-5
61 additions, 5 deletions
...lle/sae/classification/model/ClassificationModelTest.java
with
61 additions
and
5 deletions
src/test/java/fr/univlille/sae/classification/model/ClassificationModelTest.java
+
61
−
5
View file @
61f09125
package
fr.univlille.sae.classification.model
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.List
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
class
ClassificationModelTest
{
private
ClassificationModel
model
;
@BeforeEach
void
setUp
()
{
model
=
ClassificationModel
.
getClassificationModel
();
}
@Test
void
testSingletonInstance
()
{
ClassificationModel
anotherModel
=
ClassificationModel
.
getClassificationModel
();
assertSame
(
model
,
anotherModel
);
}
@Test
void
getClassificationModel
()
{
void
testAjouterDonnee
()
{
double
[]
coords
=
{
5.1
,
3.5
,
1.4
,
0.2
};
model
.
ajouterDonnee
(
coords
);
List
<
LoadableData
>
dataToClass
=
model
.
getDataToClass
();
assertEquals
(
1
,
dataToClass
.
size
());
assertNotNull
(
dataToClass
.
get
(
0
).
getClassification
());
}
@Test
void
getDatas
()
{
void
testAjouterDonneeInsuffisante
()
{
Exception
exception
=
assertThrows
(
IllegalArgumentException
.
class
,
()
->
{
model
.
ajouterDonnee
(
5.1
);
});
assertEquals
(
null
,
exception
.
getMessage
());
}
@Test
void
getDataToClass
()
{
void
testLoadData
()
throws
IOException
{
File
csvTemp
=
File
.
createTempFile
(
"test"
,
".csv"
);
String
csvTest
=
"sepal_length,sepal_width,petal_length,petal_width,class\n"
+
"5.1,3.5,1.4,0.2,Iris-setosa\n"
+
"4.9,3.0,1.4,0.2,Iris-setosa\n"
;
Files
.
write
(
Paths
.
get
(
csvTemp
.
getAbsolutePath
()),
csvTest
.
getBytes
());
model
.
loadData
(
csvTemp
);
List
<
LoadableData
>
datas
=
model
.
getDatas
();
assertEquals
(
2
,
datas
.
size
());
csvTemp
.
delete
();
}
@Test
void
testClassifierDonnees
()
{
double
[]
coords1
=
{
5.1
,
3.5
,
1.4
,
0.2
};
double
[]
coords2
=
{
4.9
,
3.0
,
1.4
,
0.2
};
model
.
ajouterDonnee
(
coords1
);
model
.
ajouterDonnee
(
coords2
);
model
.
classifierDonnees
();
assertEquals
(
0
,
model
.
getDataToClass
().
size
());
}
@Test
void
getType
()
{
void
testSetType
()
{
model
.
setType
(
DataType
.
IRIS
);
assertEquals
(
DataType
.
IRIS
,
model
.
getType
());
}
}
\ 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