/*-- $Copyright (c) 2014 Christoffer Fink$

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package net.finkn.inputspec.tools;

import net.finkn.inputspec.tools.types.Point;

import se.miun.itm.input.model.InPUTException;
import se.miun.itm.input.model.design.IDesign;

/**
 * Helper for writing more concise tests.
 * Exports common configurations and small functions that are common to
 * multiple tests.
 */
public class Helper {

  private static final GenTestCase genTest = GenTestCase.getInstance();
  private static final SinkTestCase sinkTest = SinkTestCase.getInstance();

  public static final ParamCfg pointParam = ParamCfg.builder()
      .id("X").inclMin("10").inclMax("20").add()
      .id("Y").inclMin("15").inclMax("25").add()
      .structured()
      .id("Point")
      .build();

  public static final MappingCfg pointMapping = MappingCfg.builder()
      .infer(pointParam, Point.class)
      .build();

  public static ParamCfg.Builder pb() {
    return ParamCfg.builder();
  }

  public static SinkTestCase sinkTest(ParamCfg.Builder builder) throws InPUTException {
    return sinkTest.sink(Sink.fromParam(builder.build()));
  }
  public static SinkTestCase sinkTest(IDesign design, String id) throws InPUTException {
    return sinkTest.sink(Sink.fromDesign(design, id));
  }
  public static SinkTestCase sinkTest(String id, ParamCfg ... cfgs) throws InPUTException {
    return sinkTest(design(cfgs), id);
  }

  public static GenTestCase genTest(ParamCfg.Builder builder) throws InPUTException {
    return genTest.gen(Generator.fromParam(builder.build()));
  }

  public static GenTestCase genTest(String id, ParamCfg ... cfgs) throws InPUTException {
    DesignSpaceCfg space = DesignSpaceCfg.builder().param(cfgs).build();
    return genTest.gen(Generator.fromDesignSpace(space.getDesignSpace(), id));
  }

  public static IDesign design(ParamCfg ... params) throws InPUTException {
    return DesignSpaceCfg.builder()
      .param(params)
      .build()
      .getDesignSpace()
      .nextDesign("Design");
  }
}

@@ -1384,31 +1384,121 @@
 .%0A *
-/%0Apublic class Helper %7B
+%0A * @author Christoffer Fink%0A */%0Apublic class Helper %7B%0A%0A  private static final String defaultDesignId = %22Design%22;
 %0A%0A  
@@ -2203,32 +2203,33 @@
 .build()));%0A  %7D%0A
+%0A
   public static 
@@ -2360,16 +2360,17 @@
 ));%0A  %7D%0A
+%0A
   public
@@ -2965,32 +2965,170 @@
 nPUTException %7B%0A
+    return design(null, params);%0A  %7D%0A%0A  public static IDesign design(CodeMappingCfg mapping, ParamCfg ... params) throws InPUTException %7B%0A
     return Desig
@@ -3168,16 +3168,40 @@
 params)%0A
+      .mapping(mapping)%0A
       .b
@@ -3249,24 +3249,31 @@
 tDesign(
-%22
+default
 Design
-%22
+Id
 );%0A  %7D%0A%7D

add design(CodeMappingCfg, ParamCfg...)