@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());
Profile local = existingProfiles.get(id); if (null != local) { Files.deleteIfExists(pathResolver.getProfileFilePath(local));
/** * Imports the profile. Note that if profile with the same id already exists it will be * overwritten. * * @param profile * Profile. * @return Returns created/updated profile depending if the overwrite was executed. * @throws BusinessException * If attempt is made to import common profile or profile without the id. * @throws IOException * If {@link IOException} occurs during save. * @throws JAXBException * If {@link JAXBException} occurs during save. */ public Profile importProfile(Profile profile) throws BusinessException, JAXBException, IOException { if (null == profile.getId()) { throw new BusinessException("Import the profile '" + profile.getName() + "'.", ConfigurationInterfaceErrorCodeEnum.IMPORT_DATA_NOT_VALID); } profile.setImportDate(new Date()); if (existingProfiles.containsKey(profile.getId())) { Profile old = existingProfiles.replace(profile.getId(), profile); Files.deleteIfExists(pathResolver.getProfileFilePath(old)); } else { existingProfiles.put(profile.getId(), profile); } saveProfile(profile); return profile; }
/** * Saves profile and persists it to the list. * * @param profile * Profile to be saved. * @throws IOException * If {@link IOException} occurs during save. * @throws JAXBException * If {@link JAXBException} occurs during save. * @throws BusinessException * If saving of the common profile is requested. */ private void saveProfile(Profile profile) throws BusinessException, JAXBException, IOException { if (profile.isCommonProfile()) { throw new BusinessException("Save the profile '" + profile.getName() + " to disk.", ConfigurationInterfaceErrorCodeEnum.COMMON_PROFILE_CAN_NOT_BE_ALTERED); } transformator.marshall(pathResolver.getProfileFilePath(profile), profile, getRelativeToSchemaPath(pathResolver.getProfilesPath()).toString(), ISchemaVersionAware.ConfigurationInterface.SCHEMA_VERSION); }
.resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getProfileFilePath((Profile) invocation.getArguments()[0]))); }).when(pathResolver).getProfileFilePath(Matchers.<Profile> any()); doAnswer(new Answer<Path>() { @Override
Files.deleteIfExists(pathResolver.getProfileFilePath(local));