View Javadoc

1   /**
2    * Copyright (c) 2008-2011, 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  
17  package org.yaml.snakeyaml.types;
18  
19  import java.io.IOException;
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.yaml.snakeyaml.YamlDocument;
24  
25  /**
26   * @see http://yaml.org/type/pairs.html
27   */
28  public class PairsTagTest extends AbstractTest {
29  
30      @SuppressWarnings("unchecked")
31      public void testPairs() throws IOException {
32          YamlDocument document = new YamlDocument("types/pairs.yaml", false);
33          Map<String, List<String[]>> map = (Map<String, List<String[]>>) document.getNativeData();
34          assertEquals(2, map.size());
35          List<String[]> list1 = (List<String[]>) map.get("Block tasks");
36          assertEquals(4, list1.size());
37          Object[] tuple1 = list1.get(0);
38          assertEquals(2, tuple1.length);
39          assertEquals("meeting", tuple1[0]);
40          assertEquals("with team.", tuple1[1]);
41          //
42  
43          Object[] tuple2 = list1.get(1);
44          assertEquals(2, tuple2.length);
45          assertEquals("meeting", tuple2[0]);
46          assertEquals("with boss.", tuple2[1]);
47          //
48  
49          Object[] tuple3 = list1.get(2);
50          assertEquals(2, tuple3.length);
51          assertEquals("break", tuple3[0]);
52          assertEquals("lunch.", tuple3[1]);
53          //
54  
55          Object[] tuple4 = list1.get(3);
56          assertEquals(2, tuple4.length);
57          assertEquals("meeting", tuple4[0]);
58          assertEquals("with client.", tuple4[1]);
59          //
60          List<String[]> list2 = (List<String[]>) map.get("Flow tasks");
61          assertEquals(2, list2.size());
62          Object[] tuple2_1 = list2.get(0);
63          assertEquals(2, tuple2_1.length);
64          assertEquals("meeting", tuple2_1[0]);
65          assertEquals("with team", tuple2_1[1]);
66          //
67          Object[] tuple2_2 = list2.get(1);
68          assertEquals(2, tuple2_2.length);
69          assertEquals("meeting", tuple2_2[0]);
70          assertEquals("with boss", tuple2_2[1]);
71      }
72  }