Skip to content

Commit 5a8ae2a

Browse files
authored
Merge pull request #249 from siemens/FinalTesting_8.0.0
Minor code corrections in all excs code level
2 parents f88fcaa + 75a9165 commit 5a8ae2a

20 files changed

+41
-46
lines changed

src/ArtifactoryUploader/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static class Program
3434
private static bool m_Verbose = false;
3535
public static Stopwatch UploaderStopWatch { get; set; }
3636
private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
37-
private static IEnvironmentHelper environmentHelper;
37+
private static IEnvironmentHelper environmentHelper= new EnvironmentHelper();
3838
static async Task Main(string[] args)
3939
{
4040
UploaderStopWatch = new Stopwatch();
@@ -82,7 +82,6 @@ static async Task Main(string[] args)
8282
var isValid = await artifactoryValidator.ValidateArtifactoryCredentials();
8383
if (isValid == -1)
8484
{
85-
environmentHelper = new EnvironmentHelper();
8685
environmentHelper.CallEnvironmentExit(-1);
8786
}
8887

src/LCT.APICommunications/DebianJfrogAPICommunication.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class DebianJfrogAPICommunication : JfrogApicommunication
2121

2222

2323
private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
24-
private static IEnvironmentHelper environmentHelper;
24+
private static IEnvironmentHelper environmentHelper = new EnvironmentHelper();
2525
private static int TimeoutInSec { get; set; }
2626
public DebianJfrogAPICommunication(string repoDomainName, string srcrepoName, ArtifactoryCredentials repoCredentials, int timeout) : base(repoDomainName, srcrepoName, repoCredentials, timeout)
2727
{
@@ -60,8 +60,7 @@ public override async Task<HttpResponseMessage> MoveFromRepo(ComponentsToArtifac
6060

6161
public override async Task<HttpResponseMessage> GetPackageInfo(ComponentsToArtifactory component)
6262
{
63-
HttpResponseMessage responseMessage = new HttpResponseMessage();
64-
environmentHelper = new EnvironmentHelper();
63+
HttpResponseMessage responseMessage = new HttpResponseMessage();
6564
var result = responseMessage;
6665
try
6766
{

src/LCT.APICommunications/NpmJfrogAPICommunication.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class NpmJfrogApiCommunication : JfrogApicommunication
2020
{
2121
private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
2222
private static int TimeoutInSec { get; set; }
23-
private static IEnvironmentHelper environmentHelper;
23+
private static IEnvironmentHelper environmentHelper = new EnvironmentHelper();
2424
public NpmJfrogApiCommunication(string repoDomainName, string srcrepoName, ArtifactoryCredentials repoCredentials, int timeout) : base(repoDomainName, srcrepoName, repoCredentials, timeout)
2525
{
2626
TimeoutInSec = timeout;
@@ -58,8 +58,7 @@ public override async Task<HttpResponseMessage> MoveFromRepo(ComponentsToArtifac
5858

5959
public override async Task<HttpResponseMessage> GetPackageInfo(ComponentsToArtifactory component)
6060
{
61-
HttpResponseMessage responseMessage = new HttpResponseMessage();
62-
environmentHelper = new EnvironmentHelper();
61+
HttpResponseMessage responseMessage = new HttpResponseMessage();
6362
var result = responseMessage;
6463
try
6564
{

src/LCT.APICommunications/NugetJfrogAPICommunication.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class NugetJfrogApiCommunication : JfrogApicommunication
2020
{
2121
private static int TimeoutInSec { get; set; }
2222
private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
23-
private static IEnvironmentHelper environmentHelper;
23+
private static IEnvironmentHelper environmentHelper = new EnvironmentHelper();
2424
public NugetJfrogApiCommunication(string repoDomainName, string srcrepoName, ArtifactoryCredentials repoCredentials,int timeout):base(repoDomainName,srcrepoName,repoCredentials,timeout)
2525
{
2626
TimeoutInSec = timeout;
@@ -59,7 +59,7 @@ public override async Task<HttpResponseMessage> MoveFromRepo(ComponentsToArtifac
5959
public override async Task<HttpResponseMessage> GetPackageInfo(ComponentsToArtifactory component)
6060
{
6161
HttpResponseMessage responseMessage = new HttpResponseMessage();
62-
environmentHelper = new EnvironmentHelper();
62+
6363
var result = responseMessage;
6464
try
6565
{

src/LCT.APICommunications/SW360Apicommunication.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class SW360Apicommunication : ISw360ApiCommunication
3939
private readonly string sw360UsersApi;
4040
private readonly int timeOut;
4141
private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42-
private static IEnvironmentHelper environmentHelper;
42+
private static IEnvironmentHelper environmentHelper = new EnvironmentHelper();
4343
#endregion
4444

4545
#region PUBLIC METHODS
@@ -61,8 +61,7 @@ public SW360Apicommunication(SW360ConnectionSettings sw360ConnectionSettings)
6161

6262
public async Task<string> GetProjects()
6363
{
64-
HttpClient httpClient = GetHttpClient();
65-
environmentHelper = new EnvironmentHelper();
64+
HttpClient httpClient = GetHttpClient();
6665
var result = string.Empty;
6766
try
6867
{
@@ -100,8 +99,7 @@ public async Task<HttpResponseMessage> GetProjectsByTag(string projectTag)
10099
public async Task<HttpResponseMessage> GetProjectById(string projectId)
101100
{
102101
HttpClient httpClient = GetHttpClient();
103-
HttpResponseMessage obj = new HttpResponseMessage();
104-
environmentHelper = new EnvironmentHelper();
102+
HttpResponseMessage obj = new HttpResponseMessage();
105103
var result = obj;
106104
string projectsByTagUrl = $"{sw360ProjectsApi}/{projectId}";
107105
try
@@ -126,8 +124,7 @@ public async Task<HttpResponseMessage> GetProjectById(string projectId)
126124

127125
public async Task<string> GetReleases()
128126
{
129-
HttpClient httpClient = GetHttpClient();
130-
environmentHelper = new EnvironmentHelper();
127+
HttpClient httpClient = GetHttpClient();
131128
var result = string.Empty;
132129
try
133130
{

src/LCT.Common.UTests/PipelineArtifactUploaderTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ public void UploadLogs_ShouldNotUpload_WhenInUnknownEnvironment()
6161

6262
// Act
6363
PipelineArtifactUploader.UploadLogs();
64-
string output = consoleOutput.ToString();
64+
string output = consoleOutput.ToString().Trim();
6565

6666
// Assert
67-
Assert.That(output, Is.Empty);
67+
Assert.AreNotEqual(output, "Uploading of SBOM is not supported.");
6868
}
6969

7070
[Test]
@@ -94,10 +94,10 @@ public void UploadBom_ShouldNotUpload_WhenInUnknownEnvironment()
9494

9595
// Act
9696
PipelineArtifactUploader.UploadBom();
97-
string output = consoleOutput.ToString();
97+
string output = consoleOutput.ToString().Trim();
9898

9999
// Assert
100-
Assert.That(output, Is.Empty);
100+
Assert.AreEqual(output, "Uploading of SBOM is not supported.");
101101
}
102102
}
103103
}

src/LCT.Common/EnvironmentHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class EnvironmentHelper : IEnvironmentHelper
1111
{
1212
public void CallEnvironmentExit(int code)
1313
{
14-
if (code == -1)
14+
if (code == -1 || code== 0)
1515
{
1616
PipelineArtifactUploader.UploadLogs();
1717
EnvironmentExit(code);

src/LCT.Common/SettingsManager.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class SettingsManager : ISettingsManager
2424
{
2525
public string BasePath { get; private set; } = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
2626
private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
27-
private static IEnvironmentHelper environmentHelper;
27+
private static IEnvironmentHelper environmentHelper = new EnvironmentHelper();
2828

2929
/// <summary>
3030
/// Reads the Configuration from input args and json setting file
@@ -42,9 +42,8 @@ public T ReadConfiguration<T>(string[] args, string jsonSettingsFileName)
4242
if (args?.Length == 0)
4343
{
4444
Logger.Debug($"Argument Count : {args.Length}");
45-
DisplayHelp();
46-
PipelineArtifactUploader.UploadArtifacts();
47-
Environment.Exit(0);
45+
DisplayHelp();
46+
environmentHelper.CallEnvironmentExit(0);
4847
}
4948
string settingsFilePath = GetConfigFilePathFromArgs(args, jsonSettingsFileName);
5049
Logger.Logger.Log(null, Level.Notice, $"Settings File: {settingsFilePath}", null);
@@ -213,8 +212,7 @@ private static void CheckForMissingParameter(CommonAppSettings appSettings, Prop
213212
}
214213

215214
if (!string.IsNullOrWhiteSpace(missingParameters.ToString()))
216-
{
217-
environmentHelper=new EnvironmentHelper();
215+
{
218216
ExceptionHandling.ArgumentException(missingParameters.ToString());
219217
environmentHelper.CallEnvironmentExit(-1);
220218
}

src/LCT.PackageIdentifier/AlpineProcesser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static Bom RemoveExcludedComponents(CommonAppSettings appSettings, Bom cy
8484
{
8585
componentForBOM = CommonHelper.RemoveExcludedComponents(componentForBOM, appSettings.SW360.ExcludeComponents, ref noOfExcludedComponents);
8686
dependenciesForBOM = CommonHelper.RemoveInvalidDependenciesAndReferences(componentForBOM, dependenciesForBOM);
87-
BomCreator.bomKpiData.ComponentsExcluded += noOfExcludedComponents;
87+
BomCreator.bomKpiData.ComponentsExcludedSW360 += noOfExcludedComponents;
8888

8989
}
9090
cycloneDXBOM.Components = componentForBOM;

src/LCT.PackageIdentifier/BomHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public void WriteBomKpiDataToConsole(BomKpiData bomKpiData)
4949
{CommonHelper.Convert(bomKpiData,nameof(bomKpiData.DevDependentComponents)),bomKpiData.DevDependentComponents},
5050
{CommonHelper.Convert(bomKpiData,nameof(bomKpiData.BundledComponents)),bomKpiData.BundledComponents},
5151
{CommonHelper.Convert(bomKpiData,nameof(bomKpiData.ComponentsExcluded)),bomKpiData.ComponentsExcluded},
52+
{CommonHelper.Convert(bomKpiData,nameof(bomKpiData.ComponentsExcludedSW360)),bomKpiData.ComponentsExcludedSW360},
5253
{CommonHelper.Convert(bomKpiData,nameof(bomKpiData.DuplicateComponents)),bomKpiData.DuplicateComponents},
5354
{CommonHelper.Convert(bomKpiData,nameof(bomKpiData.InternalComponents)),bomKpiData.InternalComponents},
5455
{CommonHelper.Convert(bomKpiData,nameof(bomKpiData.ThirdPartyRepoComponents)),bomKpiData.ThirdPartyRepoComponents},

0 commit comments

Comments
 (0)