View Javadoc

1   /**
2    * Copyright (c) 2008-2012, http://www.snakeyaml.org
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.yaml.snakeyaml.types;
17  
18  import java.util.List;
19  import java.util.Map;
20  
21  import org.yaml.snakeyaml.YamlDocument;
22  
23  /**
24   * @see http://yaml.org/type/pairs.html
25   */
26  public class PairsTagTest extends AbstractTest {
27  
28      @SuppressWarnings("unchecked")
29      public void testPairs() {
30          YamlDocument document = new YamlDocument("types/pairs.yaml", false);
31          Map<String, List<String[]>> map = (Map<String, List<String[]>>) document.getNativeData();
32          assertEquals(2, map.size());
33          List<String[]> list1 = (List<String[]>) map.get("Block tasks");
34          assertEquals(4, list1.size());
35          Object[] tuple1 = list1.get(0);
36          assertEquals(2, tuple1.length);
37          assertEquals("meeting", tuple1[0]);
38          assertEquals("with team.", tuple1[1]);
39          //
40  
41          Object[] tuple2 = list1.get(1);
42          assertEquals(2, tuple2.length);
43          assertEquals("meeting", tuple2[0]);
44          assertEquals("with boss.", tuple2[1]);
45          //
46  
47          Object[] tuple3 = list1.get(2);
48          assertEquals(2, tuple3.length);
49          assertEquals("break", tuple3[0]);
50          assertEquals("lunch.", tuple3[1]);
51          //
52  
53          Object[] tuple4 = list1.get(3);
54          assertEquals(2, tuple4.length);
55          assertEquals("meeting", tuple4[0]);
56          assertEquals("with client.", tuple4[1]);
57          //
58          List<String[]> list2 = (List<String[]>) map.get("Flow tasks");
59          assertEquals(2, list2.size());
60          Object[] tuple2_1 = list2.get(0);
61          assertEquals(2, tuple2_1.length);
62          assertEquals("meeting", tuple2_1[0]);
63          assertEquals("with team", tuple2_1[1]);
64          //
65          Object[] tuple2_2 = list2.get(1);
66          assertEquals(2, tuple2_2.length);
67          assertEquals("meeting", tuple2_2[0]);
68          assertEquals("with boss", tuple2_2[1]);
69      }
70  }