Skip to content

Commit b87d9f9

Browse files
authored
Fix LT-21889: Add Find and Fix step for removing disowned children (#372)
* Fix LT-21889: Add Find and Fix step for removing disowned children * Add assert for actual data being removed
1 parent c459605 commit b87d9f9

6 files changed

Lines changed: 34 additions & 6 deletions

File tree

src/SIL.LCModel.FixData/FwDataFixer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ internal override bool FixElement(XElement rt, ErrorLogger errorLogger)
256256
errorLogger(String.Format(Strings.ksRemovingObjectWithBadOwner, guidOwner, className, guid), true);
257257
return false;
258258
}
259+
else
260+
{
261+
errorLogger(String.Format(Strings.ksRemovingDisownedObject, guidOwner, className, guid), true);
262+
return false;
263+
}
259264
}
260265
}
261266
else if (storedOwner != Guid.Empty)

src/SIL.LCModel.FixData/Strings.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SIL.LCModel.FixData/Strings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@
135135
<data name="ksRemovingObjectWithBadOwner" xml:space="preserve">
136136
<value>Removing object with nonexistent owner (invalid ownerguid='{0}', class='{1}', guid='{2}').</value>
137137
</data>
138+
<data name="ksRemovingDisownedObject" xml:space="preserve">
139+
<value>Removing disowned object (invalid ownerguid='{0}', class='{1}', guid='{2}').</value>
140+
</data>
138141
<data name="ksAddingLinkToOwner" xml:space="preserve">
139142
<value>Adding ownerguid='{0}' (class='{1}', guid='{2}').</value>
140143
</data>

tests/SIL.LCModel.FixData.Tests/FwDataFixerTests.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ public void DanglingWordformLinks()
441441
var danglingMorphGoodSenseGuid = "9665bf3b-2aab-4f7f-88a9-4ca738b75110";
442442
var danglingMorphNoRepairGuid = "5752ed24-40e1-4282-9ba0-d82c89592432";
443443
var danglingMorphNoRepairAfGuid = "1f568cae-b0f8-413d-84a6-41cbd90923e9";
444+
var disownedOwnerGuid = "16827d7a-cf4e-45f8-aaa1-66cef5c2cc4d";
445+
var disownedGuid = "1f568cae-b0f8-413d-84a6-41cbd90923e9";
444446

445447
// Verify initial state.
446448
// We start out with morph bundles that have broken links.
@@ -463,7 +465,7 @@ public void DanglingWordformLinks()
463465
"//rt[@class=\"WfiMorphBundle\" and @guid=\"" + danglingMorphNoRepairAfGuid + "\"]/Morph/objsur[@guid=\"" + danglingMsaGuid + "\"]", 1);
464466

465467
// Check errors
466-
Assert.AreEqual(10, _errors.Count, "Unexpected number of errors found.");
468+
Assert.AreEqual(11, _errors.Count, "Unexpected number of errors found.");
467469
Assert.True(_errors[0].StartsWith("Removing dangling link to '" + danglingMsaGuid + "' (class='LexEntry'"),
468470
"Error message is incorrect."); // OriginalFixer--ksRemovingLinkToNonexistingObject
469471
Assert.That(_errors[1], Is.EqualTo("Fixing link to MSA based on Sense MSA (class='WfiMorphBundle', guid='" + repairableBundleGuid + "')."),
@@ -480,7 +482,9 @@ public void DanglingWordformLinks()
480482
"Error message is incorrect."); // MorphBundleFixer--ksRemovingDanglingMsa
481483
Assert.That(_errors[8], Is.EqualTo("Removing dangling link to Form '" + danglingMsaGuid + "' for WfiMorphBundle '" + danglingMorphNoRepairGuid + "'."),
482484
"Error message is incorrect."); // MorphBundleFixer--ksRemovingDanglingMorph
483-
Assert.That(_errors[9], Is.EqualTo("Removing dangling link to Form '" + danglingMsaGuid + "' for WfiMorphBundle '" + danglingMorphNoRepairAfGuid + "'."),
485+
Assert.True(_errors[9].StartsWith("Removing disowned object (invalid ownerguid='" + disownedOwnerGuid + "', class='WfiMorphBundle', guid='" + disownedGuid),
486+
"Error message is incorrect."); // MorphBundleFixer--ksRemovingDanglingMorph
487+
Assert.That(_errors[10], Is.EqualTo("Removing dangling link to Form '" + danglingMsaGuid + "' for WfiMorphBundle '" + danglingMorphNoRepairAfGuid + "'."),
484488
"Error message is incorrect."); // MorphBundleFixer--ksRemovingDanglingMorph
485489

486490
// Check file repair
@@ -498,6 +502,8 @@ public void DanglingWordformLinks()
498502
"//rt[@class=\"WfiMorphBundle\" and @guid=\"" + danglingMorphNoRepairGuid + "\"]/Morph", 0); // must remove Morph, not just child objsur
499503
AssertThatXmlIn.File(Path.Combine(testPath, "BasicFixup.fwdata")).HasSpecifiedNumberOfMatchesForXpath(
500504
"//rt[@class=\"WfiMorphBundle\" and @guid=\"" + danglingMorphNoRepairAfGuid + "\"]/Morph/objsur", 0);
505+
AssertThatXmlIn.File(Path.Combine(testPath, "BasicFixup.fwdata")).HasSpecifiedNumberOfMatchesForXpath(
506+
"//rt[@class=\"WfiMorphBundle\" and @guid=\"" + disownedGuid + "\"]/Morph/objsur", 0);
501507
}
502508

503509
/// <summary>

tests/SIL.LCModel.FixData.Tests/TestData/DeletedMsaRefBySenseAndBundle/Test.fwdata

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
<rt class="WfiWordform" guid ="31c5a1c0-270e-4edf-9406-4ed445bd27c4">
2222
<Analyses>
23-
<objsur guid="16827d7a-cf4e-45f8-aaa1-66cef5c2cc4d" type="o"/>
23+
<objsur guid="16827d7a-cf4e-45f8-aaa1-66cef5c2cc4d" t="o"/>
2424
</Analyses>
2525
</rt>
2626
<rt class="WfiAnalysis" guid ="16827d7a-cf4e-45f8-aaa1-66cef5c2cc4d" ownerguid="31c5a1c0-270e-4edf-9406-4ed445bd27c4">
2727
<MorphBundles>
28-
<objsur guid="10f3db1e-33db-4d9d-9a06-e0a8e1ed8a92" type="o"/>
28+
<objsur guid="10f3db1e-33db-4d9d-9a06-e0a8e1ed8a92" t="o"/>
2929
</MorphBundles>
3030
</rt>
3131
<rt class="WfiMorphBundle" guid ="10f3db1e-33db-4d9d-9a06-e0a8e1ed8a92" ownerguid="16827d7a-cf4e-45f8-aaa1-66cef5c2cc4d">

tests/SIL.LCModel.FixData.Tests/TestData/MorphBundleProblems/Test.fwdata

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@
2525

2626
<rt class="WfiWordform" guid ="31c5a1c0-270e-4edf-9406-4ed445bd27c4">
2727
<Analyses>
28-
<objsur guid="16827d7a-cf4e-45f8-aaa1-66cef5c2cc4d" type="o"/>
28+
<objsur guid="16827d7a-cf4e-45f8-aaa1-66cef5c2cc4d" t="o"/>
2929
</Analyses>
3030
</rt>
3131
<rt class="WfiAnalysis" guid ="16827d7a-cf4e-45f8-aaa1-66cef5c2cc4d" ownerguid="31c5a1c0-270e-4edf-9406-4ed445bd27c4">
3232
<MorphBundles>
33-
<objsur guid="10f3db1e-33db-4d9d-9a06-e0a8e1ed8a92" type="o"/>
33+
<objsur guid="10f3db1e-33db-4d9d-9a06-e0a8e1ed8a92" t="o"/>
34+
<objsur guid="d70b57bc-ecfe-4e32-a590-f2852bce69fc" t="o"/>
35+
<objsur guid="e4396e8e-b7d2-43ba-93bd-104cf2011aaf" t="o"/>
36+
<objsur guid="cb941dc9-6f6e-44b2-97f2-07854e164b4e" t="o"/>
37+
<objsur guid="9665bf3b-2aab-4f7f-88a9-4ca738b75110" t="o"/>
38+
<objsur guid="5752ed24-40e1-4282-9ba0-d82c89592432" t="o"/>
3439
</MorphBundles>
3540
</rt>
3641
<rt class="WfiMorphBundle" guid ="10f3db1e-33db-4d9d-9a06-e0a8e1ed8a92" ownerguid="16827d7a-cf4e-45f8-aaa1-66cef5c2cc4d">

0 commit comments

Comments
 (0)