1
|
/**
|
2
|
* Copyright (C) 2021 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.strategy.cache;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.List;
|
13
|
|
14
|
import org.junit.Assert;
|
15
|
import org.junit.Before;
|
16
|
import org.junit.Test;
|
17
|
|
18
|
/**
|
19
|
* @author a.mueller
|
20
|
* @since 23.02.2021
|
21
|
*/
|
22
|
public class TaggedCacheHelperTest {
|
23
|
|
24
|
private List<TaggedText> tags;
|
25
|
|
26
|
@Before
|
27
|
public void setUp() throws Exception {
|
28
|
tags = new ArrayList<>();
|
29
|
tags.add(TaggedText.NewInstance(TagEnum.label, "My"));
|
30
|
tags.add(TaggedText.NewInstance(TagEnum.label, "taxon"));
|
31
|
}
|
32
|
|
33
|
@Test
|
34
|
public void test() {
|
35
|
Assert.assertEquals("My taxon", TaggedCacheHelper.createString(tags));
|
36
|
|
37
|
tags.add(1, TaggedText.NewInstance(TagEnum.separator, ":"));
|
38
|
Assert.assertEquals("My:taxon", TaggedCacheHelper.createString(tags));
|
39
|
}
|
40
|
|
41
|
@Test
|
42
|
public void testHtmlRules() {
|
43
|
HTMLTagRules rules = new HTMLTagRules();
|
44
|
rules.addRule(TagEnum.label, "b");
|
45
|
Assert.assertEquals("<b>My taxon</b>", TaggedCacheHelper.createString(tags, rules));
|
46
|
|
47
|
tags.add(1, TaggedText.NewInstance(TagEnum.separator, ":"));
|
48
|
Assert.assertEquals("<b>My</b>:<b>taxon</b>", TaggedCacheHelper.createString(tags, rules));
|
49
|
}
|
50
|
|
51
|
}
|