Rename instances of Profile to QualityProfile

This commit is contained in:
Bogdan 2023-10-25 13:31:58 +03:00 committed by Mark McDowall
parent b06d5fb07b
commit 653aede0b7
9 changed files with 37 additions and 37 deletions

View File

@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test.Profiles
Subject.Handle(new ApplicationStartedEvent()); Subject.Handle(new ApplicationStartedEvent());
Mocker.GetMock<IProfileRepository>() Mocker.GetMock<IQualityProfileRepository>()
.Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Exactly(6)); .Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Exactly(6));
} }
@ -42,13 +42,13 @@ namespace NzbDrone.Core.Test.Profiles
// We don't want to keep adding them back if a user deleted them on purpose. // We don't want to keep adding them back if a user deleted them on purpose.
public void Init_should_skip_if_any_profiles_already_exist() public void Init_should_skip_if_any_profiles_already_exist()
{ {
Mocker.GetMock<IProfileRepository>() Mocker.GetMock<IQualityProfileRepository>()
.Setup(s => s.All()) .Setup(s => s.All())
.Returns(Builder<QualityProfile>.CreateListOfSize(2).Build().ToList()); .Returns(Builder<QualityProfile>.CreateListOfSize(2).Build().ToList());
Subject.Handle(new ApplicationStartedEvent()); Subject.Handle(new ApplicationStartedEvent());
Mocker.GetMock<IProfileRepository>() Mocker.GetMock<IQualityProfileRepository>()
.Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Never()); .Verify(v => v.Insert(It.IsAny<QualityProfile>()), Times.Never());
} }
@ -65,11 +65,11 @@ namespace NzbDrone.Core.Test.Profiles
.Build().ToList(); .Build().ToList();
Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList); Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList);
Mocker.GetMock<IProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile); Mocker.GetMock<IQualityProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
Assert.Throws<QualityProfileInUseException>(() => Subject.Delete(profile.Id)); Assert.Throws<QualityProfileInUseException>(() => Subject.Delete(profile.Id));
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never()); Mocker.GetMock<IQualityProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
} }
[Test] [Test]
@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.Profiles
Subject.Delete(1); Subject.Delete(1);
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(1), Times.Once()); Mocker.GetMock<IQualityProfileRepository>().Verify(c => c.Delete(1), Times.Once());
} }
[Test] [Test]
@ -103,7 +103,7 @@ namespace NzbDrone.Core.Test.Profiles
.Random(1) .Random(1)
.Build().ToList(); .Build().ToList();
Mocker.GetMock<IProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile); Mocker.GetMock<IQualityProfileRepository>().Setup(c => c.Get(profile.Id)).Returns(profile);
Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList); Mocker.GetMock<ISeriesService>().Setup(c => c.GetAllSeries()).Returns(seriesList);
Mocker.GetMock<IImportListFactory>() Mocker.GetMock<IImportListFactory>()
@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.Profiles
Assert.Throws<QualityProfileInUseException>(() => Subject.Delete(1)); Assert.Throws<QualityProfileInUseException>(() => Subject.Delete(1));
Mocker.GetMock<IProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never()); Mocker.GetMock<IQualityProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
} }
} }
} }

View File

@ -6,12 +6,12 @@ using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.Profiles.Qualities namespace NzbDrone.Core.Profiles.Qualities
{ {
public interface IProfileRepository : IBasicRepository<QualityProfile> public interface IQualityProfileRepository : IBasicRepository<QualityProfile>
{ {
bool Exists(int id); bool Exists(int id);
} }
public class QualityProfileRepository : BasicRepository<QualityProfile>, IProfileRepository public class QualityProfileRepository : BasicRepository<QualityProfile>, IQualityProfileRepository
{ {
private readonly ICustomFormatService _customFormatService; private readonly ICustomFormatService _customFormatService;

View File

@ -28,19 +28,19 @@ namespace NzbDrone.Core.Profiles.Qualities
IHandle<CustomFormatAddedEvent>, IHandle<CustomFormatAddedEvent>,
IHandle<CustomFormatDeletedEvent> IHandle<CustomFormatDeletedEvent>
{ {
private readonly IProfileRepository _profileRepository; private readonly IQualityProfileRepository _qualityProfileRepository;
private readonly IImportListFactory _importListFactory; private readonly IImportListFactory _importListFactory;
private readonly ICustomFormatService _formatService; private readonly ICustomFormatService _formatService;
private readonly ISeriesService _seriesService; private readonly ISeriesService _seriesService;
private readonly Logger _logger; private readonly Logger _logger;
public QualityProfileService(IProfileRepository profileRepository, public QualityProfileService(IQualityProfileRepository qualityProfileRepository,
IImportListFactory importListFactory, IImportListFactory importListFactory,
ICustomFormatService formatService, ICustomFormatService formatService,
ISeriesService seriesService, ISeriesService seriesService,
Logger logger) Logger logger)
{ {
_profileRepository = profileRepository; _qualityProfileRepository = qualityProfileRepository;
_importListFactory = importListFactory; _importListFactory = importListFactory;
_formatService = formatService; _formatService = formatService;
_seriesService = seriesService; _seriesService = seriesService;
@ -49,38 +49,38 @@ namespace NzbDrone.Core.Profiles.Qualities
public QualityProfile Add(QualityProfile profile) public QualityProfile Add(QualityProfile profile)
{ {
return _profileRepository.Insert(profile); return _qualityProfileRepository.Insert(profile);
} }
public void Update(QualityProfile profile) public void Update(QualityProfile profile)
{ {
_profileRepository.Update(profile); _qualityProfileRepository.Update(profile);
} }
public void Delete(int id) public void Delete(int id)
{ {
if (_seriesService.GetAllSeries().Any(c => c.QualityProfileId == id) || _importListFactory.All().Any(c => c.QualityProfileId == id)) if (_seriesService.GetAllSeries().Any(c => c.QualityProfileId == id) || _importListFactory.All().Any(c => c.QualityProfileId == id))
{ {
var profile = _profileRepository.Get(id); var profile = _qualityProfileRepository.Get(id);
throw new QualityProfileInUseException(profile.Name); throw new QualityProfileInUseException(profile.Name);
} }
_profileRepository.Delete(id); _qualityProfileRepository.Delete(id);
} }
public List<QualityProfile> All() public List<QualityProfile> All()
{ {
return _profileRepository.All().ToList(); return _qualityProfileRepository.All().ToList();
} }
public QualityProfile Get(int id) public QualityProfile Get(int id)
{ {
return _profileRepository.Get(id); return _qualityProfileRepository.Get(id);
} }
public bool Exists(int id) public bool Exists(int id)
{ {
return _profileRepository.Exists(id); return _qualityProfileRepository.Exists(id);
} }
public void Handle(ApplicationStartedEvent message) public void Handle(ApplicationStartedEvent message)

View File

@ -3,16 +3,16 @@ using NzbDrone.Core.Profiles.Qualities;
namespace NzbDrone.Core.Validation namespace NzbDrone.Core.Validation
{ {
public class ProfileExistsValidator : PropertyValidator public class QualityProfileExistsValidator : PropertyValidator
{ {
private readonly IQualityProfileService _qualityProfileService; private readonly IQualityProfileService _qualityProfileService;
public ProfileExistsValidator(IQualityProfileService qualityProfileService) public QualityProfileExistsValidator(IQualityProfileService qualityProfileService)
{ {
_qualityProfileService = qualityProfileService; _qualityProfileService = qualityProfileService;
} }
protected override string GetDefaultMessageTemplate() => "QualityProfile does not exist"; protected override string GetDefaultMessageTemplate() => "Quality Profile does not exist";
protected override bool IsValid(PropertyValidatorContext context) protected override bool IsValid(PropertyValidatorContext context)
{ {

View File

@ -11,7 +11,7 @@ namespace NzbDrone.Integration.Test.ApiTests
{ {
private void GivenExistingSeries() private void GivenExistingSeries()
{ {
WaitForCompletion(() => Profiles.All().Count > 0); WaitForCompletion(() => QualityProfiles.All().Count > 0);
foreach (var title in new[] { "90210", "Dexter" }) foreach (var title in new[] { "90210", "Dexter" })
{ {

View File

@ -12,7 +12,7 @@ namespace NzbDrone.Integration.Test.ApiTests.WantedTests
[Order(1)] [Order(1)]
public void cutoff_should_have_monitored_items() public void cutoff_should_have_monitored_items()
{ {
EnsureProfileCutoff(1, Quality.HDTV720p, true); EnsureQualityProfileCutoff(1, Quality.HDTV720p, true);
var series = EnsureSeries(266189, "The Blacklist", true); var series = EnsureSeries(266189, "The Blacklist", true);
EnsureEpisodeFile(series, 1, 1, Quality.SDTV); EnsureEpisodeFile(series, 1, 1, Quality.SDTV);
@ -25,7 +25,7 @@ namespace NzbDrone.Integration.Test.ApiTests.WantedTests
[Order(1)] [Order(1)]
public void cutoff_should_not_have_unmonitored_items() public void cutoff_should_not_have_unmonitored_items()
{ {
EnsureProfileCutoff(1, Quality.HDTV720p, true); EnsureQualityProfileCutoff(1, Quality.HDTV720p, true);
var series = EnsureSeries(266189, "The Blacklist", false); var series = EnsureSeries(266189, "The Blacklist", false);
EnsureEpisodeFile(series, 1, 1, Quality.SDTV); EnsureEpisodeFile(series, 1, 1, Quality.SDTV);
@ -38,7 +38,7 @@ namespace NzbDrone.Integration.Test.ApiTests.WantedTests
[Order(1)] [Order(1)]
public void cutoff_should_have_series() public void cutoff_should_have_series()
{ {
EnsureProfileCutoff(1, Quality.HDTV720p, true); EnsureQualityProfileCutoff(1, Quality.HDTV720p, true);
var series = EnsureSeries(266189, "The Blacklist", true); var series = EnsureSeries(266189, "The Blacklist", true);
EnsureEpisodeFile(series, 1, 1, Quality.SDTV); EnsureEpisodeFile(series, 1, 1, Quality.SDTV);
@ -52,7 +52,7 @@ namespace NzbDrone.Integration.Test.ApiTests.WantedTests
[Order(2)] [Order(2)]
public void cutoff_should_have_unmonitored_items() public void cutoff_should_have_unmonitored_items()
{ {
EnsureProfileCutoff(1, Quality.HDTV720p, true); EnsureQualityProfileCutoff(1, Quality.HDTV720p, true);
var series = EnsureSeries(266189, "The Blacklist", false); var series = EnsureSeries(266189, "The Blacklist", false);
EnsureEpisodeFile(series, 1, 1, Quality.SDTV); EnsureEpisodeFile(series, 1, 1, Quality.SDTV);

View File

@ -49,7 +49,7 @@ namespace NzbDrone.Integration.Test
public LogsClient Logs; public LogsClient Logs;
public ClientBase<NamingConfigResource> NamingConfig; public ClientBase<NamingConfigResource> NamingConfig;
public NotificationClient Notifications; public NotificationClient Notifications;
public ClientBase<QualityProfileResource> Profiles; public ClientBase<QualityProfileResource> QualityProfiles;
public ReleaseClient Releases; public ReleaseClient Releases;
public ReleasePushClient ReleasePush; public ReleasePushClient ReleasePush;
public ClientBase<RootFolderResource> RootFolders; public ClientBase<RootFolderResource> RootFolders;
@ -113,7 +113,7 @@ namespace NzbDrone.Integration.Test
Logs = new LogsClient(RestClient, ApiKey); Logs = new LogsClient(RestClient, ApiKey);
NamingConfig = new ClientBase<NamingConfigResource>(RestClient, ApiKey, "config/naming"); NamingConfig = new ClientBase<NamingConfigResource>(RestClient, ApiKey, "config/naming");
Notifications = new NotificationClient(RestClient, ApiKey); Notifications = new NotificationClient(RestClient, ApiKey);
Profiles = new ClientBase<QualityProfileResource>(RestClient, ApiKey); QualityProfiles = new ClientBase<QualityProfileResource>(RestClient, ApiKey);
Releases = new ReleaseClient(RestClient, ApiKey); Releases = new ReleaseClient(RestClient, ApiKey);
ReleasePush = new ReleasePushClient(RestClient, ApiKey); ReleasePush = new ReleasePushClient(RestClient, ApiKey);
RootFolders = new ClientBase<RootFolderResource>(RestClient, ApiKey); RootFolders = new ClientBase<RootFolderResource>(RestClient, ApiKey);
@ -317,10 +317,10 @@ namespace NzbDrone.Integration.Test
return result.EpisodeFile; return result.EpisodeFile;
} }
public QualityProfileResource EnsureProfileCutoff(int profileId, Quality cutoff, bool upgradeAllowed) public QualityProfileResource EnsureQualityProfileCutoff(int profileId, Quality cutoff, bool upgradeAllowed)
{ {
var needsUpdate = false; var needsUpdate = false;
var profile = Profiles.Get(profileId); var profile = QualityProfiles.Get(profileId);
if (profile.Cutoff != cutoff.Id) if (profile.Cutoff != cutoff.Id)
{ {
@ -336,7 +336,7 @@ namespace NzbDrone.Integration.Test
if (needsUpdate) if (needsUpdate)
{ {
profile = Profiles.Put(profile); profile = QualityProfiles.Put(profile);
} }
return profile; return profile;

View File

@ -11,13 +11,13 @@ namespace Sonarr.Api.V3.ImportLists
public static readonly ImportListResourceMapper ResourceMapper = new (); public static readonly ImportListResourceMapper ResourceMapper = new ();
public static readonly ImportListBulkResourceMapper BulkResourceMapper = new (); public static readonly ImportListBulkResourceMapper BulkResourceMapper = new ();
public ImportListController(IImportListFactory importListFactory, ProfileExistsValidator profileExistsValidator) public ImportListController(IImportListFactory importListFactory, QualityProfileExistsValidator qualityProfileExistsValidator)
: base(importListFactory, "importlist", ResourceMapper, BulkResourceMapper) : base(importListFactory, "importlist", ResourceMapper, BulkResourceMapper)
{ {
Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.QualityProfileId)); Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.QualityProfileId));
SharedValidator.RuleFor(c => c.RootFolderPath).IsValidPath(); SharedValidator.RuleFor(c => c.RootFolderPath).IsValidPath();
SharedValidator.RuleFor(c => c.QualityProfileId).SetValidator(profileExistsValidator); SharedValidator.RuleFor(c => c.QualityProfileId).SetValidator(qualityProfileExistsValidator);
} }
} }
} }

View File

@ -58,7 +58,7 @@ namespace Sonarr.Api.V3.Series
SeriesExistsValidator seriesExistsValidator, SeriesExistsValidator seriesExistsValidator,
SeriesAncestorValidator seriesAncestorValidator, SeriesAncestorValidator seriesAncestorValidator,
SystemFolderValidator systemFolderValidator, SystemFolderValidator systemFolderValidator,
ProfileExistsValidator profileExistsValidator, QualityProfileExistsValidator qualityProfileExistsValidator,
SeriesFolderAsRootFolderValidator seriesFolderAsRootFolderValidator) SeriesFolderAsRootFolderValidator seriesFolderAsRootFolderValidator)
: base(signalRBroadcaster) : base(signalRBroadcaster)
{ {
@ -83,7 +83,7 @@ namespace Sonarr.Api.V3.Series
.SetValidator(systemFolderValidator) .SetValidator(systemFolderValidator)
.When(s => !s.Path.IsNullOrWhiteSpace()); .When(s => !s.Path.IsNullOrWhiteSpace());
SharedValidator.RuleFor(s => s.QualityProfileId).SetValidator(profileExistsValidator); SharedValidator.RuleFor(s => s.QualityProfileId).SetValidator(qualityProfileExistsValidator);
PostValidator.RuleFor(s => s.Path).IsValidPath().When(s => s.RootFolderPath.IsNullOrWhiteSpace()); PostValidator.RuleFor(s => s.Path).IsValidPath().When(s => s.RootFolderPath.IsNullOrWhiteSpace());
PostValidator.RuleFor(s => s.RootFolderPath) PostValidator.RuleFor(s => s.RootFolderPath)