@Test public void referenceToMissingTypeShouldFail() { ReferencedParser referencedParser = new ReferencedParser("missingParser"); ParsingContextExecution contextExecution = new ParsingContextExecution(); try { contextExecution.init(); contextExecution.setRegistry(Maps.newHashMap()); Node node = Mockito.mock(Node.class); Mockito.when(node.getStartMark()).thenReturn(new Mark("name", 0, 10, 10, "", 0)); Mockito.when(node.getEndMark()).thenReturn(new Mark("name", 0, 10, 10, "", 0)); referencedParser.parse(node, contextExecution); assertEquals(ParsingErrorLevel.ERROR, contextExecution.getParsingErrors().get(0).getErrorLevel()); assertEquals(ErrorCode.ALIEN_MAPPING_ERROR, contextExecution.getParsingErrors().get(0).getErrorCode()); } finally { ParsingContextExecution.destroy(); } }
@Override public T parse(Node node, ParsingContextExecution context) { INodeParser<?> delegate = context.getRegistry().get(typeName); if (delegate == null) { log.error("No parser found for yaml type {}", typeName); context.getParsingErrors().add( new ParsingError(ErrorCode.ALIEN_MAPPING_ERROR, "No parser found for yaml type", node.getStartMark(), "", node.getEndMark(), typeName)); return null; } return (T) delegate.parse(node, context); }
ReferencedParser implements INodeParser<T> { @Override public T parse(Node node, ParsingContextExecution context) { INodeParser<?> delegate = context.getRegistry().get(typeName); if (delegate == null) { log.error("No parser found for yaml type {}", typeName); context.getParsingErrors().add( new ParsingError(ErrorCode.ALIEN_MAPPING_ERROR, "No parser found for yaml type", node.getStartMark(), "", node.getEndMark(), typeName)); return null; } return (T) delegate.parse(node, context); } }
ReferencedParser implements INodeParser<T> { @Override public T parse(Node node, ParsingContextExecution context) { INodeParser<?> delegate = context.getRegistry().get(typeName); if (delegate == null) { log.error("No parser found for yaml type {}", typeName); context.getParsingErrors().add( new ParsingError(ErrorCode.ALIEN_MAPPING_ERROR, "No parser found for yaml type", node.getStartMark(), "", node.getEndMark(), typeName)); return null; } return (T) delegate.parse(node, context); } ReferencedParser(String typeName); }
ReferencedParser implements INodeParser<T> { @Override public T parse(Node node, ParsingContextExecution context) { INodeParser<?> delegate = context.getRegistry().get(typeName); if (delegate == null) { log.error("No parser found for yaml type {}", typeName); context.getParsingErrors().add( new ParsingError(ErrorCode.ALIEN_MAPPING_ERROR, "No parser found for yaml type", node.getStartMark(), "", node.getEndMark(), typeName)); return null; } return (T) delegate.parse(node, context); } ReferencedParser(String typeName); @Override T parse(Node node, ParsingContextExecution context); }
ReferencedParser implements INodeParser<T> { @Override public T parse(Node node, ParsingContextExecution context) { INodeParser<?> delegate = context.getRegistry().get(typeName); if (delegate == null) { log.error("No parser found for yaml type {}", typeName); context.getParsingErrors().add( new ParsingError(ErrorCode.ALIEN_MAPPING_ERROR, "No parser found for yaml type", node.getStartMark(), "", node.getEndMark(), typeName)); return null; } return (T) delegate.parse(node, context); } ReferencedParser(String typeName); @Override T parse(Node node, ParsingContextExecution context);  }