// Path: ngsi2-client/src/test/java/com/orange/ngsi2/Utils.java
// public class Utils {
// 
//     /**
//      * Common object mapper used for most tests with Java 8 support for Optional
//      */
//     public final static ObjectMapper objectMapper = new ObjectMapper().registerModule(new Jdk8Module())
//             .registerModule(new JavaTimeModule())
//             .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
// 
//     /**
//      * Load a resource as an UTF-8 string
//      * @param name name of the resource
//      * @return the content of the resource
//      */
//     public static String loadResource(String name) {
//         try {
//             URL url = Utils.class.getClassLoader().getResource(name);
//             if (url == null) {
//                 return "";
//             }
//             return new String(Files.readAllBytes(Paths.get(url.toURI())), "UTF-8");
//         } catch (Exception e) {
//             return "";
//         }
//     }
// 
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.orange.ngsi2.Utils;
import org.junit.Test;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.Optional;
/*
 * Copyright (C) 2016 Orange
 *
 * 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.
 *
 */

package com.orange.ngsi2.model;




/**
 * Tests for the Registration
 */
public class RegistrationTest {

    String jsonString = "{\n" +
            "    \"id\": \"abcdefg\",\n" +
            "    \"subject\": {\n" +
            "      \"entities\": [\n" +
            "        {\n" +
            "          \"id\": \"Bcn_Welt\",\n" +
            "          \"type\": \"Room\"\n" +
            "        }\n" +
            "      ],\n" +
            "      \"attributes\": [\n" +
            "        \"temperature\"\n" +
            "      ]\n" +
            "    },\n" +
            "    \"callback\": \"http://weather.example.com/ngsi\",\n" +
            "    \"metadata\": {\n" +
            "      \"providingService\": {\n" +
            "        \"value\": \"weather.example.com\",\n" +
            "        \"type\": \"none\"\n" +
            "      },\n" +
            "      \"providingAuthority\": {\n" +
            "        \"value\": \"AEMET - Spain\",\n" +
            "        \"type\": \"none\"\n" +
            "      }\n" +
            "    },\n" +
            "    \"duration\": \"PT1M\"\n" +
            "  }";

    @Test
    public void serializationRegistrationTest() throws JsonProcessingException, MalformedURLException {
// Path: ngsi2-client/src/test/java/com/orange/ngsi2/Utils.java
// public class Utils {
// 
//     /**
//      * Common object mapper used for most tests with Java 8 support for Optional
//      */
//     public final static ObjectMapper objectMapper = new ObjectMapper().registerModule(new Jdk8Module())
//             .registerModule(new JavaTimeModule())
//             .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
// 
//     /**
//      * Load a resource as an UTF-8 string
//      * @param name name of the resource
//      * @return the content of the resource
//      */
//     public static String loadResource(String name) {
//         try {
//             URL url = Utils.class.getClassLoader().getResource(name);
//             if (url == null) {
//                 return "";
//             }
//             return new String(Files.readAllBytes(Paths.get(url.toURI())), "UTF-8");
//         } catch (Exception e) {
//             return "";
//         }
//     }
// 
// }


// Path: ngsi2-client/src/test/java/com/orange/ngsi2/model/RegistrationTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.orange.ngsi2.Utils;
import org.junit.Test;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.Optional;

/*
 * Copyright (C) 2016 Orange
 *
 * 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.
 *
 */

package com.orange.ngsi2.model;




/**
 * Tests for the Registration
 */
public class RegistrationTest {

    String jsonString = "{\n" +
            "    \"id\": \"abcdefg\",\n" +
            "    \"subject\": {\n" +
            "      \"entities\": [\n" +
            "        {\n" +
            "          \"id\": \"Bcn_Welt\",\n" +
            "          \"type\": \"Room\"\n" +
            "        }\n" +
            "      ],\n" +
            "      \"attributes\": [\n" +
            "        \"temperature\"\n" +
            "      ]\n" +
            "    },\n" +
            "    \"callback\": \"http://weather.example.com/ngsi\",\n" +
            "    \"metadata\": {\n" +
            "      \"providingService\": {\n" +
            "        \"value\": \"weather.example.com\",\n" +
            "        \"type\": \"none\"\n" +
            "      },\n" +
            "      \"providingAuthority\": {\n" +
            "        \"value\": \"AEMET - Spain\",\n" +
            "        \"type\": \"none\"\n" +
            "      }\n" +
            "    },\n" +
            "    \"duration\": \"PT1M\"\n" +
            "  }";

    @Test
    public void serializationRegistrationTest() throws JsonProcessingException, MalformedURLException {
        ObjectWriter writer = Utils.objectMapper.writer(new DefaultPrettyPrinter());