### Question:
WritableScriptedDhisResource extends AbstractWritableScriptedDhisResource implements AccessibleScriptedDhisResource { @ScriptExecutionForbidden @Nonnull public DhisResource getDhisResource() { if ( scriptExecutionContext.hasScriptExecution() ) { throw new FatalTransformerException( "Resource instance cannot be accessed within script execution." ); } return getInternalResource(); } WritableScriptedDhisResource( @Nonnull DhisResource resource, @Nonnull ScriptExecutionContext scriptExecutionContext ); @ScriptExecutionForbidden @Nonnull DhisResource getDhisResource();  }### Answer:
@Test public void getDhisResource() { final TrackedEntityInstance resource = new TrackedEntityInstance(); final WritableScriptedDhisResource scriptedResource = new WritableScriptedDhisResource( resource, scriptExecutionContext ); Assert.assertSame( resource, scriptedResource.getDhisResource() ); }
@Test( expected = FatalTransformerException.class ) public void getDhisResourceScriptExecution() { Mockito.doReturn( true ).when( scriptExecutionContext ).hasScriptExecution(); final TrackedEntityInstance resource = new TrackedEntityInstance(); final WritableScriptedDhisResource scriptedResource = new WritableScriptedDhisResource( resource, scriptExecutionContext ); Assert.assertSame( resource, scriptedResource.getDhisResource() ); }