source: josm/trunk/test/unit/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategyTest.groovy@ 9339

Last change on this file since 9339 was 9279, checked in by Don-vip, 8 years ago

fix groovy scripts broken by r9278

  • Property svn:eol-style set to native
File size: 2.1 KB
RevLine 
[3988]1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint
3
4import org.junit.*
[9279]5import org.openstreetmap.josm.JOSMFixture
6import org.openstreetmap.josm.data.osm.Node
7import org.openstreetmap.josm.gui.mappaint.styleelement.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy
8import org.openstreetmap.josm.gui.mappaint.styleelement.LabelCompositionStrategy.StaticLabelCompositionStrategy
9import org.openstreetmap.josm.gui.mappaint.styleelement.LabelCompositionStrategy.TagLookupCompositionStrategy
[3988]10
11class LabelCompositionStrategyTest {
[9279]12
[3988]13 @BeforeClass
14 public static void createJOSMFixture(){
15 JOSMFixture.createUnitTestFixture().init()
16 }
17
18 @Test
19 public void createStaticLabelCompositionStrategy() {
20 def n = new Node()
[9279]21
[3988]22 def strat = new StaticLabelCompositionStrategy(null)
23 assert strat.compose(n) == null
[9279]24
[3988]25 strat = new StaticLabelCompositionStrategy("a label")
[9279]26 assert strat.compose(n) == "a label"
[3988]27 }
[9279]28
[3988]29 @Test
30 public void createTagLookupCompositionStrategy() {
31 def n = new Node()
32 n.put("my-tag", "my-value")
[9279]33
[3988]34 def strat = new TagLookupCompositionStrategy(null)
35 assert strat.compose(n) == null
[9279]36
[3988]37 strat = new TagLookupCompositionStrategy("name")
38 assert strat.compose(n) == null
[9279]39
[3988]40 strat = new TagLookupCompositionStrategy("my-tag")
41 assert strat.compose(n) == "my-value"
42 }
[9279]43
[3988]44 @Test
45 public void createDeriveLabelFromNameTagsCompositionStrategy() {
[9279]46 def n
[3988]47 def strat
[9279]48
[3988]49 strat = new DeriveLabelFromNameTagsCompositionStrategy()
50 strat.setNameTags(null)
51 assert strat.getNameTags() == []
[9279]52
[3988]53 strat = new DeriveLabelFromNameTagsCompositionStrategy()
54 strat.setNameTags(["name", "brand"])
55 assert strat.getNameTags() == ["name", "brand"]
[9279]56
[3988]57 n = new Node()
[9279]58 n.put("brand", "my brand")
[3988]59 assert strat.compose(n) == "my brand"
[9279]60
[3988]61 n = new Node()
62 n.put("name", "my name")
63 n.put("brand", "my brand")
[9279]64 assert strat.compose(n) == "my name"
[3988]65 }
66}
67
Note: See TracBrowser for help on using the repository browser.