ProblemTest.java revision de164daf91fc8fb4dd62aa1470bcf1a6d431258f
1package com.github.javaparser;
2
3import org.junit.Test;
4
5import static com.github.javaparser.Range.range;
6import static com.github.javaparser.utils.TestUtils.assertInstanceOf;
7import static org.junit.Assert.assertEquals;
8
9public class ProblemTest {
10    @Test
11    public void testSimpleGetters() {
12        Problem problem = new Problem("Parse error", range(10, 10, 20, 20), new Exception());
13
14        assertEquals(range(10, 10, 20, 20), problem.getLocation().get());
15        assertEquals("Parse error", problem.getMessage());
16        assertInstanceOf(Exception.class, problem.getCause().get());
17    }
18
19    @Test
20    public void testVerboseMessage() {
21        Problem problem = new Problem("Parse error", range(10, 10, 20, 20), null);
22
23        assertEquals("(line 10,col 10) Parse error", problem.getVerboseMessage());
24    }
25
26    @Test
27    public void testVerboseMessageWithoutLocation() {
28        Problem problem = new Problem("Parse error", null, null);
29
30        assertEquals("Parse error", problem.getVerboseMessage());
31    }
32}