use of alien4cloud.tosca.parser.ParsingContextExecution in project alien4cloud by alien4cloud.
the class ReferencedParserTest method referenceToMissingTypeShouldFail.
@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();
}
}
use of alien4cloud.tosca.parser.ParsingContextExecution in project alien4cloud by alien4cloud.
the class ParsingAspect method addToContext.
@Around("execution(* alien4cloud.tosca.parser.INodeParser.parse(..))")
public Object addToContext(ProceedingJoinPoint joinPoint) throws Throwable {
Object parsed = joinPoint.proceed();
if (parsed != null) {
Node node = (Node) joinPoint.getArgs()[0];
ParsingContextExecution context = (ParsingContextExecution) joinPoint.getArgs()[1];
context.getObjectToNodeMap().put(parsed, node);
}
return parsed;
}
Aggregations