### Question:
AbstractCanonCommand implements CanonCommand<R>, TargetRefCommand<R> { protected final EdsBaseRef getTargetRefInternal() { if (targetRef == null) throw new IllegalStateException("TargetRef have not been set yet"); return targetRef; } protected  AbstractCanonCommand(); protected  AbstractCanonCommand(final AbstractCanonCommand<R> toCopy); @SuppressWarnings("unchecked") @Override AbstractCanonCommand<R> copy(); @Override final void run(); @Override CanonCommand<R> setTargetRef(final EdsBaseRef targetRef); final Optional<EdsBaseRef> getTargetRef(); @Override TargetRefType getTargetRefType(); @Override Instant getCreateTime(); @Override Instant getExecutionStartTime(); @Override boolean hasExecutionStarted(); @Override Instant getExecutionEndTime(); @Override boolean hasExecutionEnded(); @Override R get(); @Override Optional<Duration> getTimeout(); @Override CanonCommand<R> setTimeout(final Duration timeout);  }### Answer:
@Test void getTargetRefInternal() { final EdsdkLibrary.EdsImageRef targetRef = new EdsdkLibrary.EdsImageRef(); doNothingCommand.setTargetRef(targetRef); Assertions.assertNotNull(doNothingCommand.getTargetRefInternal()); Assertions.assertEquals(targetRef, doNothingCommand.getTargetRefInternal()); }
@Test void getTargetRefInternalThrowsIfNotSetYet() { Assertions.assertThrows(IllegalStateException.class, () -> doNothingCommand.getTargetRefInternal()); }