Skip to content

Commit 7d5b105

Browse files
latest changes
1 parent 908af58 commit 7d5b105

File tree

6 files changed

+60
-27
lines changed

6 files changed

+60
-27
lines changed

src/LCT.Common.UTests/FolderActionTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public void CopyToTargetDirectory_PassingDirsWithFiles_ReturnSuccess()
7474
{
7575
//Arrange
7676
string sourcePath = $"{Path.GetTempPath()}\\SampleFolder";
77-
Directory.CreateDirectory(sourcePath);
78-
Directory.CreateDirectory(sourcePath +"\\SampleSubFolder");
77+
System.IO.Directory.CreateDirectory(sourcePath);
78+
System.IO.Directory.CreateDirectory(sourcePath +"\\SampleSubFolder");
7979
File.WriteAllText(sourcePath + "\\Sample.txt", "");
8080
string targetPath = $"{Path.GetTempPath()}/targetPath/";
8181
var folderAction = new FolderAction();

src/LCT.Common/CommonAppSettings.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,16 @@ public string InputFolder
228228
}
229229
set
230230
{
231-
if (AppDomain.CurrentDomain.FriendlyName.Contains("PackageIdentifier"))
231+
if (!AppDomain.CurrentDomain.FriendlyName.Contains("SW360PackageCreator") &&
232+
!AppDomain.CurrentDomain.FriendlyName.Contains("ArtifactoryUploader"))
232233
{
233234
folderAction.ValidateFolderPath(value);
234235
m_InputFolder = value;
235-
}else if (AppDomain.CurrentDomain.FriendlyName.Contains("SW360PackageCreator") &&
236+
}else if (AppDomain.CurrentDomain.FriendlyName.Contains("SW360PackageCreator") ||
236237
AppDomain.CurrentDomain.FriendlyName.Contains("ArtifactoryUploader"))
237238
{
238239
_fileOperations.ValidateFilePath(value);
239-
m_InputFolder= value;
240+
m_InputFolder = value;
240241
}
241242
}
242243
}

src/LCT.SW360PackageCreator.UTest/ComponentCreatorTest.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ public async Task CycloneDxBomParser_PassingFilePath_ReturnsComponentsExcludingD
270270
new Component() { Name = "newtonsoft",Version="3.1.18",Group="",Purl="pkg:nuget/newtonsoft@3.1.18",Properties = properties },
271271
};
272272

273-
CommonAppSettings CommonAppSettings = new CommonAppSettings();
273+
CommonAppSettings CommonAppSettings = new()
274+
{
275+
SW360 = new SW360()
276+
};
274277
List<ComparisonBomData> comparisonBomData = new List<ComparisonBomData>();
275278
comparisonBomData.Add(new ComparisonBomData());
276279
var sw360Service = new Mock<ISW360Service>();
@@ -592,7 +595,7 @@ public async Task TriggerFossologyProcess_ExceptionScenario_ReturnsEmptyUploadId
592595
.ThrowsAsync(new AggregateException());
593596

594597
// Act
595-
var uploadId = await ComponentCreator.TriggerFossologyProcess(item, sw360CreatorServiceMock.Object, new CommonAppSettings());
598+
var uploadId = await ComponentCreator.TriggerFossologyProcess(item, sw360CreatorServiceMock.Object, new CommonAppSettings() { SW360=new SW360()});
596599

597600
// Assert
598601
Assert.AreEqual(string.Empty, uploadId);
@@ -637,7 +640,7 @@ public async Task TriggerFossologyProcess_NonExceptionScenario_ReturnsUploadId()
637640

638641

639642
// Act
640-
var uploadId = await ComponentCreator.TriggerFossologyProcess(item, sw360CreatorServiceMock.Object, new CommonAppSettings());
643+
var uploadId = await ComponentCreator.TriggerFossologyProcess(item, sw360CreatorServiceMock.Object, new CommonAppSettings() { SW360 = new SW360() });
641644

642645
// Assert
643646
Assert.AreEqual("uploadId", uploadId);

src/LCT.SW360PackageCreator.UTest/CreatorHelperTest.cs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,15 @@ public void Test_WriteCreatorKpiDataToConsole()
102102
public void InitializeSw360ProjectService_ForGivenAppSeetings_ReturnsSw360ServiceObject()
103103
{
104104
// Arrange
105-
CommonAppSettings appSettings = new CommonAppSettings();
106-
appSettings.SW360.AuthTokenType = "Token";
107-
appSettings.SW360.Token = "uifhiopsjfposddkf[fopefp[ld[p[lfffuhdffdkf";
108-
appSettings.SW360.URL = "http://localhost:8090";
105+
CommonAppSettings appSettings = new CommonAppSettings()
106+
{
107+
SW360 = new SW360()
108+
{
109+
AuthTokenType = "Token",
110+
Token = "uifhiopsjfposddkf[fopefp[ld[p[lfffuhdffdkf",
111+
URL = "http://localhost:8090"
112+
}
113+
};
109114

110115
// Act
111116
ISw360ProjectService sw360ProjectService = CreatorHelper.InitializeSw360ProjectService(appSettings);
@@ -118,11 +123,16 @@ public void InitializeSw360ProjectService_ForGivenAppSeetings_ReturnsSw360Servic
118123
public void InitializeSw360CreatorService_ForGivenAppSettings_ReturnsSw360Creatorervice()
119124
{
120125
// Arrange
121-
CommonAppSettings appSettings = new CommonAppSettings();
122-
appSettings.SW360.AuthTokenType = "Token";
123-
appSettings.SW360.Token = "uifhiopsjfposddkf[fopefp[ld[p[lfffuhdffdkf";
124-
appSettings.SW360.URL = "http://localhost:8090";
125-
126+
CommonAppSettings appSettings = new CommonAppSettings()
127+
{
128+
SW360=new SW360()
129+
{
130+
AuthTokenType= "Token",
131+
Token= "uifhiopsjfposddkf[fopefp[ld[p[lfffuhdffdkf",
132+
URL = "http://localhost:8090"
133+
}
134+
};
135+
126136
// Act
127137
ISw360CreatorService sw360CreatorService = CreatorHelper.InitializeSw360CreatorService(appSettings);
128138

@@ -330,10 +340,15 @@ public void GetCreatorKpiData_UpdatedCompareBomData_ReturnsCreatorKpiData()
330340
public void WriteSourceNotFoundListToConsole_GetComparisionBomDatan_ReturnsNothing()
331341
{
332342
//Arrange
333-
CommonAppSettings appSettings = new CommonAppSettings();
334-
appSettings.SW360.AuthTokenType = "Token";
335-
appSettings.SW360.Token = "uifhiopsjfposddkf[fopefp[ld[p[lfffuhdffdkf";
336-
appSettings.SW360.URL = "http://localhost:8090";
343+
CommonAppSettings appSettings = new CommonAppSettings()
344+
{
345+
SW360 = new SW360()
346+
{
347+
AuthTokenType = "Token",
348+
Token = "uifhiopsjfposddkf[fopefp[ld[p[lfffuhdffdkf",
349+
URL = "http://localhost:8090"
350+
}
351+
};
337352

338353
List<ComparisonBomData> compareBomData = new List<ComparisonBomData>();
339354
compareBomData.Add(new ComparisonBomData()

src/LCT.SW360PackageCreator.UTest/CreatorValidatorTest.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ public async Task ValidateAppSettings_TestPositive()
3131
//Arrange
3232
string projectName = "Test";
3333
ProjectReleases projectReleases=new ProjectReleases();
34-
var CommonAppSettings = new CommonAppSettings();
35-
CommonAppSettings.SW360.ProjectName = "Test";
34+
var CommonAppSettings = new CommonAppSettings()
35+
{
36+
SW360 = new SW360()
37+
{
38+
ProjectName = "Test"
39+
}
40+
};
3641
mockISw360ProjectService.Setup(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny<String>(), It.IsAny<string>(), projectReleases))
3742
.ReturnsAsync(projectName);
3843

@@ -50,8 +55,14 @@ public async Task ValidateAppSettings_OnClosedProject_EndsTheApplication()
5055
string projectName = "Test";
5156
ProjectReleases projectReleases = new ProjectReleases();
5257
projectReleases.clearingState = "CLOSED";
53-
var CommonAppSettings = new CommonAppSettings();
54-
CommonAppSettings.SW360.ProjectName = "Test";
58+
var CommonAppSettings = new CommonAppSettings()
59+
{
60+
SW360 = new SW360()
61+
{
62+
ProjectName= "Test"
63+
}
64+
};
65+
5566
mockISw360ProjectService.Setup(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny<String>(), It.IsAny<string>(), projectReleases))
5667
.ReturnsAsync(projectName);
5768

@@ -69,7 +80,10 @@ public void ValidateAppSettings_TestNegative()
6980
//Arrange
7081
string projectName = null;
7182
ProjectReleases projectReleases = new ProjectReleases();
72-
var CommonAppSettings = new CommonAppSettings();
83+
var CommonAppSettings = new CommonAppSettings()
84+
{
85+
SW360=new SW360()
86+
};
7387
mockISw360ProjectService.Setup(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny<string>(), It.IsAny<string>(),projectReleases))
7488
.ReturnsAsync(projectName);
7589

src/LCT.SW360PackageCreator/CreatorHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ private async Task<List<ComparisonBomData>> GetComparisionBomItems(List<Componen
249249
mapper.DownloadUrl = GetMavenDownloadUrl(mapper, item, releasesInfo);
250250
}
251251
else if (!string.IsNullOrEmpty(item.ReleaseExternalId) &&
252-
(item.ReleaseExternalId.Contains(Dataconstant.PurlCheck()["PYTHON"]) || item.ReleaseExternalId.Contains(Dataconstant.PurlCheck()["CONAN"]) || item.ReleaseExternalId.Contains(Dataconstant.PurlCheck()["ALPINE"])))
252+
(item.ReleaseExternalId.Contains(Dataconstant.PurlCheck()["POETRY"]) || item.ReleaseExternalId.Contains(Dataconstant.PurlCheck()["CONAN"]) || item.ReleaseExternalId.Contains(Dataconstant.PurlCheck()["ALPINE"])))
253253
{
254254
mapper.DownloadUrl = mapper.SourceUrl;
255255
}

0 commit comments

Comments
 (0)