use of nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException in project yauaa by nielsbasjes.
the class TestAnnotationSystemAnonymous method testSetterFailure.
// ----------------------------------------------------------------
@Test
void testSetterFailure() {
InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, () -> record = new MyErrorMapper() {
// Called via the annotation
@SuppressWarnings("unused")
@YauaaField("DeviceClass")
public void failingSetter(TestRecord testRecord, String value) {
throw new IllegalStateException("Just testing the error handling");
}
}.enrich(record));
assertEquals("A problem occurred while calling the requested setter", exception.getMessage());
}
use of nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException in project yauaa by nielsbasjes.
the class TestAnnotationSystemAnonymous method testImpossibleField.
@Test
void testImpossibleField() {
InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, () -> record = new MyErrorMapper() {
// Called via the annotation
@SuppressWarnings("unused")
@YauaaField("NielsBasjes")
public void setImpossibleField(TestRecord testRecord, String value) {
fail("May NEVER call this method");
}
}.enrich(record));
assertEquals("We cannot provide these fields:[NielsBasjes]", exception.getMessage());
}
use of nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException in project yauaa by nielsbasjes.
the class TestVersionCollisionChecks method testDoubleLoadedResources.
@Test
void testDoubleLoadedResources() {
InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, () -> UserAgentAnalyzer.newBuilder().delayInitialization().addResources("classpath*:UserAgents/**/*.yaml").build());
assertTrue(exception.getMessage().startsWith("Trying to load "));
assertTrue(exception.getMessage().endsWith(" resources for the second time"));
}
use of nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException in project yauaa by nielsbasjes.
the class TestAnnotationSystem method testWrongTypeParameters2.
@Test
void testWrongTypeParameters2() {
InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, WrongTypeParameters2::new);
assertTrue(exception.getMessage().contains("the method [wrongSetter] has been annotated with YauaaField but it has the wrong method signature. " + "It must look like [ public void wrongSetter(TestRecord record, String value) ]"));
}
use of nl.basjes.parse.useragent.analyze.InvalidParserConfigurationException in project yauaa by nielsbasjes.
the class TestAnnotationSystem method testBadGeneric.
// ----------------------------------------------------------------
// Here we deliberately created some bad code to check the behavior.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
void testBadGeneric() {
UserAgentAnnotationAnalyzer userAgentAnalyzer = new UserAgentAnnotationAnalyzer();
InvalidParserConfigurationException exception = assertThrows(InvalidParserConfigurationException.class, () -> assertNull(userAgentAnalyzer.map("Foo")));
assertEquals("[Map] The mapper instance is null.", exception.getMessage());
}
Aggregations