use of nl.basjes.parse.useragent.UserAgent.MutableUserAgent in project yauaa by nielsbasjes.
the class TestUseragent method testUseragent.
@Test
void testUseragent() {
String uaString = "Foo Bar";
UserAgent agent = new MutableUserAgent(uaString);
assertEquals(uaString, agent.get(UserAgent.USERAGENT_FIELDNAME).getValue());
assertEquals(0, agent.get(UserAgent.USERAGENT_FIELDNAME).getConfidence());
assertEquals(uaString, agent.getValue(UserAgent.USERAGENT_FIELDNAME));
assertEquals(0L, agent.getConfidence(UserAgent.USERAGENT_FIELDNAME).longValue());
}
use of nl.basjes.parse.useragent.UserAgent.MutableUserAgent in project yauaa by nielsbasjes.
the class TestCalculators method testFieldAgentNameVersionFallback.
@Test
void testFieldAgentNameVersionFallback() {
MutableUserAgent userAgent = new MutableUserAgent();
userAgent.setForced(UserAgent.DEVICE_BRAND, "some_thing", 1);
userAgent.setForced(AGENT_VERSION, "1.2.3", 1);
new CalculateDeviceBrand().calculate(userAgent);
new CalculateAgentName().calculate(userAgent);
new MajorVersionCalculator(AGENT_VERSION_MAJOR, AGENT_VERSION).calculate(userAgent);
new ConcatNONDuplicatedCalculator(AGENT_NAME_VERSION, AGENT_NAME, AGENT_VERSION).calculate(userAgent);
new ConcatNONDuplicatedCalculator(AGENT_NAME_VERSION_MAJOR, AGENT_NAME, AGENT_VERSION_MAJOR).calculate(userAgent);
assertEquals("Some_Thing", userAgent.getValue(DEVICE_BRAND));
assertEquals("Some_Thing", userAgent.getValue(AGENT_NAME));
assertEquals("Some_Thing 1.2.3", userAgent.getValue(AGENT_NAME_VERSION));
assertEquals("1", userAgent.getValue(AGENT_VERSION_MAJOR));
assertEquals("Some_Thing 1", userAgent.getValue(AGENT_NAME_VERSION_MAJOR));
}
use of nl.basjes.parse.useragent.UserAgent.MutableUserAgent in project yauaa by nielsbasjes.
the class TestClassifier method verifyDeviceClass.
private void verifyDeviceClass(DeviceClass deviceClass, boolean human, boolean mobile, boolean normal, boolean misuse) {
MutableUserAgent userAgent = new MutableUserAgent();
userAgent.set(DEVICE_CLASS, deviceClass.getValue(), 1);
assertEquals(human, isHuman(userAgent), "For the DeviceClass " + deviceClass + " the isHuman() was incorrect.");
assertEquals(mobile, isMobile(userAgent), "For the DeviceClass " + deviceClass + " the isMobile() was incorrect.");
assertEquals(normal, isNormalConsumerDevice(userAgent), "For the DeviceClass " + deviceClass + " the isNormalConsumerDevice() was incorrect.");
assertEquals(misuse, isDeliberateMisuse(userAgent), "For the DeviceClass " + deviceClass + " the isDeliberateMisuse() was incorrect.");
}
Aggregations