Skip to content

Commit acdc9da

Browse files
committed
Finish Tests
Create all of the rest of the tests.
1 parent 331812e commit acdc9da

File tree

6 files changed

+166
-36
lines changed

6 files changed

+166
-36
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package net.quickwrite.fluent4j;
2+
3+
import net.quickwrite.fluent4j.builder.FluentArgsBuilder;
4+
import net.quickwrite.fluent4j.util.args.FluentArgs;
5+
import net.quickwrite.fluent4j.util.bundle.FluentBundle;
6+
import org.junit.Before;
7+
import org.junit.Test;
8+
import org.junit.jupiter.api.Assertions;
9+
10+
import java.io.IOException;
11+
12+
public class TestVariables {
13+
private FluentBundle bundle;
14+
private FluentArgs arguments;
15+
16+
@Before
17+
public void setUp() throws IOException {
18+
this.bundle = GetFileHelper.getFluentBundle("variables.ftl");
19+
this.arguments = new FluentArgsBuilder().set("var", "Value").build();
20+
}
21+
22+
@Test
23+
public void testIfExceptions() {
24+
Assertions.assertTrue(bundle.hasExceptions());
25+
}
26+
27+
@Test
28+
public void testKey01() {
29+
Assertions.assertEquals(
30+
"Value",
31+
bundle.getMessage("key01", arguments).orElseThrow()
32+
);
33+
}
34+
35+
@Test
36+
public void testKey02() {
37+
Assertions.assertEquals(
38+
"Value",
39+
bundle.getMessage("key02", arguments).orElseThrow()
40+
);
41+
}
42+
43+
@Test
44+
public void testKey03() {
45+
Assertions.assertEquals(
46+
"Value",
47+
bundle.getMessage("key03", arguments).orElseThrow()
48+
);
49+
}
50+
51+
@Test
52+
public void testKey04() {
53+
Assertions.assertEquals(
54+
"Value",
55+
bundle.getMessage("key04", arguments).orElseThrow()
56+
);
57+
}
58+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package net.quickwrite.fluent4j;
2+
3+
import net.quickwrite.fluent4j.util.bundle.FluentBundle;
4+
import org.junit.Before;
5+
import org.junit.Test;
6+
import org.junit.jupiter.api.Assertions;
7+
8+
import java.io.IOException;
9+
10+
public class TestVariantKeys {
11+
private FluentBundle bundle;
12+
13+
@Before
14+
public void setUp() throws IOException {
15+
this.bundle = GetFileHelper.getFluentBundle("variant_keys.ftl");
16+
}
17+
18+
@Test
19+
public void testIfExceptions() {
20+
Assertions.assertTrue(bundle.hasExceptions());
21+
}
22+
23+
@Test
24+
public void testSimpleIdentifier() {
25+
Assertions.assertEquals("Value", GetFileHelper.getMessage(bundle, "simple-identifier"));
26+
}
27+
28+
@Test
29+
public void testIdentifierSurroundedByWhitespace() {
30+
Assertions.assertEquals("Value", GetFileHelper.getMessage(bundle, "identifier-surrounded-by-whitespace"));
31+
}
32+
33+
@Test
34+
public void testIntNumberIdentifier() {
35+
Assertions.assertEquals("Value", GetFileHelper.getMessage(bundle, "int-number"));
36+
}
37+
38+
@Test
39+
public void testFloatNumberIdentifier() {
40+
Assertions.assertEquals("Value", GetFileHelper.getMessage(bundle, "float-number"));
41+
}
42+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package net.quickwrite.fluent4j;
2+
3+
import net.quickwrite.fluent4j.util.bundle.FluentBundle;
4+
import org.junit.Before;
5+
import org.junit.Test;
6+
import org.junit.jupiter.api.Assertions;
7+
8+
import java.io.IOException;
9+
10+
public class TestWhitespaceInValue {
11+
private FluentBundle bundle;
12+
13+
@Before
14+
public void setUp() throws IOException {
15+
this.bundle = GetFileHelper.getFluentBundle("whitespace_in_value.ftl");
16+
}
17+
18+
@Test
19+
public void testIfExceptions() {
20+
Assertions.assertFalse(bundle.hasExceptions());
21+
}
22+
23+
@Test
24+
public void testKey() {
25+
Assertions.assertEquals("""
26+
first line
27+
28+
29+
30+
31+
32+
33+
last line""",
34+
GetFileHelper.getMessage(bundle, "key")
35+
);
36+
}
37+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package net.quickwrite.fluent4j;
2+
3+
import net.quickwrite.fluent4j.util.bundle.FluentBundle;
4+
import org.junit.Before;
5+
import org.junit.Test;
6+
import org.junit.jupiter.api.Assertions;
7+
8+
import java.io.IOException;
9+
10+
public class TestZeroLength {
11+
private FluentBundle bundle;
12+
13+
@Before
14+
public void setUp() throws IOException {
15+
this.bundle = GetFileHelper.getFluentBundle("zero_length.ftl");
16+
}
17+
18+
@Test
19+
public void testIfExceptions() {
20+
Assertions.assertFalse(bundle.hasExceptions());
21+
}
22+
}

src/test/resources/input/terms.ftl

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
simple-identifier =
22
{ $sel ->
3-
*[key] value
3+
*[key] Value
44
}
55
66
identifier-surrounded-by-whitespace =
77
{ $sel ->
8-
*[ key ] value
8+
*[ key ] Value
99
}
1010
1111
int-number =
1212
{ $sel ->
13-
*[1] value
13+
*[1] Value
1414
}
1515
1616
float-number =
1717
{ $sel ->
18-
*[3.14] value
18+
*[3.14] Value
1919
}
2020
2121
# ERROR
2222
invalid-identifier =
2323
{ $sel ->
24-
*[two words] value
24+
*[two words] Value
2525
}
2626
2727
# ERROR
2828
invalid-int =
2929
{ $sel ->
30-
*[1 apple] value
30+
*[1 apple] Value
3131
}
3232
3333
# ERROR
3434
invalid-int =
3535
{ $sel ->
36-
*[3.14 apples] value
36+
*[3.14 apples] Value
3737
}

0 commit comments

Comments
 (0)