@@ -0,0 +1,3277 @@
+package org.jtwig.functions.impl.structural;%0A%0Aimport com.google.common.base.Optional;%0Aimport org.jtwig.functions.FunctionRequest;%0Aimport org.jtwig.functions.impl.structural.exceptions.ParentFunctionOutsideBlockException;%0Aimport org.jtwig.functions.impl.structural.exceptions.ParentFunctionWithoutExtending;%0Aimport org.jtwig.render.context.model.BlockContext;%0Aimport org.jtwig.render.context.model.BlockDefinition;%0Aimport org.jtwig.render.context.model.BlockReference;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport static org.mockito.Mockito.*;%0A%0Apublic class ParentFunctionExceptionTest %7B%0A%0A    private ParentFunction underTest;%0A    private FunctionRequest request;%0A%0A    @Before%0A    public void prepareTestdata() %7B%0A        request = mock(FunctionRequest.class, RETURNS_DEEP_STUBS);%0A        underTest = new ParentFunction();%0A    %7D%0A    @Test(expected = ParentFunctionOutsideBlockException.class)%0A    public void getBlockIdentifierThrowsCorrectExceptionWhenOutsideOfBlock() %7B%0A        when(request.getRenderContext().getCurrent(BlockReference.class)).thenThrow(IllegalStateException.class);%0A%0A        underTest.execute(request);%0A    %7D%0A%0A    @Test(expected = ParentFunctionOutsideBlockException.class)%0A    public void getBlockContextThrowsCorrectExceptionWhenOutsideOfBlock() %7B%0A        BlockReference blockReferenceMock = mock(BlockReference.class);%0A        when(blockReferenceMock.getIdentifier()).thenReturn(%22ident%22);%0A%0A        when(request.getRenderContext().getCurrent(BlockReference.class)).thenReturn(blockReferenceMock);%0A        when(request.getRenderContext().getCurrent(BlockContext.class)).thenThrow(IllegalStateException.class);%0A%0A        underTest.execute(request);%0A    %7D%0A%0A    @Test(expected = ParentFunctionWithoutExtending.class)%0A    public void getParentBlockDefinitionThrowsCorrectExceptionWhenOutsideOfBlock() %7B%0A        BlockReference blockReferenceMock = mock(BlockReference.class);%0A        when(blockReferenceMock.getIdentifier()).thenReturn(%22ident%22);%0A%0A        BlockDefinition blockDefinitionMock = mock(BlockDefinition.class);%0A%0A        BlockContext blockContextMock = mock(BlockContext.class);%0A        when(blockContextMock.pollFirst(anyString())).thenReturn(Optional.of(blockDefinitionMock));%0A        when(blockContextMock.get(anyString())).thenReturn(Optional.%3CBlockDefinition%3Eabsent());%0A%0A        when(request.getRenderContext().getCurrent(BlockReference.class)).thenReturn(blockReferenceMock);%0A        when(request.getRenderContext().getCurrent(BlockContext.class)).thenReturn(blockContextMock);%0A%0A        underTest.execute(request);%0A    %7D%0A%0A    @Test(expected = ParentFunctionOutsideBlockException.class)%0A    public void pollCurrentBlockDefinitionThrowsCorrectExceptionWhenOutsideOfBlock() %7B%0A        BlockReference blockReferenceMock = mock(BlockReference.class);%0A        when(blockReferenceMock.getIdentifier()).thenReturn(%22ident%22);%0A%0A        BlockContext blockContextMock = mock(BlockContext.class);%0A        when(blockContextMock.pollFirst(anyString())).thenReturn(Optional.%3CBlockDefinition%3Eabsent());%0A%0A        when(request.getRenderContext().getCurrent(BlockReference.class)).thenReturn(blockReferenceMock);%0A        when(request.getRenderContext().getCurrent(BlockContext.class)).thenReturn(blockContextMock);%0A%0A        underTest.execute(request);%0A    %7D%0A%7D

add a test for the various wais the parent-function might fail