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));
}
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));
}
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));
}
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));
}
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));
});
}
Aggregations