package com.github.mgramin.sqlboot.rest.controllers;

import com.github.mgramin.sqlboot.rest.RestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import static org.junit.Assert.assertEquals;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = RestRunner.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestPropertySource(properties = {"management.port=0"})
@ActiveProfiles("information_schema")
public class DdlControllerTest {

    @Autowired
    private TestRestTemplate client;

    @Test
    public void getTextDdl() throws Exception {
        test("/ddl/table/hr");
        test("/ddl/table/hr/");
        test("/ddl/table/hr?type=sql");
        test("/ddl/table/hr?type=liquibase");
        test("/ddl/table/hr?type=html");
        test("/ddl/view/hr");
        test("/ddl/mview/hr");
    }

    private void test(String uri) {
        ResponseEntity<String> forEntity = client.getForEntity(uri, String.class);
        assertEquals(forEntity.getStatusCodeValue(), 200);
        System.out.println(forEntity.getBody());
    }

}
@@ -988,36 +988,51 @@
 ption %7B%0A        
+callRestAndValida
 te
-st
 (%22/ddl/table/hr%22
@@ -1034,36 +1034,51 @@
 e/hr%22);%0A        
+callRestAndValida
 te
-st
 (%22/ddl/table/hr/
@@ -1081,36 +1081,51 @@
 /hr/%22);%0A        
+callRestAndValida
 te
-st
 (%22/ddl/table/hr?
@@ -1136,36 +1136,51 @@
 =sql%22);%0A        
+callRestAndValida
 te
-st
 (%22/ddl/table/hr?
@@ -1201,28 +1201,43 @@
 %22);%0A        
+callRestAndValida
 te
-st
 (%22/ddl/table
@@ -1257,28 +1257,43 @@
 %22);%0A        
+callRestAndValida
 te
-st
 (%22/ddl/view/
@@ -1306,20 +1306,35 @@
         
+callRestAndValida
 te
-st
 (%22/ddl/m
@@ -1368,20 +1368,35 @@
 te void 
+callRestAndValida
 te
-st
 (String 

rename test method