-
Notifications
You must be signed in to change notification settings - Fork 53.6k
Expand file tree
/
Copy pathSpelIntegrationTest.java
More file actions
104 lines (89 loc) · 4.47 KB
/
SpelIntegrationTest.java
File metadata and controls
104 lines (89 loc) · 4.47 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
package com.baeldung.spel;
import com.baeldung.spring.spel.examples.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class SpelIntegrationTest {
@Autowired
private SpelArithmetic spelArithmetic;
@Autowired
private SpelCollections spelCollections;
@Autowired
private SpelConditional spelConditional;
@Autowired
private SpelLogical spelLogical;
@Autowired
private SpelRegex spelRegex;
@Autowired
private SpelRelational spelRelational;
@Test
public void testArithmetic() throws Exception {
assertThat(spelArithmetic.getAdd(), equalTo(20.0));
assertThat(spelArithmetic.getAddString(), equalTo("Some string plus other string"));
assertThat(spelArithmetic.getSubtract(), equalTo(19.0));
assertThat(spelArithmetic.getMultiply(), equalTo(20.0));
assertThat(spelArithmetic.getDivide(), equalTo(18.0));
assertThat(spelArithmetic.getDivideAlphabetic(), equalTo(18.0));
assertThat(spelArithmetic.getModulo(), equalTo(7.0));
assertThat(spelArithmetic.getModuloAlphabetic(), equalTo(7.0));
assertThat(spelArithmetic.getPowerOf(), equalTo(512.0));
assertThat(spelArithmetic.getBrackets(), equalTo(17.0));
}
@Test
public void testCollections() throws Exception {
assertThat(spelCollections.getDriver1Car().getModel(), equalTo("Model1"));
assertThat(spelCollections.getDriver2Car().getModel(), equalTo("Model2"));
assertThat(spelCollections.getFirstCarInPark().getModel(), equalTo("Model1"));
assertThat(spelCollections.getNumberOfCarsInPark(), equalTo(2));
}
@Test
public void testConditional() throws Exception {
assertThat(spelConditional.getTernary(), equalTo("Something went wrong. There was false value"));
assertThat(spelConditional.getTernary2(), equalTo("Some model"));
assertThat(spelConditional.getElvis(), equalTo("Some model"));
}
@Test
public void testLogical() throws Exception {
assertThat(spelLogical.isAnd(), equalTo(true));
assertThat(spelLogical.isAndAlphabetic(), equalTo(true));
assertThat(spelLogical.isOr(), equalTo(true));
assertThat(spelLogical.isOrAlphabetic(), equalTo(true));
assertThat(spelLogical.isNot(), equalTo(false));
assertThat(spelLogical.isNotAlphabetic(), equalTo(false));
}
@Test
public void testRegex() throws Exception {
assertThat(spelRegex.isValidNumericStringResult(), equalTo(true));
assertThat(spelRegex.isInvalidNumericStringResult(), equalTo(false));
assertThat(spelRegex.isValidAlphabeticStringResult(), equalTo(true));
assertThat(spelRegex.isInvalidAlphabeticStringResult(), equalTo(false));
assertThat(spelRegex.isValidFormatOfHorsePower(), equalTo(true));
}
@Test
public void testRelational() throws Exception {
assertThat(spelRelational.isEqual(), equalTo(true));
assertThat(spelRelational.isEqualAlphabetic(), equalTo(true));
assertThat(spelRelational.isNotEqual(), equalTo(false));
assertThat(spelRelational.isNotEqualAlphabetic(), equalTo(false));
assertThat(spelRelational.isLessThan(), equalTo(false));
assertThat(spelRelational.isLessThanAlphabetic(), equalTo(false));
assertThat(spelRelational.isLessThanOrEqual(), equalTo(true));
assertThat(spelRelational.isLessThanOrEqualAlphabetic(), equalTo(true));
assertThat(spelRelational.isGreaterThan(), equalTo(false));
assertThat(spelRelational.isGreaterThanAlphabetic(), equalTo(false));
assertThat(spelRelational.isGreaterThanOrEqual(), equalTo(true));
assertThat(spelRelational.isGreaterThanOrEqualAlphabetic(), equalTo(true));
assertThat(spelRelational.isAnd(), equalTo(true));
assertThat(spelRelational.isAndAlphabetic(), equalTo(true));
assertThat(spelRelational.isOr(), equalTo(true));
assertThat(spelRelational.isOrAlphabetic(), equalTo(true));
assertThat(spelRelational.isNot(), equalTo(false));
assertThat(spelRelational.isNotAlphabetic(), equalTo(false));
}
}