### Question:
StackServiceDirectory extends ServiceDirectory { @Override public String getAdvisorName(String serviceName) { if (getAdvisorFile() == null || serviceName == null) return null; File serviceDir = new File(getAbsolutePath()); File stackVersionDir = serviceDir.getParentFile().getParentFile(); File stackDir = stackVersionDir.getParentFile(); String stackName = stackDir.getName(); String versionString = stackVersionDir.getName().replaceAll("\\.", ""); String advisorClassName = stackName + versionString + serviceName + "ServiceAdvisor"; advisorClassName = advisorClassName.replaceAll("[^a-zA-Z0-9]+", ""); return advisorClassName; } StackServiceDirectory(String servicePath); @Nullable @Experimental(feature = ExperimentalFeature.CUSTOM_SERVICE_REPOS, comment = "Remove logic for handling custom service repos after enabling multi-mpack cluster deployment") RepositoryXml getRepoFile(); @Nullable @Experimental(feature = ExperimentalFeature.CUSTOM_SERVICE_REPOS, comment = "Remove logic for handling custom service repos after enabling multi-mpack cluster deployment") String getRepoDir(); @Override String getAdvisorName(String serviceName); @Override String getService(); @Override String getStack();  }### Answer:
@Test public void testValidServiceAdvisorClassName() throws Exception { String pathWithInvalidChars = "/Fake-Stack.Name/1.0/services/FAKESERVICE/"; String serviceNameValidChars = "FakeService"; String pathWithValidChars = "/FakeStackName/1.0/services/FAKESERVICE/"; String serviceNameInvalidChars = "Fake-Serv.ice"; String desiredServiceAdvisorName = "FakeStackName10FakeServiceServiceAdvisor"; MockStackServiceDirectory ssd1 = createStackServiceDirectory(pathWithInvalidChars); assertEquals(desiredServiceAdvisorName, ssd1.getAdvisorName(serviceNameValidChars)); MockStackServiceDirectory ssd2 = createStackServiceDirectory(pathWithValidChars); assertEquals(desiredServiceAdvisorName, ssd2.getAdvisorName(serviceNameInvalidChars)); MockStackServiceDirectory ssd3 = createStackServiceDirectory(pathWithInvalidChars); assertEquals(desiredServiceAdvisorName, ssd3.getAdvisorName(serviceNameInvalidChars)); MockStackServiceDirectory ssd4 = createStackServiceDirectory(pathWithValidChars); assertEquals(desiredServiceAdvisorName, ssd4.getAdvisorName(serviceNameValidChars)); }