### Question:
AbstractWritableScriptedDhisResource { @ScriptMethod( description = "Returns if the DHIS2 resource is new and has not yet been saved on DHIS2." ) public boolean isNewResource() { return getInternalResource().isNewResource(); } protected  AbstractWritableScriptedDhisResource( @Nonnull DhisResourceType resourceType, @Nonnull String resourceId, @Nonnull ScriptExecutionContext scriptExecutionContext ); protected  AbstractWritableScriptedDhisResource( @Nonnull DhisResource resource, @Nonnull ScriptExecutionContext scriptExecutionContext ); @Nullable @ScriptMethod( description = "Returns the ID of the DHIS2 resource. Return null if the instance is new." ) String getId(); @Nonnull DhisResourceType getResourceType(); @Nullable DhisResourceId getResourceId(); @ScriptMethod( description = "Returns if the DHIS2 resource is new and has not yet been saved on DHIS2." ) boolean isNewResource(); boolean isLocal(); boolean isDeleted(); @Nullable ZonedDateTime getLastUpdated(); @Nullable String getOrganizationUnitId(); @Nullable ScriptedTrackedEntityInstance getTrackedEntityInstance(); void validate();  }### Answer:
@Test public void isNewResourceUnloaded() { Mockito.doReturn( true ).when( dhisResource ).isNewResource(); final AbstractWritableScriptedDhisResource scriptedResource = new AbstractWritableScriptedDhisResource( DhisResourceType.TRACKED_ENTITY, "4711", scriptExecutionContext ) { @Override protected void load() { resource = dhisResource; } }; Assert.assertTrue( scriptedResource.isNewResource() ); Mockito.verify( dhisResource ).isNewResource(); }
@Test public void isDeletedUnloaded() { Mockito.doReturn( true ).when( dhisResource ).isNewResource(); final AbstractWritableScriptedDhisResource scriptedResource = new AbstractWritableScriptedDhisResource( dhisResource, scriptExecutionContext ) { @Override protected void load() { resource = dhisResource; } }; Assert.assertTrue( scriptedResource.isNewResource() ); Mockito.verify( dhisResource ).isNewResource(); }