use of nl.basjes.parse.useragent.calculate.CalculateDeviceBrand in project yauaa by nielsbasjes.
the class TestCalculators method checkBrandUrlExtraction.
@ParameterizedTest(name = "Test {index} -> Input: \"{0}\"")
@MethodSource("urlsAndBrands")
void checkBrandUrlExtraction(UrlBrandPair pair) {
LOG.info("URL: {}", pair);
MutableUserAgent userAgent = new MutableUserAgent();
userAgent.setForced(UserAgent.AGENT_INFORMATION_URL, pair.url, 1);
new CalculateDeviceBrand().calculate(userAgent);
assertEquals(pair.brand, userAgent.getValue(DEVICE_BRAND));
}
use of nl.basjes.parse.useragent.calculate.CalculateDeviceBrand 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));
}
Aggregations