Github user nickwallen commented on a diff in the pull request:

    https://github.com/apache/metron/pull/667#discussion_r135262339
  
    --- Diff: 
metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/TextFunctionsTest.java
 ---
    @@ -0,0 +1,103 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
    + * agreements.  See the NOTICE file distributed with this work for 
additional information regarding
    + * copyright ownership.  The ASF licenses this file to you under the 
Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with 
the License.  You may obtain
    + * a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software 
distributed under the License
    + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 
ANY KIND, either express
    + * or implied. See the License for the specific language governing 
permissions and limitations under
    + * the License.
    + */
    +
    +package org.apache.metron.stellar.dsl.functions;
    +
    +import java.util.Arrays;
    +import java.util.List;
    +import java.util.Locale;
    +import org.apache.metron.stellar.dsl.DefaultVariableResolver;
    +import org.apache.metron.stellar.dsl.ParseException;
    +import org.junit.Assert;
    +import org.junit.Test;
    +import java.util.HashMap;
    +import java.util.Map;
    +
    +import static 
org.apache.metron.stellar.common.utils.StellarProcessorUtils.run;
    +import static 
org.apache.metron.stellar.common.utils.StellarProcessorUtils.runPredicate;
    +
    +public class TextFunctionsTest {
    +
    +  static final Map<String, String> variableMap = new HashMap<String, 
String>() {{
    +    put("metron", "metron");
    +    put("sentence", "metron is great");
    +    put("empty", "");
    +    put("english", "en");
    +    put("klingon", "Kling");
    +    put("asf", "Apache Software Foundation");
    +  }};
    +
    +  @Test
    +  public void testGetAvailableLanguageTags() {
    +    Object ret = run("FUZZY_LANGS()", new HashMap<>());
    +    Assert.assertNotNull(ret);
    +    Assert.assertTrue(ret instanceof List);
    +    List<String> tags = (List<String>) ret;
    +    Assert.assertTrue(tags.size() > 0);
    +    Assert.assertTrue(tags.contains("en"));
    +    Assert.assertTrue(tags.contains("fr"));
    +  }
    +
    +  @Test()
    +  public void testNoMatchStrings() throws Exception {
    +    runPredicate("0 == FUZZY_SCORE(metron,'z',english)",
    +        new DefaultVariableResolver(v -> variableMap.get(v),
    +            v -> variableMap.containsKey(v)));
    +  }
    +
    +  @Test(expected = ParseException.class)
    +  public void testMissingLanguage() throws Exception {
    +    runPredicate("0 == FUZZY_SCORE(metron,'z',klingon)",
    +        new DefaultVariableResolver(v -> variableMap.get(v),
    +            v -> variableMap.containsKey(v)));
    +  }
    +
    +  @Test()
    +  public void testEmptyFirstArg() throws Exception {
    --- End diff --
    
    This test will never fail


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to