Search in sources :

Example 6 with InvalidParserConfigurationException

use of nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException in project yauaa by nielsbasjes.

the class TestVersionCollisionChecks method testBadVersion.

@Test
void testBadVersion() {
    InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, () -> UserAgentAnalyzer.newBuilder().dropDefaultResources().addResources("classpath*:Versions/BadVersion.yaml").delayInitialization().build());
    assertTrue(exception.getMessage().contains("Found unexpected config entry: bad"));
}
Also used : InvalidParserConfigurationException(nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException) Test(org.junit.jupiter.api.Test)

Example 7 with InvalidParserConfigurationException

use of nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException in project yauaa by nielsbasjes.

the class TestVersionCollisionChecks method testBadVersionNotMap.

@Test
void testBadVersionNotMap() {
    InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, () -> UserAgentAnalyzer.newBuilder().dropDefaultResources().addResources("classpath*:Versions/BadVersionNotMap.yaml").delayInitialization().build());
    assertTrue(exception.getMessage().contains("The value should be a string but it is a sequence"));
}
Also used : InvalidParserConfigurationException(nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException) Test(org.junit.jupiter.api.Test)

Example 8 with InvalidParserConfigurationException

use of nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException in project yauaa by nielsbasjes.

the class TestVersionCollisionChecks method testDifferentVersion.

@Test
void testDifferentVersion() {
    InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, () -> UserAgentAnalyzer.newBuilder().delayInitialization().addResources("classpath*:Versions/DifferentVersion.yaml").build());
    assertTrue(exception.getMessage().contains("Two different Yauaa versions have been loaded:"));
}
Also used : InvalidParserConfigurationException(nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException) Test(org.junit.jupiter.api.Test)

Example 9 with InvalidParserConfigurationException

use of nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException in project yauaa by nielsbasjes.

the class TestAnnotationBadUsages method testMissingTypeParameter.

@Test
void testMissingTypeParameter() {
    InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, MapperWithoutGenericType::new);
    assertEquals("Couldn't find the used generic type of the UserAgentAnnotationMapper.", exception.getMessage());
}
Also used : InvalidParserConfigurationException(nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException) Test(org.junit.jupiter.api.Test)

Example 10 with InvalidParserConfigurationException

use of nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException in project yauaa by nielsbasjes.

the class TestAnnotationBadUsages method testNoInit.

@Test
void testNoInit() {
    UserAgentAnnotationAnalyzer<String> userAgentAnalyzer = new UserAgentAnnotationAnalyzer<>();
    InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, () -> assertNull(userAgentAnalyzer.map("Foo")));
    assertEquals("[Map] The mapper instance is null.", exception.getMessage());
}
Also used : InvalidParserConfigurationException(nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException) Test(org.junit.jupiter.api.Test)

Aggregations

InvalidParserConfigurationException (nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException)35 Test (org.junit.jupiter.api.Test)24 YamlUtils.getKeyAsString (nl.basjes.parse.useragent.utils.YamlUtils.getKeyAsString)5 YamlUtils.getValueAsString (nl.basjes.parse.useragent.utils.YamlUtils.getValueAsString)5 YamlUtils.getExactlyOneNodeTuple (nl.basjes.parse.useragent.utils.YamlUtils.getExactlyOneNodeTuple)4 NodeTuple (org.yaml.snakeyaml.nodes.NodeTuple)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 ArrayList (java.util.ArrayList)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 Matcher (nl.basjes.parse.useragent.analyze.Matcher)2 ConfigLine (nl.basjes.parse.useragent.config.MatcherConfig.ConfigLine)2 YamlUtils.getValueAsMappingNode (nl.basjes.parse.useragent.utils.YamlUtils.getValueAsMappingNode)2 YamlUtils.getValueAsSequenceNode (nl.basjes.parse.useragent.utils.YamlUtils.getValueAsSequenceNode)2 MappingNode (org.yaml.snakeyaml.nodes.MappingNode)2 Node (org.yaml.snakeyaml.nodes.Node)2 SequenceNode (org.yaml.snakeyaml.nodes.SequenceNode)2