1+ package com .baeldung .defaultistaticinterfacemethods .test ;
2+
3+ import com .baeldung .defaultstaticinterfacemethods .model .Car ;
4+ import com .baeldung .defaultstaticinterfacemethods .model .Motorbike ;
5+ import com .baeldung .defaultstaticinterfacemethods .model .Vehicle ;
6+ import org .junit .BeforeClass ;
7+ import org .junit .Test ;
8+ import static org .assertj .core .api .Assertions .*;
9+
10+ public class StaticDefaulInterfaceMethodUnitTest {
11+
12+ private static Car car ;
13+ private static Motorbike motorbike ;
14+
15+ @ BeforeClass
16+ public static void setUpCarInstance () {
17+ car = new Car ("BMW" );
18+ }
19+
20+ @ BeforeClass
21+ public static void setUpMotorbikeInstance () {
22+ motorbike = new Motorbike ("Yamaha" );
23+ }
24+
25+ @ Test
26+ public void givenCarInstace_whenBrandisBMW_thenOneAssertion () {
27+ assertThat (car .getBrand ()).isEqualTo ("BMW" );
28+ }
29+
30+ @ Test
31+ public void givenCarInstance_whenCallingSpeedUp_thenOneAssertion () {
32+ assertThat (car .speedUp ()).isEqualTo ("The car is speeding up." );
33+ }
34+
35+ @ Test
36+ public void givenCarInstance_whenCallingSlowDown_thenOneAssertion () {
37+ assertThat (car .slowDown ()).isEqualTo ("The car is slowing down." );
38+ }
39+
40+ @ Test
41+ public void givenCarInstance_whenCallingTurnAlarmOn_thenOneAssertion () {
42+ assertThat (car .turnAlarmOn ()).isEqualTo ("Turning the vehice alarm on." );
43+ }
44+
45+ @ Test
46+ public void givenCarInstance_whenCallingTurnAlarmOff_thenOneAssertion () {
47+ assertThat (car .turnAlarmOff ()).isEqualTo ("Turning the vehicle alarm off." );
48+ }
49+
50+ @ Test
51+ public void givenVehicleInterface_whenCallinggetHorsePower_thenOneAssertion () {
52+ assertThat (Vehicle .getHorsePower (2500 , 480 )).isEqualTo (228 );
53+ }
54+
55+ @ Test
56+ public void givenMooorbikeInstace_whenBrandisYamaha_thenOneAssertion () {
57+ assertThat (motorbike .getBrand ()).isEqualTo ("Yamaha" );
58+ }
59+
60+ @ Test
61+ public void givenMotorbikeInstance_whenCallingSpeedUp_thenOneAssertion () {
62+ assertThat (motorbike .speedUp ()).isEqualTo ("The motorbike is speeding up." );
63+ }
64+
65+ @ Test
66+ public void givenMotorbikeInstance_whenCallingSlowDown_thenOneAssertion () {
67+ assertThat (motorbike .slowDown ()).isEqualTo ("The motorbike is slowing down." );
68+ }
69+
70+ @ Test
71+ public void givenMotorbikeInstance_whenCallingTurnAlarmOn_thenOneAssertion () {
72+ assertThat (motorbike .turnAlarmOn ()).isEqualTo ("Turning the vehice alarm on." );
73+ }
74+
75+ @ Test
76+ public void givenMotorbikeInstance_whenCallingTurnAlarmOff_thenOneAssertion () {
77+ assertThat (motorbike .turnAlarmOff ()).isEqualTo ("Turning the vehicle alarm off." );
78+ }
79+ }
0 commit comments