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.assertTrue;
/**
* 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));
assertTrue((response.getStatusLine().getStatusCode() == 415) || (response.getStatusLine().getStatusCode() == 501));
}
{{/vendorExtensions.x-is-get-method}}
{{/operation}}
{{/operations}}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy