package no.ssb.vtl.model;

/*-
 * ========================LICENSE_START=================================
 * Java VTL
 * %%
 * Copyright (C) 2016 - 2017 Hadrien Kohl
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =========================LICENSE_END==================================
 */

import org.junit.Test;

import java.util.LinkedHashMap;
import java.util.Map;

import static org.assertj.core.api.Assertions.*;


public class DataStructureTest {

    @Test
    public void testWrapWithMap() throws Exception {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("region", "0101");
        map.put("number", "1.0");
        map.put("period", "2015");

        DataStructure structure = DataStructure.of(
                "number", Component.Role.MEASURE, Double.class,
                "period", Component.Role.IDENTIFIER, String.class,
                "region", Component.Role.IDENTIFIER, String.class
        );

        DataPoint wrapped = structure.wrap(map);

        assertThat(wrapped).hasSize(3);
        assertThat(wrapped)
                .extracting(VTLObject::get)
                .containsExactly(
                        "1.0", "2015", "0101"
                );
    }

}

@@ -344,17 +344,16 @@
 se at%0A *
- 
 %0A *     
@@ -398,17 +398,16 @@
 E-2.0%0A *
- 
 %0A * Unle
@@ -878,16 +878,129 @@
 l.Map;%0A%0A
+import static no.ssb.vtl.model.Component.Role.IDENTIFIER;%0Aimport static no.ssb.vtl.model.Component.Role.MEASURE;%0A
 import s
@@ -1041,11 +1041,19 @@
 ons.
-*;%0A
+assertThat;
 %0A%0Apu
@@ -1118,38 +1118,1622 @@
 test
-WrapWithMap() throws Exception
+Builder() %7B%0A        DataStructure structure = DataStructure.of(%0A                %221%22, IDENTIFIER, String.class,%0A                %222%22, IDENTIFIER, String.class,%0A                %223%22, IDENTIFIER, String.class,%0A                %224%22, IDENTIFIER, String.class,%0A                %225%22, IDENTIFIER, String.class,%0A                %226%22, IDENTIFIER, String.class%0A        );%0A        assertThat(structure).isNotNull();%0A%0A        structure = DataStructure.of(%0A                %221%22, IDENTIFIER, String.class,%0A                %222%22, IDENTIFIER, String.class,%0A                %223%22, IDENTIFIER, String.class,%0A                %224%22, IDENTIFIER, String.class,%0A                %225%22, IDENTIFIER, String.class%0A        );%0A        assertThat(structure).isNotNull();%0A%0A        structure = DataStructure.of(%0A                %221%22, IDENTIFIER, String.class,%0A                %222%22, IDENTIFIER, String.class,%0A                %223%22, IDENTIFIER, String.class,%0A                %224%22, IDENTIFIER, String.class%0A        );%0A        assertThat(structure).isNotNull();%0A%0A        structure = DataStructure.of(%0A                %221%22, IDENTIFIER, String.class,%0A                %222%22, IDENTIFIER, String.class,%0A                %223%22, IDENTIFIER, String.class%0A        );%0A        assertThat(structure).isNotNull();%0A%0A        structure = DataStructure.of(%0A                %221%22, IDENTIFIER, String.class,%0A                %222%22, IDENTIFIER, String.class%0A        );%0A        assertThat(structure).isNotNull();%0A%0A        structure = DataStructure.of(%0A                %221%22, IDENTIFIER, String.class%0A        );%0A        assertThat(structure).isNotNull();%0A    %7D%0A%0A    @Test%0A    public void testWrapWithMap()
  %7B%0A 
@@ -2971,31 +2971,16 @@
 umber%22, 
-Component.Role.
 MEASURE,
@@ -3020,31 +3020,16 @@
 eriod%22, 
-Component.Role.
 IDENTIFI
@@ -3072,31 +3072,16 @@
 egion%22, 
-Component.Role.
 IDENTIFI

Fix DataStructure coverage