use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.
the class TestYamlBasedExpressions method runDebugOutputTest.
@Test
void runDebugOutputTest() {
UserAgentAnalyzerTester uaa = createTester("DebugOutput-tests.yaml");
assertTrue(uaa.runTests(true, true));
}
use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.
the class TestDeveloperTools method determineMatcherEfficiency.
@Test
void determineMatcherEfficiency() {
UserAgentAnalyzerTester userAgentAnalyzer = UserAgentAnalyzerTester.newBuilder().keepTests().hideMatcherLoadStats().build();
userAgentAnalyzer.analyzeMatcherImpactAllTests();
}
use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.
the class TestDeveloperTools method validateStringOutputsAndMatches.
@Test
void validateStringOutputsAndMatches() {
UserAgentAnalyzerTester uaa = UserAgentAnalyzerTester.newBuilder().withField("DeviceName").build();
MutableUserAgent useragent = new MutableUserAgent("Mozilla/5.0 (Linux; Android 7.0; Nexus 6 Build/NBD90Z) " + "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.124 Mobile Safari/537.36");
ImmutableUserAgent parseResult = uaa.parse(useragent);
assertTrue(parseResult.toString().contains("'Google Nexus 6'"));
assertTrue(parseResult.toJson().contains("\"DeviceName\":\"Google Nexus 6\""));
assertTrue(parseResult.toJson("DeviceName").contains("\"DeviceName\":\"Google Nexus 6\""));
assertFalse(parseResult.toJson("DeviceClass").contains("\"DeviceName\":\"Google Nexus 6\""));
assertTrue(parseResult.toXML().contains("<DeviceName>Google Nexus 6</DeviceName>"));
assertTrue(parseResult.toXML("DeviceName").contains("<DeviceName>Google Nexus 6</DeviceName>"));
assertFalse(parseResult.toXML("DeviceClass").contains("<DeviceName>Google Nexus 6</DeviceName>"));
assertEquals("Google Nexus 6", parseResult.toMap().get("DeviceName"));
assertEquals("Google Nexus 6", parseResult.toMap("DeviceName").get("DeviceName"));
assertNull(parseResult.toMap("DeviceClass").get("DeviceName"));
assertTrue(parseResult.toYamlTestCase(true).contains("'Google Nexus 6'"));
boolean ok = false;
for (Match match : uaa.getMatches()) {
if ("agent.(1)product.(1)comments.(3)entry[3-3]".equals(match.getKey())) {
assertEquals("Build", match.getValue());
ok = true;
break;
}
}
assertTrue(ok, "Did not see the expected match.");
ok = false;
for (Match match : uaa.getUsedMatches(useragent)) {
if ("agent.(1)product.(1)comments.(3)entry[3-3]".equals(match.getKey())) {
assertEquals("Build", match.getValue());
ok = true;
break;
}
}
assertTrue(ok, "Did not see the expected match.");
}
use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.
the class TestDeveloperTools method validateErrorSituationOutput.
@Test
void validateErrorSituationOutput() {
UserAgentAnalyzerTester uaa = UserAgentAnalyzerTester.newBuilder().showMatcherLoadStats().delayInitialization().keepTests().build();
uaa.loadResources("classpath*:**/CheckErrorOutput.yaml");
// This test must return an error state
assertFalse(uaa.runTests(false, true));
}
use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.
the class TestErrorHandlingLogOutput method testConflictingRules.
@Test
void testConflictingRules() {
assertDoesNotThrow(() -> {
UserAgentAnalyzerTester uaa = UserAgentAnalyzerTester.newBuilder().dropDefaultResources().keepTests().addResources("classpath*:BadDefinitions/ConflictingRules.yaml").build();
assertFalse(uaa.runTests(false, false));
LOG.info("Analyzer:\n{}", uaa);
});
assertTrue(logMessages.getOutput().contains("Found different value for \"Name\" with SAME confidence 1:"));
}
Aggregations