@Transactional(readOnly = true) @Test public void testGetWidgetDefinitionsByCategory() throws IOException, Exception { SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(auth); MultiMap widgetDefinitionsByCategoryMap = uIService.getWidgetDefinitionsByCategory(); Assert.notNull(widgetDefinitionsByCategoryMap); // Assert.isTrue(widgetDefinitionsByCategoryMap.size() == 3); // Assert.isTrue(widgetDefinitionsByCategoryMap.values().size() == 4); org.junit.Assert.assertTrue( "testGetWidgetDefinitionsByCategory() widgetDefinitionsByCategoryMap.size() failed test, " + "expected value 3, actually got: " + widgetDefinitionsByCategoryMap.size(), widgetDefinitionsByCategoryMap.size() == 4); org.junit.Assert.assertTrue( "testGetWidgetDefinitionsByCategory() widgetDefinitionsByCategoryMap.values().size() failed test, " + "expected value 4, actually got: " + widgetDefinitionsByCategoryMap.values().size(), widgetDefinitionsByCategoryMap.values().size() >= 5); securityContext.setAuthentication(null); }
@Test public void testEscapeSolrQueryFunction() { final VariableResolverImpl resolver = new VariableResolverImpl(); ContextImpl context = new ContextImpl(null, resolver, null, Context.FULL_DUMP, Collections.EMPTY_MAP, null, null); Context.CURRENT_CONTEXT.set(context); try { Map m = new HashMap(); m.put("query", "c:t"); resolver.addNamespace( "dataimporter.functions", EvaluatorBag.getFunctionsNamespace(Collections.EMPTY_LIST, null)); resolver.addNamespace("e", m); String s = resolver.replaceTokens("${dataimporter.functions.escapeQueryChars(e.query)}"); org.junit.Assert.assertEquals("c\\:t", s); } finally { Context.CURRENT_CONTEXT.remove(); } }