### Question:
ModelValidationScriptService implements ScriptService { public EntityReference transformEntityReference(EntityReference sourceEntity) { if (this.entityNameValidationConfiguration.useTransformation() && this.entityNameValidationManager.getEntityReferenceNameStrategy() != null) { return this.entityNameValidationManager.getEntityReferenceNameStrategy().transform(sourceEntity); } else { return sourceEntity; } }  EntityNameValidationManager getManager(); EntityNameValidationConfiguration getConfiguration(); ReplaceCharacterEntityNameValidationConfiguration getReplaceCharacterEntityNameValidationConfiguration(); String transformName(String name); EntityReference transformEntityReference(EntityReference sourceEntity); String transformName(String name, String hint); EntityReference transformEntityReference(EntityReference sourceEntity, String hint); boolean isValid(String name); boolean isValid(EntityReference sourceEntity); boolean isValid(String name, String hint); boolean isValid(EntityReference sourceEntity, String hint);  }### Answer:
@Test public void transformEntityReference() { when(nameStrategyManager.getEntityReferenceNameStrategy()).thenReturn(nameStrategy); when(configuration.useTransformation()).thenReturn(true); assertSame(entityReferenceTarget, scriptService.transformEntityReference(entityReferenceSource)); verify(nameStrategy, times(1)).transform(entityReferenceSource); when(nameStrategyManager.getEntityReferenceNameStrategy()).thenReturn(null); assertSame(entityReferenceSource, scriptService.transformEntityReference(entityReferenceSource)); verify(nameStrategy, times(1)).transform(entityReferenceSource); when(nameStrategyManager.getEntityReferenceNameStrategy()).thenReturn(nameStrategy); when(configuration.useTransformation()).thenReturn(false); assertSame(entityReferenceSource, scriptService.transformEntityReference(entityReferenceSource)); verify(nameStrategy, times(1)).transform(entityReferenceSource); when(nameStrategyManager.getEntityReferenceNameStrategy()).thenReturn(null); when(configuration.useTransformation()).thenReturn(false); assertSame(entityReferenceSource, scriptService.transformEntityReference(entityReferenceSource)); verify(nameStrategy, times(1)).transform(entityReferenceSource); }
@Test public void transformSourceEntityWithHint() { when(nameStrategyManager.getEntityReferenceNameStrategy(HINT)).thenReturn(nameStrategy); when(configuration.useTransformation()).thenReturn(false); assertSame(entityReferenceTarget, scriptService.transformEntityReference(entityReferenceSource, HINT)); verify(nameStrategy, times(1)).transform(entityReferenceSource); verify(nameStrategyManager, never()).getEntityReferenceNameStrategy(); when(nameStrategyManager.getEntityReferenceNameStrategy(HINT)).thenReturn(null); when(configuration.useTransformation()).thenReturn(false); assertSame(entityReferenceSource, scriptService.transformEntityReference(entityReferenceSource, HINT)); verify(nameStrategy, times(1)).transform(entityReferenceSource); verify(nameStrategyManager, never()).getEntityReferenceNameStrategy(); when(nameStrategyManager.getEntityReferenceNameStrategy(HINT)).thenReturn(null); when(configuration.useTransformation()).thenReturn(true); assertSame(entityReferenceSource, scriptService.transformEntityReference(entityReferenceSource, HINT)); verify(nameStrategy, times(1)).transform(entityReferenceSource); verify(nameStrategyManager, never()).getEntityReferenceNameStrategy(); when(nameStrategyManager.getEntityReferenceNameStrategy(HINT)).thenReturn(nameStrategy); when(configuration.useTransformation()).thenReturn(true); assertSame(entityReferenceTarget, scriptService.transformEntityReference(entityReferenceSource, HINT)); verify(nameStrategy, times(2)).transform(entityReferenceSource); verify(nameStrategyManager, never()).getEntityReferenceNameStrategy(); }