Skip to content

Commit 72c914a

Browse files
committed
Fix up WordService public method order
1 parent 1496618 commit 72c914a

File tree

4 files changed

+64
-64
lines changed

4 files changed

+64
-64
lines changed

Backend.Tests/Services/WordServiceTests.cs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,40 @@ public void TestDeleteFrontierWordCopiesToWordsAndRemovesFrontier()
126126
Assert.That(_wordRepo.GetAllFrontier(ProjId).Result, Is.Empty);
127127
}
128128

129+
[Test]
130+
public void TestRestoreFrontierWordAlreadyInFrontierThrows()
131+
{
132+
var wordInFrontier = _wordRepo.Create(new Word { ProjectId = ProjId }).Result;
133+
Assert.That(_wordRepo.GetAllFrontier(ProjId).Result, Has.Count.EqualTo(1));
134+
135+
Assert.That(
136+
() => _wordService.RestoreFrontierWord(ProjId, wordInFrontier.Id).Wait(),
137+
Throws.TypeOf<AggregateException>());
138+
}
139+
140+
[Test]
141+
public void TestRestoreFrontierWordMissingWordReturnsFalse()
142+
{
143+
var word = _wordRepo.Add(new Word { ProjectId = ProjId }).Result;
144+
145+
var result = _wordService.RestoreFrontierWord(ProjId, "NotAnId").Result;
146+
147+
Assert.That(result, Is.False);
148+
Assert.That(_wordRepo.GetAllFrontier(ProjId).Result, Is.Empty);
149+
}
150+
151+
[Test]
152+
public void TestRestoreFrontierWordReturnsTrueRestoresWords()
153+
{
154+
var word = _wordRepo.Add(new Word { ProjectId = ProjId }).Result;
155+
Assert.That(_wordRepo.GetAllFrontier(ProjId).Result, Is.Empty);
156+
157+
var result = _wordService.RestoreFrontierWord(ProjId, word.Id).Result;
158+
159+
Assert.That(result, Is.True);
160+
Assert.That(_wordRepo.GetAllFrontier(ProjId).Result, Has.Count.EqualTo(1));
161+
}
162+
129163
[Test]
130164
public void TestUpdateNotInFrontierReturnsNull()
131165
{
@@ -172,40 +206,6 @@ public void TestUpdateUsingCitationForm()
172206
Assert.That(vernUpdate.UsingCitationForm, Is.False);
173207
}
174208

175-
[Test]
176-
public void TestRestoreFrontierWordAlreadyInFrontierThrows()
177-
{
178-
var wordInFrontier = _wordRepo.Create(new Word { ProjectId = ProjId }).Result;
179-
Assert.That(_wordRepo.GetAllFrontier(ProjId).Result, Has.Count.EqualTo(1));
180-
181-
Assert.That(
182-
() => _wordService.RestoreFrontierWord(ProjId, wordInFrontier.Id).Wait(),
183-
Throws.TypeOf<AggregateException>());
184-
}
185-
186-
[Test]
187-
public void TestRestoreFrontierWordMissingWordReturnsFalse()
188-
{
189-
var word = _wordRepo.Add(new Word { ProjectId = ProjId }).Result;
190-
191-
var result = _wordService.RestoreFrontierWord(ProjId, "NotAnId").Result;
192-
193-
Assert.That(result, Is.False);
194-
Assert.That(_wordRepo.GetAllFrontier(ProjId).Result, Is.Empty);
195-
}
196-
197-
[Test]
198-
public void TestRestoreFrontierWordReturnsTrueRestoresWords()
199-
{
200-
var word = _wordRepo.Add(new Word { ProjectId = ProjId }).Result;
201-
Assert.That(_wordRepo.GetAllFrontier(ProjId).Result, Is.Empty);
202-
203-
var result = _wordService.RestoreFrontierWord(ProjId, word.Id).Result;
204-
205-
Assert.That(result, Is.True);
206-
Assert.That(_wordRepo.GetAllFrontier(ProjId).Result, Has.Count.EqualTo(1));
207-
}
208-
209209
[Test]
210210
public void TestFindContainingWordNoFrontier()
211211
{

Backend/Controllers/LiftController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ private async Task<IActionResult> AddImportToProject(string liftStoragePath, str
264264

265265
int countWordsImported;
266266
// Sets the projectId of our parser to add words to that project
267-
var liftMerger = _liftService.GetLiftImporterExporter(projectId, proj.VernacularWritingSystem.Bcp47,
268-
_wordService);
267+
var liftMerger = _liftService.GetLiftImporterExporter(
268+
projectId, proj.VernacularWritingSystem.Bcp47, _wordService);
269269
var importedAnalysisWritingSystems = new List<WritingSystem>();
270270
var doesImportHaveDefinitions = false;
271271
var doesImportHaveGrammaticalInfo = false;

Backend/Interfaces/IWordService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ public interface IWordService
88
{
99
Task<List<Word>> ImportWords(List<Word> words);
1010
Task<Word> Create(string userId, Word word);
11-
Task<List<Word>?> MergeReplaceFrontier(
12-
string projectId, string userId, List<Word> parents, List<string> idsToDelete);
13-
Task<bool> RevertMergeReplaceFrontier(
14-
string projectId, string userId, List<string> idsToRestore, List<string> idsToDelete);
15-
Task<Word?> Update(string userId, Word word);
1611
Task<Word?> DeleteAudio(string projectId, string userId, string wordId, string fileName);
1712
Task<string?> DeleteFrontierWord(string projectId, string userId, string wordId);
1813
Task<bool> RestoreFrontierWord(string projectId, string wordId);
14+
Task<Word?> Update(string userId, Word word);
1915
Task<string?> FindContainingWord(Word word);
16+
Task<List<Word>?> MergeReplaceFrontier(
17+
string projectId, string userId, List<Word> parents, List<string> idsToDelete);
18+
Task<bool> RevertMergeReplaceFrontier(
19+
string projectId, string userId, List<string> idsToRestore, List<string> idsToDelete);
2020
}
2121
}

Backend/Services/WordService.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -119,29 +119,6 @@ public async Task<Word> Create(string userId, Word word)
119119
return await _wordRepo.Create(PrepEditedData(userId, word));
120120
}
121121

122-
/// <summary>
123-
/// Replaces merge children in the Frontier with prepared parent words where possible,
124-
/// creates remaining parents, and deletes remaining children from the Frontier.
125-
/// </summary>
126-
public async Task<List<Word>?> MergeReplaceFrontier(
127-
string projectId, string userId, List<Word> parents, List<string> idsToDelete)
128-
{
129-
using var activity = OtelService.StartActivityWithTag(otelTagName, "replacing frontier words for merge");
130-
131-
return await _wordRepo.ReplaceFrontier(projectId, parents, idsToDelete,
132-
CreateModifyUpdatedWordAction(userId), CreateModifyDeletedWordAction(userId));
133-
}
134-
135-
public async Task<bool> RevertMergeReplaceFrontier(
136-
string projectId, string userId, List<string> idsToRestore, List<string> idsToDelete)
137-
{
138-
using var activity =
139-
OtelService.StartActivityWithTag(otelTagName, "reverting replaced frontier words for merge");
140-
141-
return await _wordRepo.RevertReplaceFrontier(
142-
projectId, idsToRestore, idsToDelete, CreateModifyDeletedWordAction(userId));
143-
}
144-
145122
/// <summary> Removes audio with specified fileName from a Frontier word </summary>
146123
/// <returns> Updated word, or null if not found </returns>
147124
public async Task<Word?> DeleteAudio(string projectId, string userId, string wordId, string fileName)
@@ -187,5 +164,28 @@ public async Task<bool> RestoreFrontierWord(string projectId, string wordId)
187164
var duplicatedWord = wordsWithVern.Find(w => w.Contains(word));
188165
return duplicatedWord?.Id;
189166
}
167+
168+
/// <summary>
169+
/// Replaces merge children in the Frontier with prepared parent words where possible,
170+
/// creates remaining parents, and deletes remaining children from the Frontier.
171+
/// </summary>
172+
public async Task<List<Word>?> MergeReplaceFrontier(
173+
string projectId, string userId, List<Word> parents, List<string> idsToDelete)
174+
{
175+
using var activity = OtelService.StartActivityWithTag(otelTagName, "replacing frontier words for merge");
176+
177+
return await _wordRepo.ReplaceFrontier(projectId, parents, idsToDelete,
178+
CreateModifyUpdatedWordAction(userId), CreateModifyDeletedWordAction(userId));
179+
}
180+
181+
public async Task<bool> RevertMergeReplaceFrontier(
182+
string projectId, string userId, List<string> idsToRestore, List<string> idsToDelete)
183+
{
184+
using var activity =
185+
OtelService.StartActivityWithTag(otelTagName, "reverting replaced frontier words for merge");
186+
187+
return await _wordRepo.RevertReplaceFrontier(
188+
projectId, idsToRestore, idsToDelete, CreateModifyDeletedWordAction(userId));
189+
}
190190
}
191191
}

0 commit comments

Comments
 (0)