Skip to content

Commit 42b6989

Browse files
author
Frode Sjovatsen
committed
refactoring + jenkins
1 parent c5fdada commit 42b6989

8 files changed

Lines changed: 52 additions & 83 deletions

File tree

FINT.Model.Resource.Test/FINT.Model.Resource.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<IsPackable>false</IsPackable>
55
</PropertyGroup>
66
<ItemGroup>
7+
<PackageReference Include="FINT.Model.Administrasjon" Version="2.7.0" />
78
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
89
<PackageReference Include="xunit" Version="2.2.0" />
910
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />

FINT.Model.Resource.Test/LinkTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ public class LinkTest
77
[Fact]
88
public void Create_Link_with_PersonResource_placeholder()
99
{
10-
var link = Link.with(typeof(PersonResource), new string[] { "/id" });
10+
var link = Link.with(typeof(PersonResource), new string[] { "id" });
1111

1212
Assert.Equal(link.href, "${test.person}/id");
1313
}
1414

1515
[Fact]
1616
public void Create_Link_with_Person_placeholder()
1717
{
18-
var link = Link.with(typeof(Person), new string[] { "/id" });
18+
var link = Link.with(typeof(Person), new string[] { "id" });
1919

2020
Assert.Equal(link.href, "${test.person}/id");
2121
}

FINT.Model.Resource.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
88
ProjectSection(SolutionItems) = preProject
99
README.md = README.md
1010
.gitignore = .gitignore
11+
Jenkinsfile = Jenkinsfile
12+
version.txt = version.txt
1113
EndProjectSection
1214
EndProject
1315
Global

FINT.Model.Resource/AbstractCollectionResources.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public abstract class AbstractCollectionResources<T>
1313
protected EmbeddedResources<T> Embedded = new EmbeddedResources<T>();
1414

1515
[JsonProperty(PropertyName = "total_items")]
16-
protected int TotalItems { get; set; }
16+
public int TotalItems { get; set; }
1717

1818

1919
[OnSerialized]
@@ -32,22 +32,11 @@ public List<Link> GetSelfLinks()
3232
return Links["self"];
3333
}
3434

35-
/*
36-
@JsonIgnore
37-
public List<T> getContent() {
38-
return new ObjectMapper().convertValue(embedded.entries, getTypeReference());
39-
}
40-
41-
@JsonIgnore
42-
public abstract TypeReference<List<T>> getTypeReference();
43-
*/
44-
4535
public List<T> GetContent()
4636
{
4737
return Embedded.Entries;
4838
}
4939

50-
5140
public class EmbeddedResources<T>
5241
{
5342
public EmbeddedResources()

FINT.Model.Resource/IFintLinks.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

FINT.Model.Resource/Link.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ namespace FINT.Model.Resource
55
{
66
public class Link
77
{
8-
private Link(string verdi)
8+
public Link()
99
{
10-
href = verdi;
1110
}
1211

13-
public string href { get; set; }
14-
15-
// TODO: Is this needed?
16-
public void setVerdi(string verdi)
12+
private Link(string verdi)
1713
{
1814
href = verdi;
1915
}
2016

17+
public string href { get; }
18+
2119
public static Link with(string verdi)
2220
{
2321
return new Link(verdi);
@@ -34,7 +32,7 @@ private static Link with(Type placeholderClass, string path)
3432
var regex = new Regex("^/");
3533
path = regex.Replace(path, "", 1);
3634

37-
return new Link(string.Format("${{{0}}}/{1}", placeholder, path));
35+
return new Link($"${{{placeholder}}}/{path}");
3836
}
3937

4038
private static string getHrefPlaceholder(Type placeholderClass)

Jenkinsfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
pipeline {
2+
agent none
3+
stages {
4+
stage('Build') {
5+
agent {
6+
docker {
7+
label 'docker'
8+
image 'microsoft/dotnet'
9+
}
10+
}
11+
steps {
12+
sh 'git clean -fdx'
13+
sh 'dotnet restore -s https://api.bintray.com/nuget/fint/nuget'
14+
sh 'dotnet build -c Release'
15+
sh 'dotnet pack -c Release'
16+
stash includes: '**/Release/*.nupkg', name: 'libs'
17+
}
18+
}
19+
20+
stage('Deploy') {
21+
agent {
22+
docker {
23+
label 'docker'
24+
image 'microsoft/dotnet'
25+
}
26+
}
27+
environment {
28+
BINTRAY = credentials('fint-bintray')
29+
}
30+
when {
31+
branch 'master'
32+
}
33+
steps {
34+
unstash 'libs'
35+
archiveArtifacts '**/*.nupkg'
36+
sh "dotnet nuget push FINT.Model.Resource/bin/Release/FINT.Model.Resource.*.nupkg -k ${BINTRAY} -s https://api.bintray.com/nuget/fint/nuget"
37+
}
38+
}
39+
}
40+
}

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

0 commit comments

Comments
 (0)