Search in sources :

Example 26 with ResteasyUriInfo

use of org.jboss.resteasy.specimpl.ResteasyUriInfo in project policies-ui-backend by RedHatInsights.

the class TagsFilterTest method filter7.

@Test
void filter7() throws URISyntaxException {
    UriInfo info = new ResteasyUriInfo(new URI("https://foo?filter[name]=toLowerCaseString&filter:op[name]=like"));
    Pager pager = PagingUtils.extractPager(info);
    String query = PolicyHistoryTagFilterHelper.getTagsFilterFromPager(pager);
    assertEquals("tags.display_name MATCHES '*tolowercasestring*'", query);
}
Also used : ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) Pager(com.redhat.cloud.policies.app.model.pager.Pager) URI(java.net.URI) ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.jupiter.api.Test)

Example 27 with ResteasyUriInfo

use of org.jboss.resteasy.specimpl.ResteasyUriInfo in project policies-ui-backend by RedHatInsights.

the class TagsFilterTest method filter4_2.

@Test
void filter4_2() throws URISyntaxException {
    UriInfo info = new ResteasyUriInfo(new URI("https://foo?filter[name]=VM&filter[id]=123&filter:op[name]=not_equal"));
    Pager pager = PagingUtils.extractPager(info);
    String query = PolicyHistoryTagFilterHelper.getTagsFilterFromPager(pager);
    assertEquals("tags.display_name != 'vm' AND tags.inventory_id = '123'", query);
}
Also used : ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) Pager(com.redhat.cloud.policies.app.model.pager.Pager) URI(java.net.URI) ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.jupiter.api.Test)

Example 28 with ResteasyUriInfo

use of org.jboss.resteasy.specimpl.ResteasyUriInfo in project policies-ui-backend by RedHatInsights.

the class TagsFilterTest method filter5.

@Test
void filter5() throws URISyntaxException {
    UriInfo info = new ResteasyUriInfo(new URI("https://foo?filter[id]=123-45&filter:op[id]=like"));
    Pager pager = PagingUtils.extractPager(info);
    String query = PolicyHistoryTagFilterHelper.getTagsFilterFromPager(pager);
    assertEquals("tags.inventory_id MATCHES '*123-45*'", query);
}
Also used : ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) Pager(com.redhat.cloud.policies.app.model.pager.Pager) URI(java.net.URI) ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.jupiter.api.Test)

Example 29 with ResteasyUriInfo

use of org.jboss.resteasy.specimpl.ResteasyUriInfo in project policies-ui-backend by RedHatInsights.

the class PagingUtilsTest method extractPagerInvalidLimit.

@Test
void extractPagerInvalidLimit() throws URISyntaxException {
    UriInfo info = new ResteasyUriInfo(new URI("https://foo?offset=12&limit=foo"));
    assertThrows(IllegalArgumentException.class, () -> {
        PagingUtils.extractPager(info);
    });
}
Also used : ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) URI(java.net.URI) ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.jupiter.api.Test)

Example 30 with ResteasyUriInfo

use of org.jboss.resteasy.specimpl.ResteasyUriInfo in project policies-ui-backend by RedHatInsights.

the class PagingUtilsTest method extractFilterInvalidOperator.

@Test
public void extractFilterInvalidOperator() throws URISyntaxException {
    UriInfo info = new ResteasyUriInfo(new URI("https://foo?filter[bar]=true&filter:op[bar]=wrong"));
    assertThrows(IllegalArgumentException.class, () -> {
        PagingUtils.extractPager(info);
    });
}
Also used : ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) URI(java.net.URI) ResteasyUriInfo(org.jboss.resteasy.specimpl.ResteasyUriInfo) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.jupiter.api.Test)

Aggregations

ResteasyUriInfo (org.jboss.resteasy.specimpl.ResteasyUriInfo)42 URI (java.net.URI)19 UriInfo (javax.ws.rs.core.UriInfo)14 Test (org.junit.jupiter.api.Test)14 Pager (com.redhat.cloud.policies.app.model.pager.Pager)8 Test (org.junit.Test)6 ResteasyHttpHeaders (org.jboss.resteasy.specimpl.ResteasyHttpHeaders)5 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)4 NotFoundException (jakarta.ws.rs.NotFoundException)4 IOException (java.io.IOException)3 WebQuery (com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery)2 Context (io.vertx.core.Context)2 HttpServerResponse (io.vertx.core.http.HttpServerResponse)2 PathSegment (jakarta.ws.rs.core.PathSegment)2 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 SecurityContext (javax.ws.rs.core.SecurityContext)2 HttpRequest (org.jboss.resteasy.spi.HttpRequest)2 HttpResponse (org.jboss.resteasy.spi.HttpResponse)2