Search in sources :

Example 6 with FieldCalculator

use of nl.basjes.parse.useragent.calculate.FieldCalculator in project yauaa by nielsbasjes.

the class TestConcatenation method testFieldConcatenationNonExistent.

@Test
void testFieldConcatenationNonExistent() {
    FieldCalculator fc;
    MutableUserAgent userAgent = createUserAgent();
    fc = new ConcatNONDuplicatedCalculator("Combined2", "One", "NonExistent");
    fc.calculate(userAgent);
    assertEquals("One Unknown", userAgent.getValue("Combined2"));
    fc = new ConcatNONDuplicatedCalculator("Combined3", "NonExistent", "Two");
    fc.calculate(userAgent);
    assertEquals("Unknown Two", userAgent.getValue("Combined3"));
    fc = new ConcatNONDuplicatedCalculator("Combined4", "NonExistent1", "NonExistent2");
    fc.calculate(userAgent);
    assertEquals("Unknown", userAgent.getValue("Combined4"));
}
Also used : MutableUserAgent(nl.basjes.parse.useragent.UserAgent.MutableUserAgent) FieldCalculator(nl.basjes.parse.useragent.calculate.FieldCalculator) ConcatNONDuplicatedCalculator(nl.basjes.parse.useragent.calculate.ConcatNONDuplicatedCalculator) Test(org.junit.jupiter.api.Test)

Aggregations

FieldCalculator (nl.basjes.parse.useragent.calculate.FieldCalculator)6 MutableUserAgent (nl.basjes.parse.useragent.UserAgent.MutableUserAgent)5 ConcatNONDuplicatedCalculator (nl.basjes.parse.useragent.calculate.ConcatNONDuplicatedCalculator)5 Test (org.junit.jupiter.api.Test)5 TreeSet (java.util.TreeSet)1 Matcher (nl.basjes.parse.useragent.analyze.Matcher)1