/** * Returns path pointing to the environment file. * * @param environment * {@link Environment} * @return Path to the file. */ public Path getEnvironmentFilePath(Environment environment) { String secureEnvironmentName = removeIllegalFilenameCharacters(environment.getName()); String fileName = environment.getId() + "-" + secureEnvironmentName + ".xml"; return getEnvironmentPath().resolve(fileName); }
/** * Saves {@link Environment} to the disk. * * @param environment * {@link Environment} to save. * @throws IOException * If {@link IOException} occurs. * @throws JAXBException * If {@link JAXBException} occurs. If saving fails. */ private void saveEnvironment(Environment environment) throws JAXBException, IOException { transformator.marshall(pathResolver.getEnvironmentFilePath(environment), environment, getRelativeToSchemaPath(pathResolver.getEnvironmentPath()).toString(), ISchemaVersionAware.ConfigurationInterface.SCHEMA_VERSION); }
@Override public Path answer(InvocationOnMock invocation) throws Throwable { return Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getEnvironmentPath())) .resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getProfileFilePath((Profile) invocation.getArguments()[0]))); } }).when(pathResolver).getProfileFilePath(Matchers.<Profile> any());
@Override public Path answer(InvocationOnMock invocation) throws Throwable { return Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getEnvironmentPath())) .resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getEnvironmentFilePath((Environment) invocation.getArguments()[0]))); } }).when(pathResolver).getEnvironmentFilePath(Matchers.<Environment> any());
existingEnvironments = new ConcurrentHashMap<>(16, 0.75f, 2); Path path = pathResolver.getEnvironmentPath(); final Path schemaPath = pathResolver.getSchemaPath();
when(pathResolver.getDefaultCiPath()).thenReturn(Paths.get(TEST_FOLDER)); when(pathResolver.getAgentMappingFilePath()).thenReturn(Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getAgentMappingFilePath()))); when(pathResolver.getEnvironmentPath()).thenReturn(Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getEnvironmentPath()))); when(pathResolver.getProfilesPath()).thenReturn(Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getProfilesPath()))); when(pathResolver.getSchemaPath()).thenReturn(Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getSchemaPath())));