package es.uvigo.ei.sing.vda.core;

import static es.uvigo.ei.sing.vda.core.RColors.R_COLORS;
import static org.junit.Assert.*;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;

import org.junit.Test;

import es.uvigo.ei.sing.vda.core.entities.NamedRSet;
import es.uvigo.ei.sing.vda.core.io.SerializationVennDiagramDesignReader;
import es.uvigo.ei.sing.vda.core.io.SerializationVennDiagramDesignWriter;
import es.uvigo.ei.sing.vda.core.io.VennDiagramDesignReader;
import es.uvigo.ei.sing.vda.core.io.VennDiagramDesignWriter;

public class VennDiagramDesignSerializationTest {

	private static final VennDiagramDesign VDD = new VennDiagramDesign(
		Arrays.asList(new NamedRSet[]{
			new NamedRSet<String>("A", R_COLORS[0])	
		})
	);
	
	static {
		VDD.getSets().get(0).add("Item 1");
		VDD.getSets().get(0).add("Item 2");
	}
	
	VennDiagramDesignWriter writer = new SerializationVennDiagramDesignWriter();
	VennDiagramDesignReader reader = new SerializationVennDiagramDesignReader();
	
	@Test
	public void testVennDiagramDesignSerialization() throws IOException {
		final File dest = File.createTempFile("venndiagramtest", "vda");
		dest.deleteOnExit();
		
		writer.write(VDD, dest);

		VennDiagramDesign readed = reader.read(dest);
		
		assertEquals(VDD, readed);
	}

}

@@ -87,16 +87,55 @@
 COLORS;%0A
+import static java.util.Arrays.asList;%0A
 import s
@@ -161,9 +161,20 @@
 ert.
-*
+assertEquals
 ;%0A%0Ai
@@ -224,33 +224,8 @@
 ion;
-%0Aimport java.util.Arrays;
 %0A%0Aim
@@ -693,43 +693,16 @@
 ign(
-%0A%09%09Arrays.asList(new NamedRSet%5B%5D%7B%0A%09
+asList(%0A
 %09%09ne
@@ -742,13 +742,8 @@
 %5B0%5D)
-%09%0A%09%09%7D
 )%0A%09)

Fix raw types warning