Search in sources :

Example 1 with UserAgentAnalyzerTester

use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.

the class TestResourceLoading method checkAllFieldsCallsAfterLoadingAdditionalResourceUnsorted.

@Test
void checkAllFieldsCallsAfterLoadingAdditionalResourceUnsorted() {
    UserAgentAnalyzerTester uaa = UserAgentAnalyzerTester.newBuilder().dropDefaultResources().addResources("classpath*:AllSteps.yaml").build();
    // uaa.finalizeLoadingRules();
    Set<String> fieldSet1 = uaa.getAllPossibleFieldNames();
    uaa.loadResources("CompanyInternalUserAgents.yaml");
    // uaa.finalizeLoadingRules();
    Set<String> fieldSet2 = uaa.getAllPossibleFieldNames();
    List<String> extraFields = new ArrayList<>();
    Collections.addAll(extraFields, "ApplicationName", "ApplicationVersion", "ApplicationInstance", "ApplicationGitCommit", "ServerName");
    assertFalse(fieldSet1.containsAll(extraFields));
    assertTrue(fieldSet2.containsAll(extraFields));
}
Also used : UserAgentAnalyzerTester(nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester) ArrayList(java.util.ArrayList) YamlUtils.getKeyAsString(nl.basjes.parse.useragent.utils.YamlUtils.getKeyAsString) Test(org.junit.jupiter.api.Test)

Example 2 with UserAgentAnalyzerTester

use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.

the class TestResourceLoading method checkEmptyAndNormalAndOptionalMissingFile.

@Test
void checkEmptyAndNormalAndOptionalMissingFile() {
    UserAgentAnalyzerTester uaa = UserAgentAnalyzerTester.newBuilder().dropDefaultResources().addResources("classpath*:AllSteps.yaml").addResources("classpath*:BadDefinitions/EmptyFile.yaml").addOptionalResources("classpath*:BadDefinitions/ThisOneDoesNotExist---Really.yaml").build();
    assertTrue(uaa.runTests(false, false));
}
Also used : UserAgentAnalyzerTester(nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester) Test(org.junit.jupiter.api.Test)

Example 3 with UserAgentAnalyzerTester

use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.

the class TestResourceLoading method checkIfLoadingAllFilesSeparatelyAsOptionalWorks.

@Test
void checkIfLoadingAllFilesSeparatelyAsOptionalWorks() {
    UserAgentAnalyzerTesterBuilder uaaB = UserAgentAnalyzerTester.newBuilder().hideMatcherLoadStats().dropDefaultResources();
    PackagedRules.getRuleFileNames().forEach(uaaB::addOptionalResources);
    UserAgentAnalyzerTester uaa = uaaB.withCache(10000).build();
    assertTrue(uaa.runTests(false, false));
}
Also used : UserAgentAnalyzerTester(nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester) UserAgentAnalyzerTesterBuilder(nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester.UserAgentAnalyzerTesterBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with UserAgentAnalyzerTester

use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.

the class TestResourceLoading method checkAllFieldsCallsAfterLoadingAdditionalResourceSorted.

@Test
void checkAllFieldsCallsAfterLoadingAdditionalResourceSorted() {
    UserAgentAnalyzerTester uaa = UserAgentAnalyzerTester.newBuilder().dropDefaultResources().addResources("classpath*:AllSteps.yaml").build();
    uaa.finalizeLoadingRules();
    List<String> fieldList1 = uaa.getAllPossibleFieldNamesSorted();
    uaa.loadResources("CompanyInternalUserAgents.yaml");
    uaa.finalizeLoadingRules();
    List<String> fieldList2 = uaa.getAllPossibleFieldNamesSorted();
    List<String> extraFields = new ArrayList<>();
    Collections.addAll(extraFields, "ApplicationName", "ApplicationVersion", "ApplicationInstance", "ApplicationGitCommit", "ServerName");
    assertFalse(fieldList1.containsAll(extraFields));
    assertTrue(fieldList2.containsAll(extraFields));
}
Also used : UserAgentAnalyzerTester(nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester) ArrayList(java.util.ArrayList) YamlUtils.getKeyAsString(nl.basjes.parse.useragent.utils.YamlUtils.getKeyAsString) Test(org.junit.jupiter.api.Test)

Example 5 with UserAgentAnalyzerTester

use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.

the class TestResourceLoading method checkEmptyAndNormalAndMandatoryMissingFile.

@Test
void checkEmptyAndNormalAndMandatoryMissingFile() {
    assertThrows(InvalidParserConfigurationException.class, () -> {
        UserAgentAnalyzerTester uaa = UserAgentAnalyzerTester.newBuilder().dropDefaultResources().addResources("classpath*:AllSteps.yaml").addResources("classpath*:BadDefinitions/EmptyFile.yaml").addResources(// Should cause a failure
        "classpath*:BadDefinitions/ThisOneDoesNotExist---Really.yaml").build();
        assertTrue(uaa.runTests(false, false));
    });
}
Also used : UserAgentAnalyzerTester(nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester) Test(org.junit.jupiter.api.Test)

Aggregations

UserAgentAnalyzerTester (nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester)43 Test (org.junit.jupiter.api.Test)37 ArrayList (java.util.ArrayList)3 UserAgentAnalyzerTesterBuilder (nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester.UserAgentAnalyzerTesterBuilder)3 TestCase (nl.basjes.parse.useragent.config.TestCase)2 YamlUtils.getKeyAsString (nl.basjes.parse.useragent.utils.YamlUtils.getKeyAsString)2 Kryo (com.esotericsoftware.kryo.Kryo)1 ByteBufferInput (com.esotericsoftware.kryo.io.ByteBufferInput)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ObjectInput (java.io.ObjectInput)1 ObjectInputStream (java.io.ObjectInputStream)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 ImmutableUserAgent (nl.basjes.parse.useragent.UserAgent.ImmutableUserAgent)1 MutableUserAgent (nl.basjes.parse.useragent.UserAgent.MutableUserAgent)1 InvalidParserConfigurationException (nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException)1 Match (nl.basjes.parse.useragent.analyze.MatchesList.Match)1 AbstractUserAgentAnalyzerTester (nl.basjes.parse.useragent.debug.AbstractUserAgentAnalyzerTester)1 Disabled (org.junit.jupiter.api.Disabled)1