Skip to content

Commit

Permalink
[ODS-5988] Remove OdsInstance from Application (#837)
Browse files Browse the repository at this point in the history
* Remove ODSInstance from Application

* Remove test

* Package updates
  • Loading branch information
simpat-adam authored Sep 30, 2023
1 parent 191f026 commit eda2f09
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 83 deletions.
4 changes: 1 addition & 3 deletions Application/EdFi.Admin.DataAccess/Models/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public Application()
public string ClaimSetName { get; set; }

public virtual Vendor Vendor { get; set; }

public virtual OdsInstance OdsInstance { get; set; }


[StringLength(255)]
[Required]
public string OperationalContextUri { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Application/EdFi.Ods.Api/EdFi.Ods.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="7.1.6" />
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="7.1.7" />
<PackageReference Include="EdFi.Suite3.Security.DataAccess" Version="7.1.10" />
<PackageReference Include="EdFi.Suite3.Common" Version="7.1.2" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Application/EdFi.Ods.Sandbox/EdFi.Ods.Sandbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="7.1.6" />
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="7.1.7" />
<PackageReference Include="EdFi.Suite3.Common" Version="7.1.2" />
</ItemGroup>
</Otherwise>
Expand Down
2 changes: 1 addition & 1 deletion Application/EdFi.Ods.Tests/EdFi.Ods.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="7.1.6" />
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="7.1.7" />
<PackageReference Include="EdFi.Suite3.Common" Version="7.1.2" />
</ItemGroup>
</Otherwise>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- SPDX-License-Identifier: Apache-2.0
-- Licensed to the Ed-Fi Alliance under one or more agreements.
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
-- See the LICENSE and NOTICES files in the project root for more information.

IF OBJECT_ID('dbo.FK_Applications_OdsInstances', 'F') IS NOT NULL
BEGIN
ALTER TABLE [dbo].[Applications] DROP CONSTRAINT [FK_Applications_OdsInstances]
END

IF EXISTS (SELECT 1
FROM sys.indexes I
WHERE I.Name = 'IX_OdsInstance_OdsInstanceId' -- Index name
AND I.object_id = OBJECT_ID('dbo.Applications'))
BEGIN
DROP INDEX [IX_OdsInstance_OdsInstanceId] ON [dbo].[Applications]
END

IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Applications' AND COLUMN_NAME = 'OdsInstance_OdsInstanceId')
BEGIN
ALTER TABLE [dbo].[Applications] DROP COLUMN [OdsInstance_OdsInstanceId]
END
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- SPDX-License-Identifier: Apache-2.0
-- Licensed to the Ed-Fi Alliance under one or more agreements.
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
-- See the LICENSE and NOTICES files in the project root for more information.

ALTER TABLE dbo.Applications
DROP CONSTRAINT IF EXISTS FK_Applications_OdsInstances;

DROP INDEX IF EXISTS IX_OdsInstance_OdsInstanceId;

ALTER TABLE dbo.Applications
DROP COLUMN IF EXISTS OdsInstance_OdsInstanceId;
Original file line number Diff line number Diff line change
Expand Up @@ -238,81 +238,6 @@ public void Should_create_lea_association()
}
}

public class When_adding_an_ods_to_an_application : UserContextTestBase
{
private string vendorName;
private string appName;
private string odsName;
private string connectionString;
private const string ClaimSetName = "ClaimSet";

[OneTimeSetUp]
public new void Setup()
{
vendorName = string.Format("{0}_TestData", DateTime.Now.Ticks);
appName = string.Format("{0}_TestData", DateTime.Now.Ticks);
odsName = string.Format("{0}_TestData", DateTime.Now.Ticks);
connectionString = string.Format("{0}_TestData", DateTime.Now.Ticks);
}

[Test]
public void Should_create_ods_and_context_and_derivative()
{
//Arrange
var vendor = new Vendor { VendorName = vendorName };

vendor.CreateApplication(appName, ClaimSetName);

using (var context = GetUsersContextTest())
{
vendor.Applications.AsEnumerable()
.ElementAt(0)
.OperationalContextUri = "uri://ed-fi-api-host.org";

vendor.Applications.AsEnumerable()
.ElementAt(0)
.OdsInstance = new OdsInstance
{
Name = odsName,
ConnectionString = connectionString,
InstanceType = "TEST"
};

vendor.Applications.AsEnumerable()
.ElementAt(0)
.OdsInstance.OdsInstanceContexts.Add(
new OdsInstanceContext
{
ContextKey = "TESTKEY",
ContextValue = "TESTVALUE"
});

vendor.Applications.AsEnumerable()
.ElementAt(0)
.OdsInstance.OdsInstanceDerivatives.Add(
new OdsInstanceDerivative
{
ConnectionString = connectionString,
DerivativeType = "TEST"
});

context.Vendors.Add(vendor);
context.SaveChangesForTest();

//Act
var application = context.Applications.Where(app => app.ApplicationName == appName)
.Include(x => x.OdsInstance)
.Single();

//Test
application.OdsInstance.Name.ShouldBe(odsName);
application.OdsInstance.ConnectionString.ShouldBe(connectionString);
application.OdsInstance.OdsInstanceContexts.Count.ShouldBe(1);
application.OdsInstance.OdsInstanceDerivatives.Count.ShouldBe(1);
}
}
}

public class When_creating_ods_context : UserContextTestBase
{
private string odsName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="7.1.6" />
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="7.1.7" />
<PackageReference Include="EdFi.Suite3.Common" Version="7.1.2" />
</ItemGroup>
</Otherwise>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="7.1.6" />
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" Version="7.1.7" />
<PackageReference Include="EdFi.Suite3.Common" Version="7.1.2" />
</ItemGroup>
</Otherwise>
Expand Down

0 comments on commit eda2f09

Please sign in to comment.