Skip to content
Snippets Groups Projects
Commit f40190de authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

Merge branch 'Sprint/2020-19' into 'master'

Sprint/2020 19

See merge request coscine/cs/resourceconfiguration!6
parents 032f1d1a 69bd8992
No related branches found
No related tags found
1 merge request!6Sprint/2020 19
Pipeline #370657 passed
Showing
with 100 additions and 161 deletions
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ResourceConfiguration.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ResourceConfiguration.Test")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a09450a0-e4d7-43c1-b232-c6dba0aee139")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
<package id="NUnit" version="3.12.0" targetFramework="net461" />
<package id="NUnit3TestAdapter" version="3.13.0" targetFramework="net461" />
</packages>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Cake.
// </auto-generated>
//------------------------------------------------------------------------------
using System.Reflection;
[assembly: AssemblyTitle("ResourceConfiguration.Test")]
[assembly: AssemblyDescription("ResourceConfiguration.Test is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("ResourceConfiguration.Test")]
[assembly: AssemblyVersion("1.1.1")]
[assembly: AssemblyFileVersion("1.1.1")]
[assembly: AssemblyInformationalVersion("1.1.1-topic-1035-resou0002")]
[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.3.13.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.13.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.3.12.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
......@@ -9,8 +7,8 @@
<ProjectGuid>{A09450A0-E4D7-43C1-B232-C6DBA0AEE139}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Coscine.ResourceConfiguration.Test</RootNamespace>
<AssemblyName>Coscine.ResourceConfiguration.Test</AssemblyName>
<RootNamespace>Coscine.ResourceConfiguration.Tests</RootNamespace>
<AssemblyName>Coscine.ResourceConfiguration.Tests</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
......@@ -35,12 +33,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
......@@ -54,21 +46,22 @@
<Compile Include="ResourceConfigurationTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ResourceConfiguration\ResourceConfiguration.csproj">
<Project>{bd9e402e-5690-400a-897c-d157143489de}</Project>
<Name>ResourceConfiguration</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="NUnit">
<Version>3.12.0</Version>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter">
<Version>3.17.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.12.0\build\NUnit.props'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.13.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.13.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
</Project>
\ No newline at end of file
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using NUnit.Framework;
namespace Coscine.ResourceConfiguration.Test
namespace Coscine.ResourceConfiguration.Tests
{
[TestFixture]
public class ResourceConfigurationTest
......@@ -11,6 +10,7 @@ namespace Coscine.ResourceConfiguration.Test
public ResourceConfigurationTest()
{
}
[OneTimeSetUp]
......@@ -22,13 +22,13 @@ namespace Coscine.ResourceConfiguration.Test
[OneTimeTearDown]
public void End()
{
}
[Test]
public void TestConstructor()
{
Coscine.ResourceConfiguration.ResourceConfiguration resourceConfiguration = new Coscine.ResourceConfiguration.ResourceConfiguration();
}
[Test]
......@@ -39,12 +39,19 @@ namespace Coscine.ResourceConfiguration.Test
Assert.False(resourcenConfiguration.IsValidResource(_resourceTypeInvalid));
}
[Test]
public void TestGetResourceType()
{
Coscine.ResourceConfiguration.ResourceConfiguration resourcenConfiguration = new Coscine.ResourceConfiguration.ResourceConfiguration();
Assert.True(resourcenConfiguration.GetResourceType(_resourceTypeValid).GetType() == new ResourceTypeObject().GetType());
Assert.True(resourcenConfiguration.GetResourceType(_resourceTypeInvalid) == null);
}
[Test]
public void TestGetResourceTypes()
{
Coscine.ResourceConfiguration.ResourceConfiguration resourcenConfiguration = new Coscine.ResourceConfiguration.ResourceConfiguration();
Assert.True(resourcenConfiguration.GetResourceTypes(_resourceTypeValid).GetType() == new ResourceTypeObject().GetType());
Assert.True(resourcenConfiguration.GetResourceTypes(_resourceTypeInvalid) == null);
Assert.IsTrue(resourcenConfiguration.GetResourceTypesByStatus("active").Length == resourcenConfiguration.GetAvailableResourceTypes().Length);
}
......
......@@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.29911.84
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceConfiguration", "ResourceConfiguration\ResourceConfiguration.csproj", "{BD9E402E-5690-400A-897C-D157143489DE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceConfiguration.Test", "ResourceConfiguration.Test\ResourceConfiguration.Test.csproj", "{A09450A0-E4D7-43C1-B232-C6DBA0AEE139}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceConfiguration.Tests", "ResourceConfiguration.Tests\ResourceConfiguration.Tests.csproj", "{A09450A0-E4D7-43C1-B232-C6DBA0AEE139}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Cake.
// </auto-generated>
//------------------------------------------------------------------------------
using System.Reflection;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ResourceConfiguration")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyDescription("ResourceConfiguration is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("ResourceConfiguration")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.1.1")]
[assembly: AssemblyFileVersion("1.1.1")]
[assembly: AssemblyInformationalVersion("1.1.1-topic-1035-resou0002")]
[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("bd9e402e-5690-400a-897c-d157143489de")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Reflection;
......@@ -13,15 +9,13 @@ namespace Coscine.ResourceConfiguration
public class ResourceConfiguration
{
private readonly Dictionary<string, ResourceTypeObject> _types = new Dictionary<string, ResourceTypeObject>();
public static string EmbeddedResourceTypesPath { get; } = "Coscine.ResourceConfiguration.ResourceTypes.json";
public ResourceConfiguration()
{
var resourcetypesFileName = "Coscine.ResourceConfiguration.ResourceTypes.json";
var typesJSON = GetJSONFromAssembly(resourcetypesFileName);
foreach (var type in typesJSON)
foreach (var kv in GetJSONFromAssembly(EmbeddedResourceTypesPath))
{
_types.Add(type.Key, new ResourceTypeObject((JObject)type.Value));
_types.Add(kv.Key, kv.Value.ToObject<ResourceTypeObject>());
}
}
......@@ -43,7 +37,7 @@ namespace Coscine.ResourceConfiguration
return _types.ContainsKey(resourceType);
}
public ResourceTypeObject GetResourceTypes(string type)
public ResourceTypeObject GetResourceType(string type)
{
if (IsValidResource(type))
{
......@@ -52,6 +46,23 @@ namespace Coscine.ResourceConfiguration
return null;
}
public string[] GetResourceTypesByStatus(string status)
{
var list = new List<string>();
foreach (var key in _types.Keys)
{
if (_types[key].Status == status)
{
list.Add(key);
}
}
return list.ToArray();
}
public string[] GetAvailableResourceTypes()
{
return GetResourceTypesByStatus("active");
}
}
}
......@@ -31,9 +31,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
......@@ -49,8 +46,12 @@
<Compile Include="ResourceTypeObject.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<EmbeddedResource Include="ResourceTypes.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Coscine.ResourceConfiguration
{
......@@ -15,32 +9,5 @@ namespace Coscine.ResourceConfiguration
public string ClassName { get; set; }
public string Status { get; set; }
public Dictionary<string, string> Config { get; set; }
public Dictionary<string, string> Options { get; set; }
public ResourceTypeObject()
{
}
public ResourceTypeObject(Dictionary<string, string> name, string path, string className, string status, Dictionary<string, string> config, Dictionary<string, string> options)
{
Name = name;
Path = path;
ClassName = className;
Status = status;
Config = config;
Options = options;
}
public ResourceTypeObject(JObject resourceData)
{
Name = resourceData["name"].ToObject<Dictionary<string, string>>();
Path = resourceData["path"].ToString();
ClassName = resourceData["className"].ToString();
Status = resourceData["status"].ToString();
Config = resourceData["config"].ToObject<Dictionary<string, string>>();
Options = resourceData["options"].ToObject<Dictionary<string, string>>();
}
}
}
......@@ -7,8 +7,7 @@
"path": "",
"className": "Full class name in the DLL",
"status": "active",
"config": {},
"options": {}
"config": {}
},
"rds": {
"name": {
......@@ -18,8 +17,7 @@
"path": "",
"className": "Full class name in the DLL",
"status": "active",
"config": {},
"options": {}
"config": {}
},
"s3": {
"name": {
......@@ -29,8 +27,7 @@
"path": "",
"className": "Full class name in the DLL",
"status": "hidden",
"config": {},
"options": {}
"config": {}
},
"gitlab": {
"name": {
......@@ -40,7 +37,16 @@
"path": "",
"className": "Full class name in the DLL",
"status": "hidden",
"config": {},
"options": {}
"config": {}
},
"testResource": {
"name": {
"de": "Test Resource",
"en": "Test Resource"
},
"path": "Should not be needed",
"className": "ResourceTypeTest",
"status": "hidden",
"config": {}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
</packages>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.38.4" />
</packages>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment