mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-02 21:03:34 +03:00
Seed the classification policy with the editor listed as a source
This commit is contained in:
committed by
James Brunton
parent
595b9cbc85
commit
89428d6b81
+5
-1
@@ -18,6 +18,7 @@ import stirling.software.proprietary.policy.model.EditorConfig;
|
||||
import stirling.software.proprietary.policy.model.OutputSpec;
|
||||
import stirling.software.proprietary.policy.model.PipelineStep;
|
||||
import stirling.software.proprietary.policy.model.Policy;
|
||||
import stirling.software.proprietary.policy.source.EditorSource;
|
||||
import stirling.software.proprietary.policy.store.PolicyStore;
|
||||
import stirling.software.proprietary.security.repository.TeamRepository;
|
||||
import stirling.software.proprietary.security.service.TeamService;
|
||||
@@ -100,7 +101,10 @@ public class DefaultClassificationPolicySeeder {
|
||||
Map<String, Object> options = new HashMap<>();
|
||||
options.put("categoryId", CATEGORY);
|
||||
options.put("mode", "new_version");
|
||||
options.put("sources", List.of());
|
||||
// The portal wizard still offers the editor as a pickable source and re-derives editor
|
||||
// participation from what it finds selected, so leaving this empty would make an admin who
|
||||
// merely re-saves this policy switch classification off.
|
||||
options.put("sources", List.of(EditorSource.ID));
|
||||
options.put("scopeTypes", List.of());
|
||||
options.put("reviewerEmail", "");
|
||||
return new Policy(
|
||||
|
||||
+17
@@ -21,6 +21,7 @@ import stirling.software.proprietary.model.Team;
|
||||
import stirling.software.proprietary.model.TeamCreatedEvent;
|
||||
import stirling.software.proprietary.policy.model.OutputSpec;
|
||||
import stirling.software.proprietary.policy.model.Policy;
|
||||
import stirling.software.proprietary.policy.source.EditorSource;
|
||||
import stirling.software.proprietary.policy.store.PolicyStore;
|
||||
import stirling.software.proprietary.security.repository.TeamRepository;
|
||||
import stirling.software.proprietary.security.service.TeamService;
|
||||
@@ -73,6 +74,22 @@ class DefaultClassificationPolicySeederTest {
|
||||
.isEqualTo("/api/v1/ai/tools/classify-and-label");
|
||||
}
|
||||
|
||||
@Test
|
||||
void listsTheEditorAsASourceSoResavingInTheWizardCannotSwitchClassificationOff() {
|
||||
when(policyStore.findByTeam(7L)).thenReturn(List.of());
|
||||
|
||||
seeder().onTeamCreated(new TeamCreatedEvent(7L, "Acme"));
|
||||
|
||||
ArgumentCaptor<Policy> saved = ArgumentCaptor.forClass(Policy.class);
|
||||
verify(policyStore).save(saved.capture());
|
||||
Policy policy = saved.getValue();
|
||||
// The portal wizard hydrates its source picker from these options and re-derives editor
|
||||
// participation from the user's selection. An editor-run policy that does not list the
|
||||
// editor here comes back from the wizard switched off.
|
||||
assertThat(policy.editor().allowed()).isTrue();
|
||||
assertThat(policy.output().options().get("sources")).isEqualTo(List.of(EditorSource.ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotSeedWhenAClassificationPolicyAlreadyExists() {
|
||||
when(policyStore.findByTeam(7L)).thenReturn(List.of(classificationPolicy(7L)));
|
||||
|
||||
Reference in New Issue
Block a user