Skip to content

Commit b18fc99

Browse files
committed
Refactor Generate relations to create unit test
1 parent ae4228e commit b18fc99

9 files changed

+183
-64
lines changed

Dependency-Graph/Translations/Dependency-Graph.es-ES.g.xlf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@
265265
<note from="Developer" annotates="general" priority="2"/>
266266
<note from="Xliff Generator" annotates="general" priority="3">Codeunit GenerateExtensionTable_ANJ - NamedType ValueJsonArryLbl</note>
267267
</trans-unit>
268+
<trans-unit id="Codeunit 708421718 - NamedType 3993970854" size-unit="char" translate="yes" xml:space="preserve">
269+
<source>DestinationAppID</source>
270+
<note from="Developer" annotates="general" priority="2"/>
271+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit GenerateRelationsTable_ANJ - NamedType DestinationAppIDLbl</note>
272+
</trans-unit>
273+
<trans-unit id="Codeunit 708421718 - NamedType 1408304205" size-unit="char" translate="yes" xml:space="preserve">
274+
<source>SourceAppID</source>
275+
<note from="Developer" annotates="general" priority="2"/>
276+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit GenerateRelationsTable_ANJ - NamedType SourceAppIDLbl</note>
277+
</trans-unit>
268278
<trans-unit id="Codeunit 2841349168 - NamedType 750120336" size-unit="char" translate="yes" xml:space="preserve">
269279
<source>When generating the tables again, custom data will be deleted, do you want to continue?</source>
270280
<note from="Developer" annotates="general" priority="2">ESP="Al generar de nuevo las tablas se eliminaran datos personalizados, ¿Desea continuar?"</note>
@@ -373,6 +383,11 @@
373383
<note from="Developer" annotates="general" priority="2"/>
374384
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType ContentTypeLbl</note>
375385
</trans-unit>
386+
<trans-unit id="Codeunit 3451087242 - NamedType 3993970854" size-unit="char" translate="yes" xml:space="preserve">
387+
<source>DestinationAppID</source>
388+
<note from="Developer" annotates="general" priority="2"/>
389+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType DestinationAppIDLbl</note>
390+
</trans-unit>
376391
<trans-unit id="Codeunit 3451087242 - NamedType 1549459477" size-unit="char" translate="yes" xml:space="preserve">
377392
<source>https://api.businesscentral.dynamics.com/v2.0/%1/api/microsoft/automation/v2.0/companies(%2)/extensions</source>
378393
<note from="Developer" annotates="general" priority="2"/>
@@ -393,6 +408,11 @@
393408
<note from="Developer" annotates="general" priority="2"/>
394409
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType ScopeLbl</note>
395410
</trans-unit>
411+
<trans-unit id="Codeunit 3451087242 - NamedType 1408304205" size-unit="char" translate="yes" xml:space="preserve">
412+
<source>SourceAppID</source>
413+
<note from="Developer" annotates="general" priority="2"/>
414+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType SourceAppIDLbl</note>
415+
</trans-unit>
396416
<trans-unit id="Codeunit 3451087242 - NamedType 752839706" size-unit="char" translate="yes" xml:space="preserve">
397417
<source>Unable to communicate with the web service.</source>
398418
<note from="Developer" annotates="general" priority="2">ESP="No se puede comunicar con el servicio web."</note>

Dependency-Graph/Translations/Dependency-Graph.es-ES_tradnl.g.xlf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@
265265
<note from="Developer" annotates="general" priority="2"/>
266266
<note from="Xliff Generator" annotates="general" priority="3">Codeunit GenerateExtensionTable_ANJ - NamedType ValueJsonArryLbl</note>
267267
</trans-unit>
268+
<trans-unit id="Codeunit 708421718 - NamedType 3993970854" size-unit="char" translate="yes" xml:space="preserve">
269+
<source>DestinationAppID</source>
270+
<note from="Developer" annotates="general" priority="2"/>
271+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit GenerateRelationsTable_ANJ - NamedType DestinationAppIDLbl</note>
272+
</trans-unit>
273+
<trans-unit id="Codeunit 708421718 - NamedType 1408304205" size-unit="char" translate="yes" xml:space="preserve">
274+
<source>SourceAppID</source>
275+
<note from="Developer" annotates="general" priority="2"/>
276+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit GenerateRelationsTable_ANJ - NamedType SourceAppIDLbl</note>
277+
</trans-unit>
268278
<trans-unit id="Codeunit 2841349168 - NamedType 750120336" size-unit="char" translate="yes" xml:space="preserve">
269279
<source>When generating the tables again, custom data will be deleted, do you want to continue?</source>
270280
<note from="Developer" annotates="general" priority="2">ESP="Al generar de nuevo las tablas se eliminaran datos personalizados, ¿Desea continuar?"</note>
@@ -373,6 +383,11 @@
373383
<note from="Developer" annotates="general" priority="2"/>
374384
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType ContentTypeLbl</note>
375385
</trans-unit>
386+
<trans-unit id="Codeunit 3451087242 - NamedType 3993970854" size-unit="char" translate="yes" xml:space="preserve">
387+
<source>DestinationAppID</source>
388+
<note from="Developer" annotates="general" priority="2"/>
389+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType DestinationAppIDLbl</note>
390+
</trans-unit>
376391
<trans-unit id="Codeunit 3451087242 - NamedType 1549459477" size-unit="char" translate="yes" xml:space="preserve">
377392
<source>https://api.businesscentral.dynamics.com/v2.0/%1/api/microsoft/automation/v2.0/companies(%2)/extensions</source>
378393
<note from="Developer" annotates="general" priority="2"/>
@@ -393,6 +408,11 @@
393408
<note from="Developer" annotates="general" priority="2"/>
394409
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType ScopeLbl</note>
395410
</trans-unit>
411+
<trans-unit id="Codeunit 3451087242 - NamedType 1408304205" size-unit="char" translate="yes" xml:space="preserve">
412+
<source>SourceAppID</source>
413+
<note from="Developer" annotates="general" priority="2"/>
414+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType SourceAppIDLbl</note>
415+
</trans-unit>
396416
<trans-unit id="Codeunit 3451087242 - NamedType 752839706" size-unit="char" translate="yes" xml:space="preserve">
397417
<source>Unable to communicate with the web service.</source>
398418
<note from="Developer" annotates="general" priority="2">ESP="No se puede comunicar con el servicio web."</note>

Dependency-Graph/Translations/Dependency-Graph.g.xlf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@
228228
<note from="Developer" annotates="general" priority="2"></note>
229229
<note from="Xliff Generator" annotates="general" priority="3">Codeunit GenerateExtensionTable_ANJ - NamedType ValueJsonArryLbl</note>
230230
</trans-unit>
231+
<trans-unit id="Codeunit 708421718 - NamedType 3993970854" size-unit="char" translate="yes" xml:space="preserve">
232+
<source>DestinationAppID</source>
233+
<note from="Developer" annotates="general" priority="2"></note>
234+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit GenerateRelationsTable_ANJ - NamedType DestinationAppIDLbl</note>
235+
</trans-unit>
236+
<trans-unit id="Codeunit 708421718 - NamedType 1408304205" size-unit="char" translate="yes" xml:space="preserve">
237+
<source>SourceAppID</source>
238+
<note from="Developer" annotates="general" priority="2"></note>
239+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit GenerateRelationsTable_ANJ - NamedType SourceAppIDLbl</note>
240+
</trans-unit>
231241
<trans-unit id="Codeunit 2841349168 - NamedType 750120336" size-unit="char" translate="yes" xml:space="preserve">
232242
<source>When generating the tables again, custom data will be deleted, do you want to continue?</source>
233243
<note from="Developer" annotates="general" priority="2">ESP="Al generar de nuevo las tablas se eliminaran datos personalizados, ¿Desea continuar?"</note>
@@ -333,6 +343,11 @@
333343
<note from="Developer" annotates="general" priority="2"></note>
334344
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType ContentTypeLbl</note>
335345
</trans-unit>
346+
<trans-unit id="Codeunit 3451087242 - NamedType 3993970854" size-unit="char" translate="yes" xml:space="preserve">
347+
<source>DestinationAppID</source>
348+
<note from="Developer" annotates="general" priority="2"></note>
349+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType DestinationAppIDLbl</note>
350+
</trans-unit>
336351
<trans-unit id="Codeunit 3451087242 - NamedType 1549459477" size-unit="char" translate="yes" xml:space="preserve">
337352
<source>https://api.businesscentral.dynamics.com/v2.0/%1/api/microsoft/automation/v2.0/companies(%2)/extensions</source>
338353
<note from="Developer" annotates="general" priority="2"></note>
@@ -353,6 +368,11 @@
353368
<note from="Developer" annotates="general" priority="2"></note>
354369
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType ScopeLbl</note>
355370
</trans-unit>
371+
<trans-unit id="Codeunit 3451087242 - NamedType 1408304205" size-unit="char" translate="yes" xml:space="preserve">
372+
<source>SourceAppID</source>
373+
<note from="Developer" annotates="general" priority="2"></note>
374+
<note from="Xliff Generator" annotates="general" priority="3">Codeunit WSAndMDInfoImp_ANJ - NamedType SourceAppIDLbl</note>
375+
</trans-unit>
356376
<trans-unit id="Codeunit 3451087242 - NamedType 752839706" size-unit="char" translate="yes" xml:space="preserve">
357377
<source>Unable to communicate with the web service.</source>
358378
<note from="Developer" annotates="general" priority="2">ESP="No se puede comunicar con el servicio web."</note>

Dependency-Graph/src/Base/DependencyGraphFacadeANJ.Codeunit.al

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,25 @@ codeunit 80810 DependencyGraphFacade_ANJ
107107
end;
108108
#endregion
109109

110+
/// <summary>
111+
/// GetInterfaceFillProcessingTables.
112+
/// </summary>
113+
/// <param name="FillingProcessingTables">VAR Interface FillingProcessingTables_ANJ.</param>
114+
procedure GetInterfaceFillProcessingTables(var FillingProcessingTables: Interface FillingProcessingTables_ANJ)
115+
var
116+
DependencyGraphSetup: Record DependencyGraphSetup_ANJ;
117+
begin
118+
DependencyGraphSetup.SetLoadFields(FillingProcessingTables);
119+
DependencyGraphSetup.GetInstance();
120+
FillingProcessingTables := DependencyGraphSetup.FillingProcessingTables;
121+
OnAfterGetFillingProcessingTables(FillingProcessingTables);
122+
end;
123+
124+
[IntegrationEvent(false, false)]
125+
local procedure OnAfterGetFillingProcessingTables(var FillingProcessingTables: Interface FillingProcessingTables_ANJ)
126+
begin
127+
end;
128+
110129
var
111130
CleanTemporaryTables: Codeunit CleanTemporaryTables_ANJ;
112131
GenerateExtensionTable: Codeunit GenerateExtensionTable_ANJ;

Dependency-Graph/src/Base/FillingProcessingTablesANJ.Interface.al

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@ interface FillingProcessingTables_ANJ
1010
/// </summary>
1111
/// <returns>Return value of type Text.</returns>
1212
procedure GetExtensions(): Text;
13+
14+
/// <summary>
15+
/// GetRelations.
16+
/// </summary>
17+
/// <returns>Return value of type Text.</returns>
18+
procedure GetRelations() JsonText: Text;
1319
}

Dependency-Graph/src/Base/WSAndMDInfoImpANJ.Codeunit.al

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,78 @@ codeunit 80812 WSAndMDInfoImp_ANJ implements FillingProcessingTables_ANJ
158158
Error(WSStatusCodeErr, ResponseHttpResponseMessage.HttpStatusCode(), ResponseText);
159159
end;
160160

161+
/// <summary>
162+
/// GetRelations.
163+
/// </summary>
164+
/// <returns>Return value of type Text.</returns>
165+
procedure GetRelations() JsonText: Text;
166+
var
167+
Extensions: Record Extensions_ANJ;
168+
RelationsArry: JsonArray;
169+
begin
170+
Extensions.SetLoadFields(AppID);
171+
Extensions.SetRange(ShowInGraph, true);
172+
if Extensions.FindSet(false) then
173+
repeat
174+
CheckDependencies(Extensions.AppID, RelationsArry);
175+
until Extensions.Next() = 0;
176+
RelationsArry.WriteTo(JsonText);
177+
end;
178+
179+
/// <summary>
180+
/// CheckDependencies.
181+
/// </summary>
182+
/// <param name="AppId">Guid.</param>
183+
/// <param name="RelationsArry">VAR JsonArray.</param>
184+
local procedure CheckDependencies(AppId: Guid; var RelationsArry: JsonArray);
185+
var
186+
DestinationAppID: Guid;
187+
ModuleDependencyInfoList: List of [ModuleDependencyInfo];
188+
SingleModuleDependencyInfo: ModuleDependencyInfo;
189+
AuxModuleInfo: ModuleInfo;
190+
begin
191+
if not NavApp.GetModuleInfo(AppId, AuxModuleInfo) then
192+
exit;
193+
194+
ModuleDependencyInfoList := AuxModuleInfo.Dependencies;
195+
196+
foreach SingleModuleDependencyInfo in ModuleDependencyInfoList do begin
197+
DestinationAppID := SingleModuleDependencyInfo.Id;
198+
if CheckDestinationAppIDShowInGraph(DestinationAppID) then
199+
AddNewRelationToJsonArry(RelationsArry, AppId, DestinationAppID);
200+
end;
201+
end;
202+
203+
/// <summary>
204+
/// AddNewRelationToJsonArry.
205+
/// </summary>
206+
/// <param name="RelationsArry">VAR JsonArray.</param>
207+
/// <param name="SourceAppID">Guid.</param>
208+
/// <param name="DestinationAppID">Guid.</param>
209+
local procedure AddNewRelationToJsonArry(var RelationsArry: JsonArray; SourceAppID: Guid; DestinationAppID: Guid)
210+
var
211+
RelationJsonObject: JsonObject;
212+
begin
213+
RelationJsonObject.Add(SourceAppIDLbl, SourceAppID);
214+
RelationJsonObject.Add(DestinationAppIDLbl, DestinationAppID);
215+
216+
RelationsArry.Add(RelationJsonObject);
217+
end;
218+
219+
/// <summary>
220+
/// CheckDestinationAppIDShowInGraph.
221+
/// </summary>
222+
/// <param name="AppID">Guid.</param>
223+
/// <returns>Return value of type Boolean.</returns>
224+
local procedure CheckDestinationAppIDShowInGraph(AppID: Guid): Boolean;
225+
var
226+
Extensions: Record Extensions_ANJ;
227+
begin
228+
Extensions.SetRange(AppID, AppID);
229+
Extensions.SetRange(ShowInGraph, true);
230+
exit(not Extensions.IsEmpty());
231+
end;
232+
161233
var
162234
AzureADTenant: Codeunit "Azure AD Tenant";
163235
JSONMethods: Codeunit JSONMethods_ANJ;
@@ -168,10 +240,12 @@ codeunit 80812 WSAndMDInfoImp_ANJ implements FillingProcessingTables_ANJ
168240
ClientIdLbl: Label '&client_id=%1';
169241
ClientSecretLbl: Label '&client_secret=%1';
170242
ContentTypeLbl: Label 'Content-Type';
243+
DestinationAppIDLbl: Label 'DestinationAppID';
171244
ExtensionsUrlLbl: Label 'https://api.businesscentral.dynamics.com/v2.0/%1/api/microsoft/automation/v2.0/companies(%2)/extensions';
172245
FilterMSAppsLbl: Label '?$filter=publisher ne ';
173246
GrantTypeLbl: Label 'grant_type=client_credentials';
174247
ScopeLbl: Label '&scope=https://api.businesscentral.dynamics.com/.default';
248+
SourceAppIDLbl: Label 'SourceAppID';
175249
UnableToCommunicateWSErr: Label 'Unable to communicate with the web service.', comment = 'ESP="No se puede comunicar con el servicio web."';
176250
UrlencodedLbl: Label 'application/x-www-form-urlencoded';
177251
WSStatusCodeErr: Label 'Error - Status code: %1 Description: %2', comment = 'ESP="Error - Código: %1 Descripción: %2"';

Dependency-Graph/src/ControlAddinViewer/MarkdownViewerFSANJ.ControlAddin.al

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ controladdin MarkdownViewerFS_ANJ
88
StartupScript = 'src\ControlAddinViewer\Start.js';
99
VerticalStretch = true;
1010

11-
1211
/// <summary>
1312
/// Ready.
1413
/// </summary>

Dependency-Graph/src/ExtensionTable/GenerateExtensionTableANJ.Codeunit.al

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,12 @@ codeunit 80805 GenerateExtensionTable_ANJ
3030
if IsHandled then
3131
exit;
3232

33-
GetInterfaceFillProcessingTables(FillingProcessingTables);
33+
DependencyGraphFacade.GetInterfaceFillProcessingTables(FillingProcessingTables);
3434
ResponseText := FillingProcessingTables.GetExtensions();
3535
if ResponseText <> '' then
3636
PopulateResponse(ResponseText);
3737
end;
3838

39-
/// <summary>
40-
/// GetInterfaceFillProcessingTables.
41-
/// </summary>
42-
/// <param name="FillingProcessingTables">VAR Interface FillingProcessingTables_ANJ.</param>
43-
local procedure GetInterfaceFillProcessingTables(var FillingProcessingTables: Interface FillingProcessingTables_ANJ)
44-
var
45-
DependencyGraphSetup: Record DependencyGraphSetup_ANJ;
46-
begin
47-
DependencyGraphSetup.SetLoadFields(FillingProcessingTables);
48-
DependencyGraphSetup.GetInstance();
49-
FillingProcessingTables := DependencyGraphSetup.FillingProcessingTables;
50-
OnAfterGetFillingProcessingTables(FillingProcessingTables);
51-
end;
52-
5339
/// <summary>
5440
/// PopulateResponse.
5541
/// </summary>
@@ -107,11 +93,6 @@ codeunit 80805 GenerateExtensionTable_ANJ
10793
Extensions.Modify(true);
10894
end;
10995

110-
[IntegrationEvent(false, false)]
111-
local procedure OnAfterGetFillingProcessingTables(var FillingProcessingTables: Interface FillingProcessingTables_ANJ)
112-
begin
113-
end;
114-
11596
[IntegrationEvent(false, false)]
11697
local procedure OnBeforeGenerateExtensionTable(Extensions: Record Extensions_ANJ; var IsHandled: Boolean);
11798
begin

0 commit comments

Comments
 (0)