@Test
public void testOverlay() {

    CheckSpec left = new CheckSpec();
    CheckSpec right = new CheckSpec();
    CheckSpec emptyComposite = left.overlay(right);
    assertNull("getName is null", emptyComposite.getName());
    assertNull("getImpl is null", emptyComposite.getImpl());
    assertNull("getTemplate is null", emptyComposite.getTemplate());
    assertNull("getInlineScript is null", emptyComposite.getInlineScript());
    assertNull("getInlineEngine is null", emptyComposite.getInlineEngine());
    assertFalse("isSkip is false", emptyComposite.isSkip());
    assertEquals("getConfig is empty, not null", JsonValue.EMPTY_JSON_OBJECT, emptyComposite.getConfig());
    right.setName("right_name");
    right.setImpl("right_impl");
    right.setTemplate("right_template");
    right.setInlineScript("right_inlineScript");
    right.setInlineEngine("right_inlineEngine");
    right.setConfig(key("side", "right").key("onlyRight", "onlyRight").get());
    right.setSkip(true);
    final CheckSpec allRight = left.overlay(right);
    assertEquals("getName is right_name", "right_name", allRight.getName());
    assertEquals("getImpl is right_impl", "right_impl", allRight.getImpl());
    assertEquals("getTemplate is right_template", "right_template", allRight.getTemplate());
    assertEquals("getInlineScript is right_inlineScript", "right_inlineScript", allRight.getInlineScript());
    assertEquals("getInlineEngine is right_inlineEngine", "right_inlineEngine", allRight.getInlineEngine());
    assertTrue("isSkip is true", allRight.isSkip());
    assertEquals("getConfig side is right", "right", allRight.getConfig().getString("side"));
    assertEquals("getConfig onlyRight is onlyRight", "right", allRight.getConfig().getString("side"));
    left.setConfig(key("side", "left").key("onlyLeft", "onlyLeft").get());
    final CheckSpec leftConfig = left.overlay(right);
    assertEquals("getConfig side is left", "left", leftConfig.getConfig().getString("side"));
    assertEquals("getConfig onlyRight is onlyRight", "onlyRight", leftConfig.getConfig().getString("onlyRight"));
    assertEquals("getConfig onlyLeft is onlyLeft", "onlyLeft", leftConfig.getConfig().getString("onlyLeft"));
    left.setImpl("left_impl");
    final CheckSpec leftImpl = left.overlay(right);
    assertEquals("getImpl is left_impl", "left_impl", leftImpl.getImpl());
    assertNull("getInlineScript is null", leftImpl.getInlineScript());
    assertNull("getInlineEngine is null", leftImpl.getInlineEngine());
    left.setInlineScript("left_inlineScript");
    final CheckSpec leftScript = left.overlay(right);
    assertNull("getImpl is left_impl", leftScript.getImpl());
    assertEquals("getInlineScript is left_inlineScript", "left_inlineScript", leftScript.getInlineScript());
    assertNull("getInlineEngine is null", leftScript.getInlineEngine());
    left.setInlineEngine("left_inlineEngine");
    final CheckSpec leftEngine = left.overlay(right);
    assertNull("getImpl is left_impl", leftEngine.getImpl());
    assertEquals("getInlineScript is left_inlineScript", "left_inlineScript", leftEngine.getInlineScript());
    assertEquals("getInlineEngine is left_inlineEngine", "left_inlineEngine", leftEngine.getInlineEngine());
    left.setName("left_name");
    final CheckSpec leftName = left.overlay(right);
    assertEquals("getName is right_name", "right_name", leftName.getName());
    left.setSkip(true);
    final CheckSpec leftSkip = left.overlay(right);
    assertTrue("isSkip is true (left is skipped)", leftSkip.isSkip());
    right.setSkip(false);
    final CheckSpec rightNoSkip = left.overlay(right);
    assertTrue("isSkip is true (left yes, right no)", rightNoSkip.isSkip());
    left.setSkip(false);
    final CheckSpec noSkip = left.overlay(right);
    assertFalse("isSkip is false", noSkip.isSkip());
}