package com.defimak47.grooshella.services.console.web;

import static org.junit.Assert.*;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

@RunWith(SpringRunner.class)
@SpringBootTest
public class GroovyScriptServiceTest {

    @Autowired
    private GroovyScriptService groovyScriptService;

    @Test
    public void testExecuteScript() {
        Map<String,Object> result = null;
        final String script = "println \"hello world!\"";
        _given: {
        }

        _then: {
            result = groovyScriptService.executeScript(script);
        }

        _expect: {
            assertNotNull(result);
        }
    
    }

}

@@ -80,16 +80,166 @@
 .Assert.
+assertNotNull;%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0A// import static org.hamcrest.CoreMatchers.*;%0Aimport static org.hamcrest.Matchers.
 *;%0A%0Aimpo
@@ -988,14 +988,459 @@
     
-%7D%0A
     
+assertThat(result, notNullValue());%0A            assertThat(result, allOf(%0A                                not(hasKey(%22error%22)),%0A                                hasKey(%22startTime%22),%0A                                hasKey(%22endTime%22),%0A                                hasKey(%22result%22),%0A                                hasKey(%22output%22))%0A                );%0A            assertThat(result, hasEntry(equalTo(%22output%22), anything(%22hello world!%22)));%0A        %7D
 %0A   

Complete assertion results.