Skip to content

Commit

Permalink
updates for COLID 2.11 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kanwalmeet committed Feb 10, 2023
1 parent 8174431 commit 1ccff50
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/COLID.Scheduler.Common/COLID.Scheduler.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.9" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
Expand Down
31 changes: 20 additions & 11 deletions src/COLID.Scheduler.Common/Constants/Metadata.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Microsoft.Extensions.Configuration;

namespace COLID.Scheduler.Common.Constants
{
public static class Metadata
{
public const string Author = "https://pid.bayer.com/kos/19050/author";
private static readonly string _basePath = Path.GetFullPath("appsettings.json");
private static readonly string _filePath = _basePath.Substring(0, _basePath.Length - 16);
private static IConfigurationRoot _configuration = new ConfigurationBuilder()
.SetBasePath(_filePath)
.AddJsonFile("appsettings.json")
.Build();
public static readonly string _serviceUrl = _configuration.GetValue<string>("ServiceUrl");

public const string LastChangeUser = "https://pid.bayer.com/kos/19050/lastChangeUser";
public static readonly string Author = _serviceUrl + "kos/19050/author";

public const string DataSteward = "https://pid.bayer.com/kos/19050/hasDataSteward";
public static readonly string LastChangeUser = _serviceUrl + "kos/19050/lastChangeUser";

public const string ContactPerson = "https://pid.bayer.com/kos/19050/hasContactPerson";
public static readonly string DataSteward = _serviceUrl + "kos/19050/hasDataSteward";

public const string ChangeRequester = "https://pid.bayer.com/kos/19050/546454";
public static readonly string ContactPerson = _serviceUrl + "kos/19050/hasContactPerson";

public const string ConsumerGroup = "https://pid.bayer.com/kos/19050#hasConsumerGroup";
public static readonly string ChangeRequester = _serviceUrl + "kos/19050/546454";

public const string InformationClassification = "https://pid.bayer.com/kos/19050/hasInformationClassification";
public static readonly string ConsumerGroup = _serviceUrl + "kos/19050#hasConsumerGroup";

public static readonly string InformationClassification = _serviceUrl + "kos/19050/hasInformationClassification";

public const string W3Type = "http://www/w3/org/1999/02/22-rdf-syntax-ns#type";

public const string LifecyleStatus = "https://pid.bayer.com/kos/19050/hasLifecycleStatus";
public static readonly string LifecyleStatus = _serviceUrl + "kos/19050/hasLifecycleStatus";

public static readonly string ConsumerGroupContact = _serviceUrl + "kos/19050/hasConsumerGroupContactPerson";

}
}
4 changes: 3 additions & 1 deletion src/COLID.Scheduler.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
"CorrelationId": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"ServiceUrl": "https://pid.bayer.com/",
"HttpServiceUrl": "http://pid.bayer.com/"
}
12 changes: 10 additions & 2 deletions tests/UnitTests/Builder/ContactBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using COLID.Scheduler.Common.DataModels;
using Microsoft.Extensions.Configuration;

namespace UnitTests.Builder
{
public class ContactBuilder
{
private ContactDto _contact = new ContactDto();

private static readonly string _basePath = Path.GetFullPath("appsettings.json");
private static readonly string _filePath = _basePath.Substring(0, _basePath.Length - 16);
private static IConfigurationRoot _configuration = new ConfigurationBuilder()
.SetBasePath(_filePath)
.AddJsonFile("appsettings.json")
.Build();
public static readonly string _serviceUrl = _configuration.GetValue<string>("ServiceUrl");
public ContactBuilder()
{
}
Expand All @@ -21,7 +29,7 @@ public ContactDto Build()
public ContactBuilder GenerateSampleData()
{
WithEmailAddress("[email protected]");
WithTypeUri(new Uri("https://pid.bayer.com/kos/19050/hasContactPerson"));
WithTypeUri(new Uri(_serviceUrl + "kos/19050/hasContactPerson"));
WithTypeLabel("Contact Person");
IsTechnical(false);
return this;
Expand Down
22 changes: 16 additions & 6 deletions tests/UnitTests/TestData.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using COLID.Scheduler.Common.DataModels;
using Microsoft.Extensions.Configuration;
using UnitTests.Builder;
using COLID.Scheduler.Common.Constants;

namespace UnitTests
{
public static class TestData
{
private static readonly string _basePath = Path.GetFullPath("appsettings.json");
private static readonly string _filePath = _basePath.Substring(0, _basePath.Length - 16);
private static IConfigurationRoot _configuration = new ConfigurationBuilder()
.SetBasePath(_filePath)
.AddJsonFile("appsettings.json")
.Build();
public static readonly string _serviceUrl = _configuration.GetValue<string>("ServiceUrl");
public static AdUserDto GenerateAdUser(bool enabled = true)
{
var id = Guid.NewGuid().ToString();
Expand All @@ -18,7 +28,7 @@ public static AdUserDto GenerateAdUser(bool enabled = true)
public static ColidEntryContactsDto GenerateColidEntryContacts(string colidEntryLabel, IEnumerable<ContactDto> contacts)
{
return new ColidEntryContactBuilder()
.WithPidUri($"https://pid.bayer.com/{Guid.NewGuid()}")
.WithPidUri($"{_serviceUrl}{Guid.NewGuid()}")
.WithLabel(colidEntryLabel)
.WithContacts(contacts)
.WithConsumerGroupContact(GenerateContactConsumerGroupAdmin())
Expand All @@ -45,7 +55,7 @@ public static ContactDto GenerateContactConsumerGroupAdmin()
{
return new ContactBuilder()
.WithEmailAddress("[email protected]")
.WithTypeUri("https://pid.bayer.com/kos/19050/hasConsumerGroupContactPerson")
.WithTypeUri(Metadata.ConsumerGroupContact)
.WithTypeLabel("Contact Person")
.Build();
}
Expand All @@ -54,7 +64,7 @@ public static ContactDto GenerateContactContactPerson(string email)
{
return new ContactBuilder()
.WithEmailAddress(email)
.WithTypeUri("https://pid.bayer.com/kos/19050/hasContactPerson")
.WithTypeUri(Metadata.ContactPerson)
.WithTypeLabel("Contact Person")
.IsTechnical(false)
.Build();
Expand All @@ -64,7 +74,7 @@ public static ContactDto GenerateContactLastChangeUser(string email)
{
return new ContactBuilder()
.WithEmailAddress(email)
.WithTypeUri("https://pid.bayer.com/kos/19050/lastChangeUser")
.WithTypeUri(Metadata.LastChangeUser)
.WithTypeLabel("Last Change User")
.IsTechnical(true)
.Build();
Expand All @@ -74,7 +84,7 @@ public static ContactDto GenerateContactAuthor(string email)
{
return new ContactBuilder()
.WithEmailAddress(email)
.WithTypeUri("https://pid.bayer.com/kos/19050/author")
.WithTypeUri(Metadata.Author)
.WithTypeLabel("Author")
.IsTechnical(true)
.Build();
Expand All @@ -84,7 +94,7 @@ public static ContactDto GenerateContactDataSteward(string email)
{
return new ContactBuilder()
.WithEmailAddress(email)
.WithTypeUri("https://pid.bayer.com/kos/19050/hasDataSteward")
.WithTypeUri(Metadata.DataSteward)
.WithTypeLabel("Data Steward")
.IsTechnical(false)
.Build();
Expand Down

0 comments on commit 1ccff50

Please sign in to comment.