Search in sources :

Example 11 with InvalidParserConfigurationException

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

the class TestAnnotationBadUsages method testNullInitAnalyzer.

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

Example 12 with InvalidParserConfigurationException

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

the class TestAnnotationSystem method testInaccessibleSetter.

@Test
void testInaccessibleSetter() {
    InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, InaccessibleSetterMapper::new);
    assertEquals("Method annotated with YauaaField is not public: inaccessibleSetter", exception.getMessage());
}
Also used : InvalidParserConfigurationException(nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException) Test(org.junit.jupiter.api.Test)

Example 13 with InvalidParserConfigurationException

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

the class TestAnnotationSystem method testImpossibleField.

@Test
void testImpossibleField() {
    InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, ImpossibleFieldMapper::new);
    assertEquals("We cannot provide these fields:[NielsBasjes]", exception.getMessage());
}
Also used : InvalidParserConfigurationException(nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException) Test(org.junit.jupiter.api.Test)

Example 14 with InvalidParserConfigurationException

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

the class TestAnnotationSystem method testNonVoidSetter.

@Test
void testNonVoidSetter() {
    InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, WrongReturnType::new);
    assertTrue(exception.getMessage().contains("the method [nonVoidSetter] has been annotated with YauaaField but it has the wrong method signature. " + "It must look like [ public void nonVoidSetter(TestRecord record, String value) ]"));
}
Also used : InvalidParserConfigurationException(nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException) Test(org.junit.jupiter.api.Test)

Example 15 with InvalidParserConfigurationException

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

the class TestAnnotationSystem method testInaccessibleSetterClass.

@Test
void testInaccessibleSetterClass() {
    PrivateTestRecord record = new PrivateTestRecord("Bla bla bla");
    InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, () -> new InaccessibleSetterMapperClass().enrich(record));
    assertEquals("The class nl.basjes.parse.useragent.annotate.TestAnnotationSystem.PrivateTestRecord is not public.", 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