package be.iminds.jfed.gts_highlevel.model;

import org.testng.annotations.Test;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.StringReader;

import static org.testng.Assert.assertEquals;

/**
 * User: twalcari
 * Date: 9/18/2015
 * Time: 17:35
 */

public class GtsXmlReservationTest {

    @Test
    public void unmarshalGtsReservation() throws JAXBException {

        final String input =  "    <reservation>\n" +
                "        <children>\n" +
                "            <id>58</id>\n" +
                "            <endTime>17548354799000</endTime>\n" +
                "            <projectName>jfed</projectName>\n" +
                "            <resourceProviderId>Host-1442504304395</resourceProviderId>\n" +
                "            <status>ACTIVE</status>\n" +
                "            <startTime>1442504280000</startTime>\n" +
                "        </children>\n" +
                "        <id>17</id>\n" +
                "        <endTime>17548354799000</endTime>\n" +
                "        <projectName>jfed</projectName>\n" +
                "        <resourceProviderId>66</resourceProviderId>\n" +
                "        <status>ACTIVE</status>\n" +
                "        <startTime>1442504280000</startTime>\n" +
                "    </reservation>";

        JAXBContext context = JAXBContext.newInstance(GtsXmlReservation.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();

        GtsXmlReservation reservation = (GtsXmlReservation) unmarshaller.unmarshal(new StringReader(input));

        assertEquals(reservation.getId(), new Integer(17));


    }
}
