handlebars.JavaSpring.libraries.spring-mvc.api_test.mustache Maven / Gradle / Ivy
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import java.util.*;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.testng.annotations.Test;
import static org.junit.Assert.assertEquals;
/**
* Test class to verify that GET endpoints on generated project are reached.
*/
public class {{classname}}ControllerIT {
{{#operations}}
{{#operation}}
{{#vendorExtensions.x-is-get-method}}
@Test
public void {{operationId}}Test() throws Exception {
final String requestURL = "http://localhost:8002{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}{{testPath}}{{#hasQueryParams}}?{{/hasQueryParams}}{{#queryParams}}{{paramName}}={{testExample}}{{#hasMore}}&{{/hasMore}}{{/queryParams}}";
final HttpClient client = HttpClientBuilder.create().build();
final HttpResponse response = client.execute(new HttpGet(requestURL));
assertEquals(response.getStatusLine().getStatusCode(), 501);
}
{{/vendorExtensions.x-is-get-method}}
{{/operation}}
{{/operations}}
}