package org.eclipse.scanning.test.command;

import static org.junit.Assert.*;
import static org.eclipse.scanning.command.ModelStringifier.stringify;

import org.eclipse.scanning.api.points.models.BoundingBox;
import org.eclipse.scanning.api.points.models.GridModel;
import org.eclipse.scanning.api.points.models.StepModel;
import org.junit.Test;


public class ModelStringifierTest {
	// TODO: Test round-trips, i.e. interpret(stringify(model)) == model.

	@Test
	public void testStepModelConcise() {
		StepModel smodel = new StepModel();
		smodel.setStart(0);
		smodel.setStop(10);
		smodel.setStep(1);
		smodel.setName("fred");

		assertEquals("step('fred', 0.0, 10.0, 1.0)", stringify(smodel, false));
	}

	@Test
	public void testStepModelVerbose() {
		StepModel smodel = new StepModel();
		smodel.setStart(0);
		smodel.setStop(10);
		smodel.setStep(1);
		smodel.setName("fred");

		assertEquals("step(axis='fred', start=0.0, stop=10.0, step=1.0)", stringify(smodel, true));
	}

	@Test
	public void testGridModelConcise() {
		BoundingBox bbox = new BoundingBox();
		bbox.setxStart(0);
		bbox.setyStart(1);
		bbox.setWidth(10);
		bbox.setHeight(11);

		GridModel gmodel = new GridModel();
		gmodel.setyName("alice");
		gmodel.setxName("bob");
		gmodel.setBoundingBox(bbox);
		gmodel.setRows(3);
		gmodel.setColumns(4);

		assertEquals(
				"grid(('bob', 'alice'), (0.0, 1.0), (10.0, 11.0), count=(3, 4), snake=False)",
				stringify(gmodel, false));
	}

	@Test
	public void testGridModelVerbose() {
		BoundingBox bbox = new BoundingBox();
		bbox.setxStart(0);
		bbox.setyStart(1);
		bbox.setWidth(10);
		bbox.setHeight(11);

		GridModel gmodel = new GridModel();
		gmodel.setyName("alice");
		gmodel.setxName("bob");
		gmodel.setBoundingBox(bbox);
		gmodel.setRows(3);
		gmodel.setColumns(4);

		assertEquals(
				"grid(axes=('bob', 'alice'), origin=(0.0, 1.0), size=(10.0, 11.0), count=(3, 4), snake=False)",
				stringify(gmodel, true));
	}

}

@@ -255,24 +255,83 @@
 .GridModel;%0A
+import org.eclipse.scanning.api.points.models.RasterModel;%0A
 import org.e
@@ -1998,10 +1998,990 @@
 ));%0A%09%7D%0A%0A
+%09@Test%0A%09public void testRasterModelConcise() %7B%0A%09%09BoundingBox bbox = new BoundingBox();%0A%09%09bbox.setxStart(0);%0A%09%09bbox.setyStart(1);%0A%09%09bbox.setWidth(10);%0A%09%09bbox.setHeight(11);%0A%0A%09%09RasterModel rmodel = new RasterModel();%0A%09%09rmodel.setyName(%22alice%22);%0A%09%09rmodel.setxName(%22bob%22);%0A%09%09rmodel.setBoundingBox(bbox);%0A%09%09rmodel.setxStep(3);%0A%09%09rmodel.setyStep(4);%0A%0A%09%09assertEquals(%0A%09%09%09%09%22grid(('bob', 'alice'), (0.0, 1.0), (10.0, 11.0), step=(3.0, 4.0), snake=False)%22,%0A%09%09%09%09stringify(rmodel, false));%0A%09%7D%0A%0A%09@Test%0A%09public void testRasterModelVerbose() %7B%0A%09%09BoundingBox bbox = new BoundingBox();%0A%09%09bbox.setxStart(0);%0A%09%09bbox.setyStart(1);%0A%09%09bbox.setWidth(10);%0A%09%09bbox.setHeight(11);%0A%0A%09%09RasterModel rmodel = new RasterModel();%0A%09%09rmodel.setyName(%22alice%22);%0A%09%09rmodel.setxName(%22bob%22);%0A%09%09rmodel.setBoundingBox(bbox);%0A%09%09rmodel.setxStep(3);%0A%09%09rmodel.setyStep(4);%0A%0A%09%09assertEquals(%0A%09%09%09%09%22grid(axes=('bob', 'alice'), origin=(0.0, 1.0), size=(10.0, 11.0), step=(3.0, 4.0), snake=False)%22,%0A%09%09%09%09stringify(rmodel, true));%0A%09%7D%0A%0A
 %7D%0A

Add tests for RasterModel stringifier