-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GoogleMaps Tests from CluedIn Repo
- Loading branch information
VladMB
committed
Nov 5, 2019
1 parent
9239850
commit dd33ac0
Showing
3 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
test/integration/Integration.Tests/ExternalSearch.GoogleMaps.Integration.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<ProjectGuid>{8CBDF6EB-A861-466E-932B-04CA5917923C}</ProjectGuid> | ||
<TargetFramework>net452</TargetFramework> | ||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath> | ||
<IsCodedUITest>False</IsCodedUITest> | ||
<TestProjectType>UnitTest</TestProjectType> | ||
<AssemblyTitle>Integration.Tests</AssemblyTitle> | ||
<Product>Integration.Tests</Product> | ||
<Copyright>Copyright © 2019</Copyright> | ||
<OutputPath>bin\$(Configuration)\</OutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugType>full</DebugType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="CluedIn.Core" Version="2.4.0-alpha0103" /> | ||
<PackageReference Include="CluedIn.Testing.Base" Version="2.4.0" /> | ||
<PackageReference Include="Moq" Version="4.13.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\src\ExternalSearch.Providers.GoogleMaps.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using CluedIn.Core.Data; | ||
using CluedIn.Core.Data.Parts; | ||
using CluedIn.Core.Messages.Processing; | ||
using CluedIn.ExternalSearch; | ||
using CluedIn.ExternalSearch.Providers.GoogleMaps; | ||
using CluedIn.ExternalSearch.Providers.GoogleMaps.Models; | ||
using CluedIn.Testing.Base.Context; | ||
using CluedIn.Testing.Base.ExternalSearch; | ||
using CluedIn.Testing.Base.Processing.Actors; | ||
using Moq; | ||
using Xunit; | ||
//using TestContext = CluedIn.Tests.Unit.TestContext; | ||
|
||
namespace CluedIn.Tests.Integration.ExternalSearch | ||
{ | ||
public class GoogleMapsTests : BaseExternalSearchTest<GoogleMapsExternalSearchProvider> | ||
{ | ||
[Theory] | ||
[InlineData("CluedIn APS", "Titangade 11", "Titangade 11, 2200 København, Denmark")] | ||
[InlineData("CluedIn APS", "11 Titangade", "Titangade 11, 2200 København, Denmark")] | ||
[InlineData("CluedIn APS", "Denmark, Titangade 11", "Titangade 11, 2200 København, Denmark")] | ||
// Fails since api call does not yield enough information, | ||
// and no persons are returned. | ||
public void TestClueProduction(string name, string address, string formattedAdress) | ||
{ | ||
var list = new List<string>(new string[] { "AIzaSyA8oZKYh7NT4bX_yZl8vKIMdecoQCHJC4I" }); | ||
object[] parameters = { list }; | ||
var properties = new EntityMetadataPart(); | ||
properties.Properties.Add(CluedIn.Core.Data.Vocabularies.Vocabularies.CluedInOrganization.OrganizationName, name); | ||
properties.Properties.Add(CluedIn.Core.Data.Vocabularies.Vocabularies.CluedInOrganization.Address, address); | ||
|
||
|
||
IEntityMetadata entityMetadata = new EntityMetadataPart() { | ||
EntityType = EntityType.Organization, | ||
Properties = properties.Properties | ||
}; | ||
|
||
//var tokenProvider = new DummyTokenProvider("AIzaSyA8oZKYh7NT4bX_yZl8vKIMdecoQCHJC4I"); | ||
|
||
this.Setup(parameters, entityMetadata); | ||
|
||
// Assert | ||
this.testContext.ProcessingHub.Verify(h => h.SendCommand(It.IsAny<ProcessClueCommand>()), Times.AtLeastOnce); | ||
Assert.True(clues.Count > 0); | ||
foreach(var clue in this.clues) | ||
{ | ||
clue.Decompress().Data.EntityData.Properties | ||
.TryGetValue("googleMaps.Organization.FormattedAddress", out var value); | ||
|
||
Assert.Equal(formattedAdress, value); | ||
} | ||
} | ||
|
||
[Theory] | ||
|
||
[InlineData(null)] | ||
public void TestNoClueProduction(string name) | ||
{ | ||
IEntityMetadata entityMetadata = new EntityMetadataPart() { | ||
Name = name, | ||
EntityType = EntityType.Organization | ||
}; | ||
|
||
this.Setup(null, entityMetadata); | ||
|
||
// Assert | ||
this.testContext.ProcessingHub.Verify(h => h.SendCommand(It.IsAny<ProcessClueCommand>()), Times.Never); | ||
Assert.True(clues.Count == 0); | ||
} | ||
|
||
// TODO Issue 170 - Test Failures | ||
//[Theory] | ||
//[InlineData("null")] | ||
//[InlineData("empty")] | ||
//[InlineData("nonWorking")] | ||
//public void TestInvalidApiToken(string provider) | ||
//{ | ||
// var tokenProvider = GetProviderByName(provider); | ||
// object[] parameters = { tokenProvider }; | ||
|
||
// IEntityMetadata entityMetadata = new EntityMetadataPart() | ||
// { | ||
// Name = "Sitecore", | ||
// EntityType = EntityType.Organization | ||
// }; | ||
|
||
// Setup(parameters, entityMetadata); | ||
// // Assert | ||
// this.testContext.ProcessingHub.Verify(h => h.SendCommand(It.IsAny<ProcessClueCommand>()), Times.Never); | ||
// Assert.True(clues.Count == 0); | ||
//} | ||
|
||
//[Fact] | ||
//public void NullTest() | ||
//{ | ||
// var dummyTokenProvider = new DummyTokenProvider("1234"); | ||
// var permIdExternalSearchProvider = new PermIdExternalSearchProvider(dummyTokenProvider); | ||
|
||
// var query = new ExternalSearchQuery(permIdExternalSearchProvider, EntityType.FAQ, "asd", "gfh"); | ||
// var result = new ExternalSearchQueryResult<object>(query, null); | ||
|
||
// var actual = permIdExternalSearchProvider.GetPrimaryEntityMetadata(null, result, null); | ||
|
||
// Assert.Null(actual); | ||
//} | ||
|
||
//[Fact] | ||
//public void TestNoAdditionalInfo() | ||
//{ | ||
// var dummyTokenProvider = new DummyTokenProvider("1234"); | ||
// var permIdExternalSearchProvider = new PermIdExternalSearchProvider(dummyTokenProvider); | ||
|
||
// var permIdSocialResponse = new PermIdSocialResponse { | ||
// AdditionalInfo = null, | ||
// DomiciledIn = new List<string>() { "Copenhagen" }, | ||
// PermId = new List<string>() { "123" }, | ||
// OrganizationName = new List<string>() { "Organization name" } | ||
// }; | ||
|
||
// var query = new ExternalSearchQuery { | ||
// ProviderId = new Guid("8bc514e4-3dcd-44ca-9e36-479c0940f646"), | ||
// QueryKey = "abc", | ||
// EntityType = EntityType.Organization | ||
// }; | ||
|
||
// var result = new ExternalSearchQueryResult<PermIdSocialResponse>(query, permIdSocialResponse); | ||
// var dummyContext = new TestContext().Context; | ||
// var dummyRequest = new DummyRequest(); | ||
|
||
// foreach (var clue in permIdExternalSearchProvider.BuildClues(dummyContext, query, result, dummyRequest)) | ||
// { | ||
// if (clue.Data.EntityData.EntityType != EntityType.Organization) | ||
// throw new Exception("EntityType should be Organization, since only data about organization is provided"); | ||
// } | ||
//} | ||
|
||
//[Fact] | ||
//public void TestAdditionalInfo() | ||
//{ | ||
// var dummyTokenProvider = new DummyTokenProvider("1234"); | ||
// var permIdExternalSearchProvider = new PermIdExternalSearchProvider(dummyTokenProvider); | ||
|
||
// var person = new AssociatedPerson() { | ||
// FamilyName = new List<string>() { "FamilyName" }, | ||
// PersonUrl = new List<string>() { "abc" } | ||
// }; | ||
|
||
// var permIdSocialResponse = new PermIdSocialResponse { | ||
// AdditionalInfo = new List<AssociatedPerson>() { person }, | ||
// DomiciledIn = new List<string>() { "Copenhagen" }, | ||
// PermId = new List<string>() { "123" }, | ||
// OrganizationName = new List<string>() { "Organization name" } | ||
// }; | ||
|
||
// var query = new ExternalSearchQuery { | ||
// ProviderId = new Guid("8bc514e4-3dcd-44ca-9e36-479c0940f646"), | ||
// QueryKey = "abc", | ||
// EntityType = EntityType.Organization | ||
// }; | ||
|
||
// var result = new ExternalSearchQueryResult<PermIdSocialResponse>(query, permIdSocialResponse); | ||
// var dummyContext = new TestContext().Context; | ||
// var dummyRequest = new DummyRequest(); | ||
|
||
// var hasYieldedPerson = false; | ||
// foreach (var clue in permIdExternalSearchProvider.BuildClues(dummyContext, query, result, dummyRequest)) | ||
// { | ||
// if (clue.Data.EntityData.EntityType == EntityType.Infrastructure.User) | ||
// hasYieldedPerson = true; | ||
// } | ||
|
||
// if (!hasYieldedPerson) | ||
// throw new Exception("Should yield at least one person, since data about one has been provided"); | ||
//} | ||
|
||
//public class DummyRequest : IExternalSearchRequest | ||
//{ | ||
// public IEntityMetadata EntityMetaData | ||
// { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | ||
// public object CustomQueryInput | ||
// { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | ||
// public bool? NoRecursion | ||
// { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | ||
// public List<Guid> ProviderIds | ||
// { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | ||
// public IExternalSearchQueryParameters QueryParameters | ||
// { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | ||
// public List<IExternalSearchQuery> Queries | ||
// { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | ||
// public bool IsFinished | ||
// { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | ||
// public bool AllQueriesHasExecuted => throw new NotImplementedException(); | ||
//} | ||
} | ||
} |