Search in sources :

Example 6 with ConcatNONDuplicatedCalculator

use of nl.basjes.parse.useragent.calculate.ConcatNONDuplicatedCalculator 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));
}
Also used : MutableUserAgent(nl.basjes.parse.useragent.UserAgent.MutableUserAgent) CalculateDeviceBrand(nl.basjes.parse.useragent.calculate.CalculateDeviceBrand) CalculateAgentName(nl.basjes.parse.useragent.calculate.CalculateAgentName) MajorVersionCalculator(nl.basjes.parse.useragent.calculate.MajorVersionCalculator) ConcatNONDuplicatedCalculator(nl.basjes.parse.useragent.calculate.ConcatNONDuplicatedCalculator) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

MutableUserAgent (nl.basjes.parse.useragent.UserAgent.MutableUserAgent)6 ConcatNONDuplicatedCalculator (nl.basjes.parse.useragent.calculate.ConcatNONDuplicatedCalculator)6 Test (org.junit.jupiter.api.Test)6 FieldCalculator (nl.basjes.parse.useragent.calculate.FieldCalculator)5 CalculateAgentName (nl.basjes.parse.useragent.calculate.CalculateAgentName)1 CalculateDeviceBrand (nl.basjes.parse.useragent.calculate.CalculateDeviceBrand)1 MajorVersionCalculator (nl.basjes.parse.useragent.calculate.MajorVersionCalculator)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1