Repository navigation
Expand file tree
/
Copy pathTests.java
More file actions
152 lines (105 loc) · 4.36 KB
/
Copy pathTests.java
File metadata and controls
152 lines (105 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import static org.junit.Assert.*;
import org.junit.Assert;
import org.junit.Test;
import Entry.OsagoCalculatorService;
import Enums.BonusMalusEnum;
import Enums.EnginePowerEnum;
import Enums.InsurancePeriodEnum;
import Enums.PersonsAllowedToDriveEnum;
import Enums.VehicleOwnerTypeEnum;
import Enums.VehicleRegistrationCountryEnum;
import Enums.VehicleTypeEnum;
import Models.DriverDescription;
import Models.OwnerDescription;
import Models.VehicleDescription;
import Shared.ValueDescription;
public class Tests {
@Test
public void CalcResultForBashkortostanForMotorBike() throws Exception {
OsagoCalculatorService osagoCalculatorService = new OsagoCalculatorService();
VehicleDescription vehicle = new VehicleDescription();
OwnerDescription owner = new OwnerDescription();
vehicle.EnginePower = EnginePowerEnum.From71To100;
vehicle.VehicleRegistrationCountry = VehicleRegistrationCountryEnum.Russia;
vehicle.VehicleType = VehicleTypeEnum.MotorcyclesAndScooters;
owner.AreaId = 1;
owner.RegionId = 1;
owner.BonusMalusRate = BonusMalusEnum._1;
owner.DriverDescription = new DriverDescription(22, 3);
owner.InsurancePeriod = InsurancePeriodEnum._9Month;
owner.PersonsAllowedToDrive = PersonsAllowedToDriveEnum.AnyDrivers;
owner.VehicleOwnerType = VehicleOwnerTypeEnum.Individual;
float result = osagoCalculatorService.Calc(vehicle, owner);
boolean hasError = false;
if (Math.round(result) != 3643) {
hasError = true;
}
Assert.assertEquals(hasError, false);
}
@Test
public void CalcResultForBashkortostanForMotorBikeAndCompareWithTinkoff() throws Exception {
OsagoCalculatorService osagoCalculatorService = new OsagoCalculatorService();
VehicleDescription vehicle = new VehicleDescription();
OwnerDescription owner = new OwnerDescription();
vehicle.EnginePower = EnginePowerEnum.From71To100;
vehicle.VehicleRegistrationCountry = VehicleRegistrationCountryEnum.Russia;
vehicle.VehicleType = VehicleTypeEnum.Cars;
owner.AreaId = 1;
owner.RegionId = 1;
owner.BonusMalusRate = BonusMalusEnum._1;
owner.DriverDescription = new DriverDescription(22, 3);
owner.InsurancePeriod = InsurancePeriodEnum._9Month;
owner.PersonsAllowedToDrive = PersonsAllowedToDriveEnum.AnyDrivers;
owner.VehicleOwnerType = VehicleOwnerTypeEnum.Individual;
float result = osagoCalculatorService.Calc(vehicle, owner);
boolean hasError = false;
if (result < 10000 || result > 16000) {
hasError = true;
}
Assert.assertEquals(hasError, false);
}
@Test
public void CheckBehaviourInOutOFRangeCoef() throws Exception {
OsagoCalculatorService osagoCalculatorService = new OsagoCalculatorService();
VehicleDescription vehicle = new VehicleDescription();
OwnerDescription owner = new OwnerDescription();
vehicle.EnginePower = EnginePowerEnum.From71To100;
vehicle.VehicleRegistrationCountry = VehicleRegistrationCountryEnum.Russia;
vehicle.VehicleType = VehicleTypeEnum.Cars;
owner.AreaId = 1;
owner.RegionId = 1;
owner.BonusMalusRate = BonusMalusEnum._1;
owner.DriverDescription = new DriverDescription(25, 19);
owner.InsurancePeriod = InsurancePeriodEnum._9Month;
owner.PersonsAllowedToDrive = PersonsAllowedToDriveEnum.AnyDrivers;
owner.VehicleOwnerType = VehicleOwnerTypeEnum.Individual;
float result = osagoCalculatorService.Calc(vehicle, owner);
boolean hasError = false;
if (Math.round(result) != 11122) {
hasError = true;
}
Assert.assertEquals(hasError, false);
}
@Test
public void CalcResultForBashkortostanForCar() throws Exception {
OsagoCalculatorService osagoCalculatorService = new OsagoCalculatorService();
VehicleDescription vehicle = new VehicleDescription();
OwnerDescription owner = new OwnerDescription();
vehicle.EnginePower = EnginePowerEnum.From71To100;
vehicle.VehicleRegistrationCountry = VehicleRegistrationCountryEnum.Russia;
vehicle.VehicleType = VehicleTypeEnum.Cars;
owner.AreaId = 1;
owner.RegionId = 1;
owner.BonusMalusRate = BonusMalusEnum._1;
owner.DriverDescription = new DriverDescription(20, 3);
owner.InsurancePeriod = InsurancePeriodEnum._9Month;
owner.PersonsAllowedToDrive = PersonsAllowedToDriveEnum.AnyDrivers;
owner.VehicleOwnerType = VehicleOwnerTypeEnum.Individual;
float result = osagoCalculatorService.Calc(vehicle, owner);
boolean hasError = false;
if (Math.round(result) == 5937) {
hasError = true;
}
Assert.assertEquals(hasError, false);
}
}