Skip to content

Commit 06bdb1e

Browse files
committed
Unit test for StringTemplateListener
1 parent 36e2af8 commit 06bdb1e

File tree

3 files changed

+71
-2
lines changed

3 files changed

+71
-2
lines changed

query-engine/docs/query-engine-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ services:
5959
- 14268:14268
6060

6161
query-engine:
62-
image: ghcr.io/yaytay/query-engine-design-mode:0.0.43-4-main
62+
image: ghcr.io/yaytay/query-engine-design-mode:0.0.43-5-main
6363
ports:
6464
- 2000:8080
6565
volumes:

query-engine/src/main/java/uk/co/spudsoft/query/main/Version.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public final class Version {
3434
/**
3535
* The project version, as set in the Maven pom.xml.
3636
*/
37-
public static final String MAVEN_PROJECT_VERSION = "0.0.43-4-main";
37+
public static final String MAVEN_PROJECT_VERSION = "0.0.43-5-main";
3838

3939
private Version() {
4040
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (C) 2024 njt
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package uk.co.spudsoft.query.exec;
18+
19+
import static org.hamcrest.MatcherAssert.assertThat;
20+
import static org.hamcrest.Matchers.startsWith;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import org.junit.jupiter.api.Test;
23+
import org.stringtemplate.v4.misc.ErrorType;
24+
import org.stringtemplate.v4.misc.STMessage;
25+
26+
27+
/**
28+
*
29+
* @author njt
30+
*/
31+
public class StringTemplateListenerTest {
32+
33+
@Test
34+
public void testCompileError() {
35+
StringTemplateListener listener = new StringTemplateListener();
36+
listener.compileTimeError(new STMessage(ErrorType.NO_SUCH_OPTION, null, new IllegalArgumentException("test")));
37+
assertEquals(1, listener.getErrors().size());
38+
assertEquals(StringTemplateListener.ErrorType.compile, listener.getErrors().get(0).type);
39+
assertThat(listener.getErrors().get(0).message, startsWith("no such option: null"));
40+
}
41+
42+
@Test
43+
public void testInternalError() {
44+
StringTemplateListener listener = new StringTemplateListener();
45+
listener.internalError(new STMessage(ErrorType.NO_SUCH_OPTION, null, new IllegalArgumentException("test")));
46+
assertEquals(1, listener.getErrors().size());
47+
assertEquals(StringTemplateListener.ErrorType.internal, listener.getErrors().get(0).type);
48+
assertThat(listener.getErrors().get(0).message, startsWith("no such option: null"));
49+
}
50+
51+
@Test
52+
public void testIoError() {
53+
StringTemplateListener listener = new StringTemplateListener();
54+
listener.IOError(new STMessage(ErrorType.NO_SUCH_OPTION, null, new IllegalArgumentException("test")));
55+
assertEquals(1, listener.getErrors().size());
56+
assertEquals(StringTemplateListener.ErrorType.io, listener.getErrors().get(0).type);
57+
assertThat(listener.getErrors().get(0).message, startsWith("no such option: null"));
58+
}
59+
60+
@Test
61+
public void testRunTimeError() {
62+
StringTemplateListener listener = new StringTemplateListener();
63+
listener.runTimeError(new STMessage(ErrorType.NO_SUCH_OPTION, null, new IllegalArgumentException("test")));
64+
assertEquals(1, listener.getErrors().size());
65+
assertEquals(StringTemplateListener.ErrorType.runTime, listener.getErrors().get(0).type);
66+
assertThat(listener.getErrors().get(0).message, startsWith("no such option: null"));
67+
}
68+
69+
}

0 commit comments

Comments
 (0)