Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Projet GORDYJAN_BAGNOLY_GARCIA_POIGNONNEC
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POIGNONNEC
Projet GORDYJAN_BAGNOLY_GARCIA_POIGNONNEC
Commits
c27312fe
Commit
c27312fe
authored
May 17, 2019
by
Arthur POIGNONNEC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TEST] Ajout de tests sur le banc d'essai
parent
58553969
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
83 additions
and
14 deletions
+83
-14
Task.java
garage/src/garage/Task.java
+10
-3
TestBench.java
garage/src/garage/TestBench.java
+14
-10
Vehicle.java
garage/src/vehicle/Vehicle.java
+1
-0
VehicleModel.java
garage/src/vehicle/VehicleModel.java
+1
-1
GearBox.java
garage/src/vehicle/part/gearbox/GearBox.java
+2
-0
GearBoxAutomatic.java
garage/src/vehicle/part/gearbox/GearBoxAutomatic.java
+5
-0
GearBoxManual.java
garage/src/vehicle/part/gearbox/GearBoxManual.java
+5
-0
PedalPosition.java
garage/src/vehicle/part/pedal/PedalPosition.java
+28
-0
TestBenchTest.java
garage/test/TestBenchTest.java
+17
-0
No files found.
garage/src/garage/Task.java
View file @
c27312fe
...
...
@@ -19,11 +19,18 @@ public class Task {
//METHODS
public
void
execute
()
throws
ExecutionFailedException
{
Class
[]
mArgs
=
new
Class
[
args
.
size
()];
for
(
Integer
i
=
0
;
i
<
args
.
size
();
i
++)
mArgs
[
i
]
=
args
.
get
(
i
).
getClass
();
Class
[]
mArgs
=
new
Class
[
0
];
if
(
args
!=
null
){
mArgs
=
new
Class
[
args
.
size
()];
for
(
Integer
i
=
0
;
i
<
args
.
size
();
i
++)
mArgs
[
i
]
=
args
.
get
(
i
).
getClass
();
}
try
{
System
.
out
.
println
(
"Calling method "
+
method
+
" of class -> "
+
obj
.
getClass
());
Method
m
=
obj
.
getClass
().
getMethod
(
method
,
mArgs
);
m
.
invoke
(
obj
,
args
.
toArray
());
if
(
args
==
null
)
m
.
invoke
(
obj
,
null
);
else
m
.
invoke
(
obj
,
args
.
toArray
());
}
catch
(
Exception
e
){
throw
new
ExecutionFailedException
(
e
.
getMessage
());
}
...
...
garage/src/garage/TestBench.java
View file @
c27312fe
...
...
@@ -61,16 +61,20 @@ public class TestBench {
}
public
void
run
(
Integer
time
)
{
for
(
Integer
t
=
0
;
t
<
time
;
t
++)
{
final
Integer
tick
=
t
;
tasks
.
stream
().
filter
(
task
->
tick
.
equals
(
task
.
getT
())).
forEach
(
task
->
{
try
{
task
.
execute
();
vehicle
.
update
();
}
catch
(
ExecutionFailedException
e
)
{
System
.
out
.
println
(
"ERROR -> "
+
e
.
getMessage
());
}
});
if
(
vehicle
!=
null
)
{
for
(
Integer
t
=
0
;
t
<
time
;
t
++)
{
final
Integer
tick
=
t
;
tasks
.
stream
().
filter
(
task
->
tick
.
equals
(
task
.
getT
())).
forEach
(
task
->
{
try
{
task
.
execute
();
vehicle
.
update
();
}
catch
(
ExecutionFailedException
e
)
{
System
.
out
.
println
(
"ERROR -> "
+
e
.
getMessage
());
}
});
}
}
else
{
System
.
out
.
println
(
"Aucune véhicule sur le banc d'essai"
);
}
}
}
garage/src/vehicle/Vehicle.java
View file @
c27312fe
...
...
@@ -74,6 +74,7 @@ public class Vehicle {
// METHODS /////////////////////////////////////////////////////////////////////////////////////////////////////////
public
void
update
(){
for
(
Pedal
p
:
pedals
)
p
.
update
();
}
...
...
garage/src/vehicle/VehicleModel.java
View file @
c27312fe
...
...
@@ -6,7 +6,7 @@ import vehicle.part.frame.FrameType;
public
enum
VehicleModel
{
FIAT_500
(
VehicleBrand
.
FIAT
,
"500"
,
EngineModel
.
TDI_
A
_D
,
FrameType
.
MICRO
,
BrakeType
.
PAD_FX200
,
4
),
FIAT_500
(
VehicleBrand
.
FIAT
,
"500"
,
EngineModel
.
TDI_
M
_D
,
FrameType
.
MICRO
,
BrakeType
.
PAD_FX200
,
4
),
PEUGEOT_5008
(
VehicleBrand
.
PEUGEOT
,
"5008"
,
EngineModel
.
TDI_A_P
,
FrameType
.
SUV
,
BrakeType
.
DISC_FX200
,
4
);
private
final
VehicleBrand
brand
;
...
...
garage/src/vehicle/part/gearbox/GearBox.java
View file @
c27312fe
...
...
@@ -12,4 +12,6 @@ public interface GearBox {
void
reverse
()
throws
StallException
,
EngineBrokenException
;
public
Gear
getCurrentGear
();
}
\ No newline at end of file
garage/src/vehicle/part/gearbox/GearBoxAutomatic.java
View file @
c27312fe
...
...
@@ -43,4 +43,9 @@ public class GearBoxAutomatic implements GearBox {
currentGear
=
Gear
.
REVERSE
;
}
}
@Override
public
Gear
getCurrentGear
()
{
return
currentGear
;
}
}
garage/src/vehicle/part/gearbox/GearBoxManual.java
View file @
c27312fe
...
...
@@ -95,4 +95,9 @@ public class GearBoxManual implements GearBox{
public
void
disengage
(){
engaged
=
false
;
}
@Override
public
Gear
getCurrentGear
()
{
return
currentGear
;
}
}
garage/src/vehicle/part/pedal/PedalPosition.java
0 → 100644
View file @
c27312fe
package
vehicle
.
part
.
pedal
;
public
enum
PedalPosition
{
ACCELERATOR
(
0
),
BRAKE
(
1
),
CLUTCH
(
2
);
private
final
Integer
value
;
PedalPosition
(
Integer
value
)
{
this
.
value
=
value
;
}
public
Integer
getValue
()
{
return
value
;
}
public
static
PedalPosition
getEnum
(
Integer
value
)
{
for
(
PedalPosition
position
:
PedalPosition
.
values
())
{
if
(
position
.
getValue
().
equals
(
value
))
{
return
position
;
}
}
return
null
;
}
}
garage/test/TestBenchTest.java
View file @
c27312fe
...
...
@@ -2,10 +2,13 @@ import garage.ExecutionFailedException;
import
garage.Task
;
import
garage.TestBench
;
import
org.junit.Before
;
import
org.junit.FixMethodOrder
;
import
org.junit.Test
;
import
vehicle.Vehicle
;
import
vehicle.VehicleModel
;
import
vehicle.part.gearbox.Gear
;
import
vehicle.part.pedal.PedalAccelerator
;
import
vehicle.part.pedal.PedalPosition
;
import
java.util.Arrays
;
...
...
@@ -107,4 +110,18 @@ public class TestBenchTest {
testBench
.
run
(
10
);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test
public
void
scenario1Test
(){
testBench
.
addVehicle
(
fiat500
);
testBench
.
addTask
(
new
Task
(
fiat500
.
getPedals
().
get
(
PedalPosition
.
CLUTCH
.
getValue
()),
"setState"
,
Arrays
.
asList
(
70
d
),
2
));
testBench
.
addTask
(
new
Task
(
fiat500
.
getGearBox
(),
"gearUp"
,
null
,
3
));
testBench
.
addTask
(
new
Task
(
fiat500
.
getPedals
().
get
(
PedalPosition
.
CLUTCH
.
getValue
()),
"setState"
,
Arrays
.
asList
(
0
d
),
4
));
assertEquals
(
Gear
.
NEUTRAL
,
fiat500
.
getGearBox
().
getCurrentGear
());
testBench
.
run
(
10
);
assertEquals
(
Gear
.
FIRST
,
fiat500
.
getGearBox
().
getCurrentGear
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment