### Question:
ModelValidationScriptService implements ScriptService { public String transformName(String name) { if (this.entityNameValidationConfiguration.useTransformation() && this.entityNameValidationManager.getEntityReferenceNameStrategy() != null) { return this.entityNameValidationManager.getEntityReferenceNameStrategy().transform(name); } else { return name; } }  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 transformName() { when(nameStrategyManager.getEntityReferenceNameStrategy()).thenReturn(nameStrategy); when(configuration.useTransformation()).thenReturn(true); assertEquals(TRANSFORMED_NAME, scriptService.transformName(TEST_NAME)); verify(nameStrategy, times(1)).transform(TEST_NAME); when(nameStrategyManager.getEntityReferenceNameStrategy()).thenReturn(null); assertEquals(TEST_NAME, scriptService.transformName(TEST_NAME)); verify(nameStrategy, times(1)).transform(TEST_NAME); when(nameStrategyManager.getEntityReferenceNameStrategy()).thenReturn(nameStrategy); when(configuration.useTransformation()).thenReturn(false); assertEquals(TEST_NAME, scriptService.transformName(TEST_NAME)); verify(nameStrategy, times(1)).transform(TEST_NAME); when(nameStrategyManager.getEntityReferenceNameStrategy()).thenReturn(null); when(configuration.useTransformation()).thenReturn(false); assertEquals(TEST_NAME, scriptService.transformName(TEST_NAME)); verify(nameStrategy, times(1)).transform(TEST_NAME); }
@Test public void transformNameWithHint() { when(nameStrategyManager.getEntityReferenceNameStrategy(HINT)).thenReturn(nameStrategy); when(configuration.useTransformation()).thenReturn(false); assertEquals(TRANSFORMED_NAME, scriptService.transformName(TEST_NAME, HINT)); verify(nameStrategy, times(1)).transform(TEST_NAME); verify(nameStrategyManager, never()).getEntityReferenceNameStrategy(); when(nameStrategyManager.getEntityReferenceNameStrategy(HINT)).thenReturn(null); when(configuration.useTransformation()).thenReturn(false); assertEquals(TEST_NAME, scriptService.transformName(TEST_NAME, HINT)); verify(nameStrategy, times(1)).transform(TEST_NAME); verify(nameStrategyManager, never()).getEntityReferenceNameStrategy(); when(nameStrategyManager.getEntityReferenceNameStrategy(HINT)).thenReturn(null); when(configuration.useTransformation()).thenReturn(true); assertEquals(TEST_NAME, scriptService.transformName(TEST_NAME, HINT)); verify(nameStrategy, times(1)).transform(TEST_NAME); verify(nameStrategyManager, never()).getEntityReferenceNameStrategy(); when(nameStrategyManager.getEntityReferenceNameStrategy(HINT)).thenReturn(nameStrategy); when(configuration.useTransformation()).thenReturn(true); assertEquals(TRANSFORMED_NAME, scriptService.transformName(TEST_NAME, HINT)); verify(nameStrategy, times(2)).transform(TEST_NAME); verify(nameStrategyManager, never()).getEntityReferenceNameStrategy(); }