use of org.wso2.carbon.apimgt.persistence.exceptions.APIPersistenceException in project carbon-apimgt by wso2.
the class RegistrySearchUtilTestCase method testAdminUserQueryInDevPortal.
@Test
public void testAdminUserQueryInDevPortal() throws APIPersistenceException {
// Normal dev portal api listing
String inputQuery = "";
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("isAdmin", true);
UserContext ctx = new UserContext("admin", organization, properties, new String[] { "admin" });
String searchQuery = RegistrySearchUtil.getDevPortalSearchQuery(inputQuery, ctx, false, false);
String expected = "name=*&enableStore=(true OR null)&group=true&group.field=name&group.ngroups=true&group.sort=versionTimestamp desc&lcState=(PUBLISHED OR PROTOTYPED)";
Assert.assertEquals("Generated query mismatched. ", expected, searchQuery);
// search for 'test' in description
inputQuery = "description:test";
expected = "description=*test*&lcState=(PUBLISHED OR PROTOTYPED)";
searchQuery = RegistrySearchUtil.getDevPortalSearchQuery(inputQuery, ctx, false, false);
Assert.assertEquals("Generated query mismatched for description search. ", expected, searchQuery);
// search for provider 'pubuser'
inputQuery = "provider:pubuser";
expected = "provider=*pubuser*&lcState=(PUBLISHED OR PROTOTYPED)";
searchQuery = RegistrySearchUtil.getDevPortalSearchQuery(inputQuery, ctx, false, false);
Assert.assertEquals("Generated query mismatched for provider search. ", expected, searchQuery);
}
use of org.wso2.carbon.apimgt.persistence.exceptions.APIPersistenceException in project carbon-apimgt by wso2.
the class RegistrySearchUtilTestCase method testDevPortalUserQueryInDevPortal.
@Test
public void testDevPortalUserQueryInDevPortal() throws APIPersistenceException {
// Normal dev portal api listing
String inputQuery = "";
UserContext ctx = new UserContext("devUser", organization, null, devPortalRoles);
String searchQuery = RegistrySearchUtil.getDevPortalSearchQuery(inputQuery, ctx, false, false);
String expected = "store_view_roles=(null OR internal\\/subscriber OR internal\\/everyone)&name=*" + "&enableStore=(true OR null)&group=true&group.field=name&group.ngroups=true&group.sort=versionTimestamp desc" + "&lcState=(PUBLISHED OR PROTOTYPED)";
Assert.assertEquals("Generated query mismatched. ", expected, searchQuery);
// search for 'test' in description
inputQuery = "description:test";
expected = "store_view_roles=(null OR internal\\/subscriber OR internal\\/everyone)&" + "description=*test*&lcState=(PUBLISHED OR PROTOTYPED)";
searchQuery = RegistrySearchUtil.getDevPortalSearchQuery(inputQuery, ctx, false, false);
Assert.assertEquals("Generated query mismatched for description search. ", expected, searchQuery);
// search for provider 'pubuser'
inputQuery = "provider:pubuser";
expected = "store_view_roles=(null OR internal\\/subscriber OR internal\\/everyone)&" + "provider=*pubuser*&lcState=(PUBLISHED OR PROTOTYPED)";
searchQuery = RegistrySearchUtil.getDevPortalSearchQuery(inputQuery, ctx, false, false);
Assert.assertEquals("Generated query mismatched for provider search. ", expected, searchQuery);
// search for propertyname 'test'
inputQuery = "property_name:test";
expected = "store_view_roles=(null OR internal\\/subscriber OR internal\\/everyone)" + "&api_meta.property_name__display=*test*&lcState=(PUBLISHED OR PROTOTYPED)";
searchQuery = RegistrySearchUtil.getDevPortalSearchQuery(inputQuery, ctx, false, false);
Assert.assertEquals("Generated query mismatched for property search. ", expected, searchQuery);
}
use of org.wso2.carbon.apimgt.persistence.exceptions.APIPersistenceException in project carbon-apimgt by wso2.
the class RegistrySearchUtilTestCase method testAnonymousUserQueryInDevPortal.
@Test
public void testAnonymousUserQueryInDevPortal() throws APIPersistenceException {
// Normal dev portal api listing
String inputQuery = "";
UserContext ctx = new UserContext("wso2.anonymous.user", organization, null, anonymousRoles);
String searchQuery = RegistrySearchUtil.getDevPortalSearchQuery(inputQuery, ctx, false, false);
String expected = "store_view_roles=(null OR system\\/wso2.anonymous.role)&name=*&enableStore=(true OR null)" + "&group=true&group.field=name&group.ngroups=true&group.sort=versionTimestamp desc&lcState=(PUBLISHED OR PROTOTYPED)";
Assert.assertEquals("Generated query mismatched. ", expected, searchQuery);
// search for 'test' in description
inputQuery = "description:test";
expected = "store_view_roles=(null OR system\\/wso2.anonymous.role)&" + "description=*test*&lcState=(PUBLISHED OR PROTOTYPED)";
searchQuery = RegistrySearchUtil.getDevPortalSearchQuery(inputQuery, ctx, false, false);
Assert.assertEquals("Generated query mismatched for description search. ", expected, searchQuery);
// search for provider 'pubuser'
inputQuery = "provider:pubuser";
expected = "store_view_roles=(null OR system\\/wso2.anonymous.role)&" + "provider=*pubuser*&lcState=(PUBLISHED OR PROTOTYPED)";
searchQuery = RegistrySearchUtil.getDevPortalSearchQuery(inputQuery, ctx, false, false);
Assert.assertEquals("Generated query mismatched for provider search. ", expected, searchQuery);
// search for propertyname 'test'
inputQuery = "property_name:test";
expected = "store_view_roles=(null OR system\\/wso2.anonymous.role)" + "&api_meta.property_name__display=*test*&lcState=(PUBLISHED OR PROTOTYPED)";
searchQuery = RegistrySearchUtil.getDevPortalSearchQuery(inputQuery, ctx, false, false);
Assert.assertEquals("Generated query mismatched for property search. ", expected, searchQuery);
}
use of org.wso2.carbon.apimgt.persistence.exceptions.APIPersistenceException in project carbon-apimgt by wso2.
the class RegistrySearchUtilTestCase method testPublisherUserQueryInPublisher.
@Test
public void testPublisherUserQueryInPublisher() throws APIPersistenceException {
// Normal publisher api listing
String inputQuery = "";
UserContext ctx = new UserContext("publisher", organization, null, publisherRoles);
String searchQuery = RegistrySearchUtil.getPublisherSearchQuery(inputQuery, ctx);
String expected = "publisher_roles=(null OR internal\\/creator OR internal\\/publisher OR internal\\/everyone)" + "&name=*&type=(HTTP OR WS OR SOAPTOREST OR GRAPHQL OR SOAP OR SSE OR WEBSUB OR WEBHOOK OR ASYNC)";
Assert.assertEquals("Generated query mismatched. ", expected, searchQuery);
// search for 'test' in description
inputQuery = "description:test";
expected = "publisher_roles=(null OR internal\\/creator OR internal\\/publisher OR internal\\/everyone)" + "&description=*test*&type=(HTTP OR WS OR SOAPTOREST OR GRAPHQL OR SOAP OR SSE OR WEBSUB OR WEBHOOK " + "OR ASYNC)";
searchQuery = RegistrySearchUtil.getPublisherSearchQuery(inputQuery, ctx);
Assert.assertEquals("Generated query mismatched for description search. ", expected, searchQuery);
}
use of org.wso2.carbon.apimgt.persistence.exceptions.APIPersistenceException in project carbon-apimgt by wso2.
the class RegistryPersistenceUtilTestCase method testcreateAPIArtifactContent.
@Test
public void testcreateAPIArtifactContent() throws APIPersistenceException, APIManagementException, RegistryException {
API api = new API(new APIIdentifier("pubuser", "TestAPI", "1.0"));
Set<Tier> availableTiers = new HashSet<Tier>();
availableTiers.add(new Tier("Unlimited"));
availableTiers.add(new Tier("Gold"));
api.setAvailableTiers(availableTiers);
Set<URITemplate> uriTemplates = new HashSet<URITemplate>();
URITemplate template = new URITemplate();
template.setHTTPVerb("GET");
template.setUriTemplate("/test");
template.setAuthType("None");
uriTemplates.add(template);
api.setUriTemplates(uriTemplates);
List<APICategory> categories = new ArrayList<APICategory>();
APICategory category = new APICategory();
category.setName("testcategory");
categories.add(category);
api.setApiCategories(categories);
List<Label> gatewayLabels = new ArrayList<Label>();
Label label = new Label();
label.setName("TestLabel");
gatewayLabels.add(label);
GenericArtifact genericArtifact = new GenericArtifactImpl(new QName("", "TestAPI", ""), "application/vnd.wso2-api+xml");
genericArtifact.setAttribute("URITemplate", "/test");
GenericArtifact retArtifact = RegistryPersistenceUtil.createAPIArtifactContent(genericArtifact, api);
Assert.assertEquals("API name does not match", api.getId().getApiName(), retArtifact.getAttribute("overview_name"));
Assert.assertEquals("API version does not match", api.getId().getVersion(), retArtifact.getAttribute("overview_version"));
Assert.assertEquals("API provider does not match", api.getId().getProviderName(), retArtifact.getAttribute("overview_provider"));
}
Aggregations