Search in sources :

Example 6 with MutableAgentField

use of nl.basjes.parse.useragent.AgentField.MutableAgentField in project yauaa by nielsbasjes.

the class TestUseragent method testCopying.

@Test
void testCopying() {
    MutableAgentField origNull = new MutableAgentField(null);
    origNull.setValue("One", 1);
    // Different default!
    MutableAgentField copyNull = new MutableAgentField("Foo");
    assertTrue(copyNull.setValue(origNull));
    assertEquals("One", copyNull.getValue());
    assertEquals(1, copyNull.getConfidence());
    copyNull.reset();
    // The default should NOT be modified
    assertEquals("Foo", copyNull.getValue());
    assertEquals(-1, copyNull.getConfidence());
    MutableAgentField origFoo = new MutableAgentField("Foo");
    origFoo.setValue("Two", 2);
    // Different default!
    MutableAgentField copyFoo = new MutableAgentField(null);
    copyFoo.setValue(origFoo);
    assertEquals("Two", copyFoo.getValue());
    assertEquals(2, copyFoo.getConfidence());
    copyFoo.reset();
    // The default should NOT be modified
    assertNull(copyFoo.getValue());
    assertEquals(-1, copyFoo.getConfidence());
}
Also used : MutableAgentField(nl.basjes.parse.useragent.AgentField.MutableAgentField) Test(org.junit.jupiter.api.Test)

Aggregations

MutableAgentField (nl.basjes.parse.useragent.AgentField.MutableAgentField)6 Test (org.junit.jupiter.api.Test)5 MutableUserAgent (nl.basjes.parse.useragent.UserAgent.MutableUserAgent)4 ImmutableUserAgent (nl.basjes.parse.useragent.UserAgent.ImmutableUserAgent)2