Skip to content

Commit

Permalink
[Add] integration test to add a Person to a SiteDirectory on an OCDT WSP
Browse files Browse the repository at this point in the history
  • Loading branch information
sam.gerene committed Jan 13, 2018
1 parent cd9550b commit a7ba1ff
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 55 deletions.
6 changes: 3 additions & 3 deletions CDP4ServicesDal.Tests/CdpServicesDalTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CdpServicesDalTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2017 RHEA System S.A.
// Copyright (c) 2017-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -312,7 +312,7 @@ public async Task Verify_that_multiple_read_requests_can_be_made_in_parallel()

var readresult = await dal.Read(siteDirectory, new CancellationToken());
}

/// <summary>
/// Set the credentials property so DAL appears to be open
/// </summary>
Expand All @@ -325,4 +325,4 @@ private void SetDalToBeOpen(CdpServicesDal dal)
credentialsProperty.SetValue(dal, this.credentials);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WSPPostOperationTestFixture.cs" company="RHEA S.A.">
// Copyright (c) 2015 RHEA S.A.
// <copyright file="WSPPostOperationTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion CDP4WspDal.NetCore.Tests/SessionTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="SessionTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015 RHEA System S.A.
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// -------------------------------------------------------------------------------------------------

Expand Down
88 changes: 62 additions & 26 deletions CDP4WspDal.NetCore.Tests/WSPDalTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WSPDalTestFixture.cs" company="RHEA S.A.">
// Copyright (c) 2015 RHEA S.A.
// <copyright file="WSPDalTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand All @@ -24,7 +24,7 @@ namespace CDP4WspDal.Tests
using CDP4Dal.Operations;
using CDP4WspDal;
using NUnit.Framework;

using File = System.IO.File;
using Thing = CDP4Common.CommonData.Thing;

Expand All @@ -48,7 +48,7 @@ public class WspDalTestFixture
private IterationSetup iterationSetup;
private SiteReferenceDataLibrary siteReferenceDataLibrary;
private ModelReferenceDataLibrary modelReferenceDataLibrary;

[SetUp]
public void SetUp()
{
Expand All @@ -62,7 +62,7 @@ public void SetUp()
this.siteDirectory = new SiteDirectory(Guid.Parse("f13de6f8-b03a-46e7-a492-53b2f260f294"), this.session.Assembler.Cache, this.uri);
var lazySiteDirectory = new Lazy<Thing>(() => this.siteDirectory);
lazySiteDirectory.Value.Cache.TryAdd(new Tuple<Guid, Guid?>(lazySiteDirectory.Value.Iid, null), lazySiteDirectory);

this.PopulateSiteDirectory();
}

Expand Down Expand Up @@ -115,7 +115,7 @@ public async Task VerifyThatOpenReturnsDTOs()

Assert.AreEqual(60, amountOfDtos);
}

[Test]
public async Task VerifThatAClosedDalCannotBeClosedAgain()
{
Expand All @@ -131,7 +131,7 @@ public async Task VerifThatAClosedDalCannotBeClosedAgain()
public async Task VerifyThatIfCredentialsAreNullExceptionIsThrown()
{
var dal = new WspDal();

Assert.That(async () => await dal.Open(null, new CancellationToken()), Throws.TypeOf<NullReferenceException>());
}

Expand All @@ -142,10 +142,10 @@ public async Task VerifyThatIfNotHttpOrHttpsExceptionIsThrown()
var invalidCredentials = new Credentials("John", "a password", uri);

var dal = new WspDal();

Assert.That(async () => await dal.Open(invalidCredentials, new CancellationToken()), Throws.TypeOf<ArgumentException>());
}

[Test]
public async Task VerifyThatIfCredentialsAreNullOnReadExceptionIsThrown()
{
Expand All @@ -154,10 +154,10 @@ public async Task VerifyThatIfCredentialsAreNullOnReadExceptionIsThrown()
organizationDto.AddContainer(ClassKind.SiteDirectory, Guid.Parse("eb77f3e1-a0f3-412d-8ed6-b8ce881c0145"));

var dal = new WspDal();

Assert.That(async () => await dal.Read(organizationDto, new CancellationToken()), Throws.TypeOf<InvalidOperationException>());
}

[Test]
public void VerifyThatWriteThrowsException()
{
Expand Down Expand Up @@ -238,7 +238,7 @@ public async Task IntegrationTest()

foreach (var container in topcontainers)
{
returned = await this.dal.Read(container.Value.ToDto(),this.cancelationTokenSource.Token, attributes);
returned = await this.dal.Read(container.Value.ToDto(), this.cancelationTokenSource.Token, attributes);
await assembler.Synchronize(returned);
}
}
Expand All @@ -251,7 +251,7 @@ public void VerifyThatWSPPostBodyIsCorrectlyResolves()

var context = "/SiteDirectory/f289023d-41e8-4aaf-aae5-1be1ecf24bac";
var operationContainer = new OperationContainer(context);

var testDtoOriginal = new CDP4Common.DTO.Alias(iid: Guid.NewGuid(), rev: 1)
{
Content = "content",
Expand All @@ -260,7 +260,7 @@ public void VerifyThatWSPPostBodyIsCorrectlyResolves()
};
testDtoOriginal.AddContainer(ClassKind.DomainOfExpertise, domainOfExpertiseIid);
testDtoOriginal.AddContainer(ClassKind.SiteDirectory, siteDirecortoryIid);

var testDtoModified = new CDP4Common.DTO.Alias(iid: testDtoOriginal.Iid, rev: 1)
{
Content = "content2",
Expand Down Expand Up @@ -341,14 +341,14 @@ public void VerifyThatWSPPostBodyIsCorrectlyResolves()
[Category("WSP_dependent")]
public async Task VerifyThatReadIterationWorks()
{
var dal = new WspDal { Session = this.session};
var credentials = new Credentials("admin", "pass", new Uri("https://cdp4services-public.rheagroup.com"));
var dal = new WspDal { Session = this.session };
var credentials = new Credentials("admin", "pass", new Uri("https://cdp4services-public.rheagroup.com"));
var session = new Session(dal, credentials);

var returned = await dal.Open(credentials, this.cancelationTokenSource.Token);

session.Assembler.Synchronize(returned);
await session.Assembler.Synchronize(returned);

var siteDir = session.Assembler.RetrieveSiteDirectory();
var modelSetup = siteDir.Model.Single(x => x.ShortName == "LOFT");
var iterationSetup = modelSetup.IterationSetup.First();
Expand Down Expand Up @@ -426,13 +426,13 @@ public async Task VerifyThatFileCanBeUploaded()
var commonFileStoreModified = new CDP4Common.DTO.CommonFileStore(commonFileStoreIid, 0);
commonFileStoreModified.File.Add(fileIid);
commonFileStoreModified.AddContainer(ClassKind.EngineeringModel, engineeringModeliid);

var file = new CDP4Common.DTO.File(Guid.NewGuid(), 0);
file.Owner = domainOfExpertiseIid;
file.FileRevision.Add(fileRevisionIid);
file.AddContainer(ClassKind.CommonFileStore, commonFileStoreIid);
file.AddContainer(ClassKind.EngineeringModel, engineeringModeliid);

var fileRevision = new CDP4Common.DTO.FileRevision(Guid.NewGuid(), 0);
fileRevision.Name = "testfile";
fileRevision.ContentHash = contentHash;
Expand All @@ -441,10 +441,10 @@ public async Task VerifyThatFileCanBeUploaded()
fileRevision.AddContainer(ClassKind.File, fileIid);
fileRevision.AddContainer(ClassKind.CommonFileStore, commonFileStoreIid);
fileRevision.AddContainer(ClassKind.EngineeringModel, engineeringModeliid);

var context = string.Format("/EngineeringModel/{0}/iteration/{1}", engineeringModeliid, iterationiid);
var operationContainer = new OperationContainer(context);

var updateCommonFileStoreOperation = new Operation(commonFileStoreOriginal, commonFileStoreModified, OperationKind.Update);
operationContainer.AddOperation(updateCommonFileStoreOperation);

Expand Down Expand Up @@ -473,9 +473,45 @@ public void VerifyThatWritingMultipleOperationContainersIsNotSupported()

Assert.Throws<NotSupportedException>(() => dal.Write(operationContainers));

Assert.Throws<NotSupportedException>(() => dal.Write(operationContainers));
Assert.Throws<NotSupportedException>(() => dal.Write(operationContainers));
}


[Test]
[Category("WSP_dependent")]
public async Task Verify_that_person_can_be_Posted()
{
var uri = new Uri("http://ocdt-dev.rheagroup.com");
var credentials = new Credentials("admin", "Dahubo12", uri);

var wspdal = new WspDal();
var dtos = await wspdal.Open(credentials, this.cancelationTokenSource.Token);

var siteDirectory = (CDP4Common.DTO.SiteDirectory)dtos.Single(x => x.ClassKind == ClassKind.SiteDirectory);

var context = siteDirectory.Route;
var operationContainer = new OperationContainer(context, siteDirectory.RevisionNumber);

var person = new CDP4Common.DTO.Person(Guid.NewGuid(), 1);
person.ShortName = Guid.NewGuid().ToString();
person.Surname = Guid.NewGuid().ToString();
person.GivenName = Guid.NewGuid().ToString();
person.AddContainer(ClassKind.SiteDirectory, Guid.Parse("eb77f3e1-a0f3-412d-8ed6-b8ce881c0145"));

var operation1 = new Operation(null, person, OperationKind.Create);
operationContainer.AddOperation(operation1);

var siteDirectoryClone = siteDirectory.DeepClone<CDP4Common.DTO.SiteDirectory>();
siteDirectoryClone.Person.Add(person.Iid);
var operation2 = new Operation(siteDirectory, siteDirectoryClone, OperationKind.Update);
operationContainer.AddOperation(operation2);

var result = await wspdal.Write(operationContainer);

var resultPerson = (CDP4Common.DTO.Person)result.Single(x => x.Iid == person.Iid);

Assert.NotNull(resultPerson);
}

/// <summary>
/// Set the credentials property so DAL appears to be open
/// </summary>
Expand All @@ -501,4 +537,4 @@ private string GetAssemblyDirectory()
return directory;
}
}
}
}
4 changes: 2 additions & 2 deletions CDP4WspDal.NetCore.Tests/WSPUriQueryAttributeTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WSPUriQueryAttributeTestFixture.cs" company="RHEA S.A.">
// Copyright (c) 2015 RHEA S.A.
// <copyright file="WSPUriQueryAttributeTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WspCopyOperationHandlerTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015 RHEA System S.A.
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions CDP4WspDal.NetCore.Tests/WspOperationModifierTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WspOperationModifierTestFixture.cs" company="RHEA S.A.">
// Copyright (c) 2015 RHEA S.A.
// <copyright file="WspOperationModifierTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WspValueSetOperationCreatorTestFixture.cs" company="RHEA S.A.">
// Copyright (c) 2015 RHEA S.A.
// <copyright file="WspValueSetOperationCreatorTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion CDP4WspDal.Tests/Helper/StreamHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="StreamHelper.cs" company="RHEA System S.A.">
// Copyright (c) 2017 RHEA System S.A.
// Copyright (c) 2017-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions CDP4WspDal.Tests/Operations/WSPPostOperationTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WSPPostOperationTestFixture.cs" company="RHEA S.A.">
// Copyright (c) 2015 RHEA S.A.
// <copyright file="WSPPostOperationTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion CDP4WspDal.Tests/PostOperationTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="JsonDeserializerTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2017 RHEA System S.A.
// Copyright (c) 2017-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion CDP4WspDal.Tests/SessionTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
// <copyright file="SessionTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015 RHEA System S.A.
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// -------------------------------------------------------------------------------------------------

Expand Down
8 changes: 4 additions & 4 deletions CDP4WspDal.Tests/WSPDalTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WSPDalTestFixture.cs" company="RHEA S.A.">
// Copyright (c) 2015 RHEA S.A.
// <copyright file="WSPDalTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -347,7 +347,7 @@ public async Task VerifyThatReadIterationWorks()

var returned = await dal.Open(credentials, this.cancelationTokenSource.Token);

session.Assembler.Synchronize(returned);
await session.Assembler.Synchronize(returned);

var siteDir = session.Assembler.RetrieveSiteDirectory();
var modelSetup = siteDir.Model.Single(x => x.ShortName == "LOFT");
Expand Down Expand Up @@ -537,4 +537,4 @@ private string GetAssemblyDirectory()
return directory;
}
}
}
}
4 changes: 2 additions & 2 deletions CDP4WspDal.Tests/WSPUriQueryAttributeTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WSPUriQueryAttributeTestFixture.cs" company="RHEA S.A.">
// Copyright (c) 2015 RHEA S.A.
// <copyright file="WSPUriQueryAttributeTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion CDP4WspDal.Tests/WspCopyOperationHandlerTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WspCopyOperationHandlerTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015 RHEA System S.A.
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions CDP4WspDal.Tests/WspOperationModifierTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WspOperationModifierTestFixture.cs" company="RHEA S.A.">
// Copyright (c) 2015 RHEA S.A.
// <copyright file="WspOperationModifierTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions CDP4WspDal.Tests/WspValueSetOperationCreatorTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WspValueSetOperationCreatorTestFixture.cs" company="RHEA S.A.">
// Copyright (c) 2015 RHEA S.A.
// <copyright file="WspValueSetOperationCreatorTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2018 RHEA System S.A.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down

0 comments on commit a7ba1ff

Please sign in to comment.