Search in sources :

Example 1 with ParsingContextExecution

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();
    }
}
Also used : ParsingContextExecution(alien4cloud.tosca.parser.ParsingContextExecution) Node(org.yaml.snakeyaml.nodes.Node) Mark(org.yaml.snakeyaml.error.Mark) Test(org.junit.Test)

Example 2 with ParsingContextExecution

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;
}
Also used : ParsingContextExecution(alien4cloud.tosca.parser.ParsingContextExecution) Node(org.yaml.snakeyaml.nodes.Node) Around(org.aspectj.lang.annotation.Around)

Aggregations

ParsingContextExecution (alien4cloud.tosca.parser.ParsingContextExecution)2 Node (org.yaml.snakeyaml.nodes.Node)2 Around (org.aspectj.lang.annotation.Around)1 Test (org.junit.Test)1 Mark (org.yaml.snakeyaml.error.Mark)1