1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertTrue;
|
---|
6 |
|
---|
7 | import org.junit.BeforeClass;
|
---|
8 | import org.junit.Test;
|
---|
9 | import org.openstreetmap.josm.JOSMFixture;
|
---|
10 |
|
---|
11 | public class OsmUtilsTest {
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * Setup test.
|
---|
15 | */
|
---|
16 | @BeforeClass
|
---|
17 | public static void setUp() {
|
---|
18 | JOSMFixture.createUnitTestFixture().init();
|
---|
19 | }
|
---|
20 |
|
---|
21 | @Test
|
---|
22 | public void testCreatePrimitive() throws Exception {
|
---|
23 | final OsmPrimitive p = OsmUtils.createPrimitive("way name=Foo railway=rail");
|
---|
24 | assertTrue(p instanceof Way);
|
---|
25 | assertEquals(2, p.keySet().size());
|
---|
26 | assertEquals("Foo", p.get("name"));
|
---|
27 | assertEquals("rail", p.get("railway"));
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Test
|
---|
31 | public void testArea() throws Exception {
|
---|
32 | final OsmPrimitive p = OsmUtils.createPrimitive("area name=Foo railway=rail");
|
---|
33 | assertEquals(OsmPrimitiveType.WAY, p.getType());
|
---|
34 | assertTrue(p.getKeys().equals(OsmUtils.createPrimitive("way name=Foo railway=rail").getKeys()));
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Test(expected = IllegalArgumentException.class)
|
---|
38 | public void testCreatePrimitiveFail() throws Exception {
|
---|
39 | OsmUtils.createPrimitive("noway name=Foo");
|
---|
40 | }
|
---|
41 | }
|
---|