• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 9253732050

27 May 2024 11:03AM UTC coverage: 56.515% (-0.4%) from 56.916%
9253732050

Pull #1779

github

JFriel
revert change
Pull Request #1779: Task/rdmp 122 update a database extraction

10780 of 20550 branches covered (52.46%)

Branch coverage included in aggregate %.

50 of 58 new or added lines in 3 files covered. (86.21%)

369 existing lines in 20 files now uncovered.

30680 of 52811 relevant lines covered (58.09%)

7662.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.12
/Rdmp.Core/DataExport/DataRelease/ReleaseEnvironmentPotential.cs
1
// Copyright (c) The University of Dundee 2018-2019
2
// This file is part of the Research Data Management Platform (RDMP).
3
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
using System;
8
using System.Linq;
9
using System.Threading;
10
using Rdmp.Core.Curation.Data;
11
using Rdmp.Core.DataExport.Data;
12
using Rdmp.Core.Repositories;
13
using Rdmp.Core.ReusableLibraryCode.Checks;
14
using Rdmp.Core.Ticketing;
15

16
namespace Rdmp.Core.DataExport.DataRelease;
17

18
/// <summary>
19
/// Evaluates things that are not within the control area of the DataExportManager but which might prevent a release e.g. ticketing system is not available
20
///  / tickets in wrong status / safehaven down for maintencence etc.
21
/// </summary>
22
public class ReleaseEnvironmentPotential : ICheckable
23
{
24
    private readonly IDataExportRepository _repository;
25
    public IExtractionConfiguration Configuration { get; private set; }
14✔
26
    public IProject Project { get; private set; }
14✔
27

UNCOV
28
    public Exception Exception { get; private set; }
×
29
    public TicketingReleaseabilityEvaluation Assesment { get; private set; }
8✔
UNCOV
30
    public string Reason { get; private set; }
×
31

32

33
    public ReleaseEnvironmentPotential(IExtractionConfiguration configuration)
14✔
34
    {
35
        _repository = configuration.DataExportRepository;
14✔
36
        Configuration = configuration;
14✔
37
        Project = configuration.Project;
14✔
38
    }
14✔
39

40
    private void MakeAssessment()
41
    {
UNCOV
42
        Assesment = TicketingReleaseabilityEvaluation.TicketingLibraryMissingOrNotConfiguredCorrectly;
×
43

UNCOV
44
        var configuration = _repository.CatalogueRepository
×
UNCOV
45
            .GetAllObjectsWhere<TicketingSystemConfiguration>("IsActive", 1).SingleOrDefault();
×
UNCOV
46
        if (configuration == null) return;
×
47

48
        var factory = new TicketingSystemFactory(_repository.CatalogueRepository);
×
49

50

51
        ITicketingSystem ticketingSystem;
52
        try
53
        {
54
            ticketingSystem = factory.CreateIfExists(configuration);
×
55
        }
×
56
        catch (Exception e)
×
57
        {
58
            Assesment = TicketingReleaseabilityEvaluation.TicketingLibraryCrashed;
×
59
            Exception = e;
×
60
            return;
×
61
        }
62

63
        if (ticketingSystem == null)
×
64
            return;
×
65

66
        try
67
        {
68
            Assesment = ticketingSystem.GetDataReleaseabilityOfTicket(Project.MasterTicket,
×
69
                Configuration.RequestTicket, Configuration.ReleaseTicket, out var reason, out var e);
×
70
            Exception = e;
×
71
            Reason = reason;
×
72
        }
×
73
        catch (Exception e)
×
74
        {
75
            if (e is ThreadInterruptedException)
×
76
                throw;
×
77

78
            Assesment = TicketingReleaseabilityEvaluation.TicketingLibraryCrashed;
×
79
            Exception = e;
×
80
        }
×
81
    }
×
82

83
    public void Check(ICheckNotifier notifier)
84
    {
UNCOV
85
        MakeAssessment();
×
86

UNCOV
87
        var message = $"Environment Releasability is {Assesment}";
×
UNCOV
88
        if (!string.IsNullOrWhiteSpace(Reason))
×
89
            message += $" - {Reason}";
×
90

UNCOV
91
        notifier.OnCheckPerformed(new CheckEventArgs(message, GetCheckResultFor(Assesment), Exception));
×
UNCOV
92
    }
×
93

94
    private static CheckResult GetCheckResultFor(TicketingReleaseabilityEvaluation assesment)
95
    {
UNCOV
96
        return assesment switch
×
UNCOV
97
        {
×
98
            TicketingReleaseabilityEvaluation.TicketingLibraryCrashed => CheckResult.Fail,
×
99
            TicketingReleaseabilityEvaluation.CouldNotReachTicketingServer => CheckResult.Fail,
×
100
            TicketingReleaseabilityEvaluation.CouldNotAuthenticateAgainstServer => CheckResult.Fail,
×
101
            TicketingReleaseabilityEvaluation.NotReleaseable => CheckResult.Fail,
×
UNCOV
102
            TicketingReleaseabilityEvaluation.TicketingLibraryMissingOrNotConfiguredCorrectly => CheckResult.Warning,
×
103
            TicketingReleaseabilityEvaluation.Releaseable => CheckResult.Success,
×
104
            _ => throw new ArgumentOutOfRangeException(nameof(assesment))
×
UNCOV
105
        };
×
106
    }
107
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc