Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<metadata>

<id>Microsoft.CommonDataModel.ObjectModel.Adapter.Adls.All</id>
<version>1.1.1</version>
<version>1.1.2</version>
<description>The ADLS adapter implementation for the Microsoft Common Data Model Object Model.</description>

<authors>Microsoft</authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45;net462</TargetFrameworks>
<version>1.1.1</version>
<version>1.1.2</version>
<Description>The ADLS adapter implementation for the Microsoft Common Data Model Object Model.</Description>

<Authors>Microsoft</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<metadata>

<id>Microsoft.CommonDataModel.ObjectModel.Adapter.Adls</id>
<version>1.1.1</version>
<version>1.1.2</version>
<description>The ADLS adapter implementation for the Microsoft Common Data Model Object Model.</description>

<authors>Microsoft</authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void TestManifestCannotAddEntityDefinitionWithoutCreatingDocument()

Assert.IsTrue(functionWasCalled);
Assert.AreEqual(CdmStatusLevel.Error, functionParameter1);
Assert.IsTrue(functionParameter2.Contains("Expected entity to have an \"Owner\" document set. Cannot create entity declaration to add to manifest. "));
Assert.IsTrue(functionParameter2.Contains("Expected entity to have an \"Owner\" document set. Cannot create entity declaration to add to manifest."));


Assert.AreEqual(0, manifest.Entities.Count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public async Task TestPartitionPatternWithGlob()
{
Invoke = (CdmStatusLevel statusLevel, string message) =>
{
if (message.Equals("CdmDataPartitionPatternDefinition | The Data Partition Pattern contains both a glob pattern (/testfile.csv) and a regular expression (/subFolder/testSubFile.csv) set, the glob pattern will be used. | FileStatusCheckAsync"))
if (message.Contains("CdmDataPartitionPatternDefinition | The Data Partition Pattern contains both a glob pattern (/testfile.csv) and a regular expression (/subFolder/testSubFile.csv) set, the glob pattern will be used. | FileStatusCheckAsync"))
patternWithGlobAndRegex++;
}
}, CdmStatusLevel.Warning);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ public sealed class AttributeContextUtil
/// Function to get the attribute context string tree from a resolved entity
/// </summary>
/// <param name="resolvedEntity"></param>
/// <param name="attribContext"></param>
/// <returns></returns>
public string GetAttributeContextStrings(CdmEntityDefinition resolvedEntity, CdmAttributeContext attribContext)
public string GetAttributeContextStrings(CdmEntityDefinition resolvedEntity)
{
// clear the string builder
bldr.Clear();
Expand All @@ -40,6 +39,17 @@ public string GetAttributeContextStrings(CdmEntityDefinition resolvedEntity, Cdm
return bldr.ToString();
}

public string GetArgumentValuesAsString(CdmArgumentDefinition args)
{
// clear the string builder
bldr.Clear();

// get the corpus path for each attribute context in the tree
GetArgumentValues(args);

return bldr.ToString();
}

/// <summary>
/// Get the corpus path for each attribute context in the tree and build a string collection that we can
/// compare with the expected attribute context corpus path collection.
Expand Down Expand Up @@ -90,13 +100,13 @@ private void GetTraits(CdmEntityDefinition resolvedEntity)

foreach (CdmArgumentDefinition args in trait.Arguments)
{
GetArgumentValuesAsString(args);
GetArgumentValues(args);
}
}
}
}

private void GetArgumentValuesAsString(CdmArgumentDefinition args)
private void GetArgumentValues(CdmArgumentDefinition args)
{
string paramName = args.ResolvedParameter?.Name;
string paramDefaultValue = args.ResolvedParameter?.DefaultValue;
Expand Down Expand Up @@ -151,18 +161,18 @@ public static async Task ValidateAttributeContext(CdmCorpusDefinition corpus, st
{
AttributeContextUtil attrCtxUtil = new AttributeContextUtil();

// Expected
string expectedStringFilePath = Path.GetFullPath(Path.Combine(expectedOutputPath, $"AttrCtx_{entityName}.txt"));
string expectedText = File.ReadAllText(expectedStringFilePath);

// Actual
string actualStringFilePath = Path.GetFullPath(Path.Combine(expectedOutputPath, "..", "ActualOutput", $"AttrCtx_{entityName}.txt"));

// Save Actual AttrCtx_*.txt and Resolved_*.cdm.json
string actualText = attrCtxUtil.GetAttributeContextStrings(resolvedEntity, resolvedEntity.AttributeContext);
string actualText = attrCtxUtil.GetAttributeContextStrings(resolvedEntity);
File.WriteAllText(actualStringFilePath, actualText);
await resolvedEntity.InDocument.SaveAsAsync($"Resolved_{entityName}.cdm.json", saveReferenced: false);

// Expected
string expectedStringFilePath = Path.GetFullPath(Path.Combine(expectedOutputPath, $"AttrCtx_{entityName}.txt"));
string expectedText = File.ReadAllText(expectedStringFilePath);

// Test if Actual is Equal to Expected
Assert.AreEqual(expectedText.Replace("\r\n", "\n"), actualText.Replace("\r\n", "\n"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public async Task TestExtends()
{
string testName = "TestExtends";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand All @@ -60,10 +61,11 @@ public async Task TestExtendsProj()
{
string testName = "TestExtendsProj";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand All @@ -76,10 +78,11 @@ public async Task TestEA()
{
string testName = "TestEA";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand All @@ -92,10 +95,11 @@ public async Task TestEAProj()
{
string testName = "TestEAProj";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand Down Expand Up @@ -132,10 +136,11 @@ public async Task TestEmptyProj()
{
string testName = "TestEmptyProj";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand All @@ -148,10 +153,11 @@ public async Task TestCollProj()
{
string testName = "TestCollProj";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand All @@ -164,10 +170,11 @@ public async Task TestNestedProj()
{
string testName = "TestNestedProj";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand All @@ -180,10 +187,11 @@ public async Task TestMultiProj()
{
string testName = "TestMultiProj";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand All @@ -196,10 +204,11 @@ public async Task TestCondProj()
{
string testName = "TestCondProj";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand All @@ -212,10 +221,11 @@ public async Task TestRenProj()
{
string testName = "TestRenProj";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand All @@ -228,10 +238,11 @@ public async Task TestCommProj()
{
string testName = "TestCommProj";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand All @@ -244,10 +255,11 @@ public async Task TestMissProj()
{
string testName = "TestMissProj";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand All @@ -260,10 +272,11 @@ public async Task TestSeqProj()
{
string testName = "TestSeqProj";
string entityName = "Customer";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

foreach (List<string> resOpt in resOptsCombinations)
{
await LoadEntityForResolutionOptionAndSave(testName, entityName, resOpt);
await ProjectionTestUtils.LoadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
}
}

Expand Down Expand Up @@ -343,40 +356,5 @@ public async Task TestEAProjOM()
await util.DefaultManifest.SaveAsAsync(util.ManifestDocName, saveReferenced: true);
}
}

/// <summary>
/// Loads an entity, resolves it, and then validates the generated attribute contexts
/// </summary>
private async Task LoadEntityForResolutionOptionAndSave(string testName, string entityName, List<string> resOpts)
{
string expectedOutputPath = TestHelper.GetExpectedOutputFolderPath(testsSubpath, testName);
string fileNameSuffix = ProjectionTestUtils.GetResolutionOptionNameSuffix(resOpts);

CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, testName);
corpus.Storage.Mount("expected", new LocalAdapter(expectedOutputPath));

CdmEntityDefinition entity = await corpus.FetchObjectAsync<CdmEntityDefinition>($"local:/{entityName}.cdm.json/{entityName}");
Assert.IsNotNull(entity);
CdmEntityDefinition resolvedEntity = await ProjectionTestUtils.GetResolvedEntity(corpus, entity, resOpts, true);
Assert.IsNotNull(resolvedEntity);

await ValidateResolvedAttributes(corpus, resolvedEntity, entityName, fileNameSuffix);

await AttributeContextUtil.ValidateAttributeContext(corpus, expectedOutputPath, $"{entityName}{fileNameSuffix}", resolvedEntity);
}

/// <summary>
/// Validate the list of resolved attributes against an expected list
/// </summary>
private async Task ValidateResolvedAttributes(CdmCorpusDefinition corpus, CdmEntityDefinition actualResolvedEntity, string entityName, string fileNameSuffix)
{
CdmEntityDefinition expectedResolvedEntity = await corpus.FetchObjectAsync<CdmEntityDefinition>($"expected:/Resolved_{entityName}{fileNameSuffix}.cdm.json/Resolved_{entityName}{fileNameSuffix}");

Assert.AreEqual(expectedResolvedEntity.Attributes.Count, actualResolvedEntity.Attributes.Count);
for (int i = 0; i < expectedResolvedEntity.Attributes.Count; i++)
{
Assert.AreEqual(expectedResolvedEntity.Attributes[i].FetchObjectDefinitionName(), actualResolvedEntity.Attributes[i].FetchObjectDefinitionName());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ public async Task TestExpansion()
/// ArrayExpansion on an entity attribute
/// </summary>
[TestMethod]
public async Task TestProj()
public async Task TestEntityAttribute()
{
string testName = "TestProj";
string testName = "TestEntityAttribute";
string entityName = "ThreeMusketeers";
CdmCorpusDefinition corpus = ProjectionTestUtils.GetCorpus(testName, testsSubpath);

Expand Down
Loading