// Path: src/main/java/de/fesere/hypermedia/cj/exceptions/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
//     public ElementNotFoundException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/de/fesere/hypermedia/cj/exceptions/MalformedDataValueException.java
// public class MalformedDataValueException extends RuntimeException {
// 
//     public MalformedDataValueException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/de/fesere/hypermedia/cj/model/data/StringDataEntry.java
// public class StringDataEntry extends BaseDataEntry<String> {
// 
//     private String value;
// 
//     public StringDataEntry(String name) {
//         this(name, "");
//     }
// 
//     public StringDataEntry(String name, String value) {
//         super(name);
//         this.value = value;
//     }
// 
//     public StringDataEntry(String name, String value, String prompt) {
//         super(name, prompt);
//         this.value = value;
//     }
// 
//     @Override
//     public String getValue() {
//         return value;
//     }
// }


import de.fesere.hypermedia.cj.exceptions.ElementNotFoundException;
import de.fesere.hypermedia.cj.exceptions.MalformedDataValueException;
import de.fesere.hypermedia.cj.model.data.StringDataEntry;
import org.junit.Assert;
import org.junit.Test;
import java.net.URI;
import static junit.framework.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.core.Is.is;
package de.fesere.hypermedia.cj.model;




public class ItemSerializationTest extends SerializationTestBase {

    private static final URI TEST_COM_ITEM = URI.create("http://writeToStringExample.com/item/1");

    @Test
    public void testPOJOtoJSON() {
        Item classUnderTest = new Item(TEST_COM_ITEM);

        assertSerialization("{\"href\":\"http://writeToStringExample.com/item/1\"}", classUnderTest);
    }

    @Test
    public void testJSONtoPOJO() {
        String givenJSON = "{\"href\":\"http://writeToStringExample.com/item/1\"}";

        Item item = serializer.deserialize(givenJSON, Item.class);

        assertEquals(TEST_COM_ITEM, item.getHref());
    }

    @Test
    public void testJSONwithAllPropertiesToPOJO() {

        String givenJSON = "{\"href\":\"http://writeToStringExample.com/item/1\", \"data\":[{\"name\":\"foo\", \"value\":\"bar\", \"prompt\":\"foos prompt\"}]}";

        Item item = serializer.deserialize(givenJSON, Item.class);
        assertThat(item.getHref(), is(TEST_COM_ITEM));

        DataEntry dataEntry = item.getData().get(0);
        assertThat(dataEntry.getPrompt(), is("foos prompt"));
        assertThat(dataEntry.getName(), is("foo"));
        assertThat((String) dataEntry.getValue(), is("bar"));
    }

    @Test
    public void testSerializeItemWithSingleDataEntry() {
        Item item = new Item(TEST_COM_ITEM);
// Path: src/main/java/de/fesere/hypermedia/cj/exceptions/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
//     public ElementNotFoundException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/de/fesere/hypermedia/cj/exceptions/MalformedDataValueException.java
// public class MalformedDataValueException extends RuntimeException {
// 
//     public MalformedDataValueException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/de/fesere/hypermedia/cj/model/data/StringDataEntry.java
// public class StringDataEntry extends BaseDataEntry<String> {
// 
//     private String value;
// 
//     public StringDataEntry(String name) {
//         this(name, "");
//     }
// 
//     public StringDataEntry(String name, String value) {
//         super(name);
//         this.value = value;
//     }
// 
//     public StringDataEntry(String name, String value, String prompt) {
//         super(name, prompt);
//         this.value = value;
//     }
// 
//     @Override
//     public String getValue() {
//         return value;
//     }
// }


// Path: src/test/java/de/fesere/hypermedia/cj/model/ItemSerializationTest.java
import de.fesere.hypermedia.cj.exceptions.ElementNotFoundException;
import de.fesere.hypermedia.cj.exceptions.MalformedDataValueException;
import de.fesere.hypermedia.cj.model.data.StringDataEntry;
import org.junit.Assert;
import org.junit.Test;
import java.net.URI;
import static junit.framework.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.core.Is.is;

package de.fesere.hypermedia.cj.model;




public class ItemSerializationTest extends SerializationTestBase {

    private static final URI TEST_COM_ITEM = URI.create("http://writeToStringExample.com/item/1");

    @Test
    public void testPOJOtoJSON() {
        Item classUnderTest = new Item(TEST_COM_ITEM);

        assertSerialization("{\"href\":\"http://writeToStringExample.com/item/1\"}", classUnderTest);
    }

    @Test
    public void testJSONtoPOJO() {
        String givenJSON = "{\"href\":\"http://writeToStringExample.com/item/1\"}";

        Item item = serializer.deserialize(givenJSON, Item.class);

        assertEquals(TEST_COM_ITEM, item.getHref());
    }

    @Test
    public void testJSONwithAllPropertiesToPOJO() {

        String givenJSON = "{\"href\":\"http://writeToStringExample.com/item/1\", \"data\":[{\"name\":\"foo\", \"value\":\"bar\", \"prompt\":\"foos prompt\"}]}";

        Item item = serializer.deserialize(givenJSON, Item.class);
        assertThat(item.getHref(), is(TEST_COM_ITEM));

        DataEntry dataEntry = item.getData().get(0);
        assertThat(dataEntry.getPrompt(), is("foos prompt"));
        assertThat(dataEntry.getName(), is("foo"));
        assertThat((String) dataEntry.getValue(), is("bar"));
    }

    @Test
    public void testSerializeItemWithSingleDataEntry() {
        Item item = new Item(TEST_COM_ITEM);
        item.addData(new StringDataEntry("foo", "bar"));