Stabilize flow import tests for shared Spring context
This commit is contained in:
parent
8ff739703e
commit
9e107352ce
|
|
@ -43,6 +43,8 @@ public class FlowImportComponentTest {
|
|||
|
||||
@Test
|
||||
public void importFlowFromJsonFile() throws Exception {
|
||||
String owner = "import-user-" + UUID.randomUUID();
|
||||
String flowName = "Imported Flow " + UUID.randomUUID();
|
||||
FlowData flowData = FlowData.builder()
|
||||
.block(llmBlockFactory.create(LLMBlockConfiguration.builder()
|
||||
.name("imported-llm")
|
||||
|
|
@ -55,9 +57,9 @@ public class FlowImportComponentTest {
|
|||
.build();
|
||||
ImportedFlow importedFlow = new ImportedFlow(
|
||||
null,
|
||||
"Imported Flow",
|
||||
flowName,
|
||||
"Flow loaded from JSON",
|
||||
"testuser",
|
||||
owner,
|
||||
LocalDateTime.of(2026, 3, 1, 10, 0),
|
||||
LocalDateTime.of(2026, 3, 2, 11, 0),
|
||||
true,
|
||||
|
|
@ -73,19 +75,24 @@ public class FlowImportComponentTest {
|
|||
flowImportComponent.start();
|
||||
flowImportComponent.start();
|
||||
|
||||
FlowEntity saved = flowRepository.findByOwnerAndName("testuser", "Imported Flow").orElse(null);
|
||||
FlowEntity saved = flowRepository.findByOwnerAndName(owner, flowName).orElse(null);
|
||||
assertNotNull(saved);
|
||||
assertNotNull(saved.getId());
|
||||
assertEquals("Imported Flow", saved.getName());
|
||||
assertEquals("testuser", saved.getOwner());
|
||||
assertEquals(flowName, saved.getName());
|
||||
assertEquals(owner, saved.getOwner());
|
||||
assertTrue(saved.isPublished());
|
||||
assertNotNull(saved.getFlow());
|
||||
assertEquals(1, saved.getFlow().getBlocks().size());
|
||||
assertEquals(1, flowRepository.count());
|
||||
long matchingFlows = flowRepository.findByOwner(owner).stream()
|
||||
.filter(flow -> flowName.equals(flow.getName()))
|
||||
.count();
|
||||
assertEquals(1, matchingFlows);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importFlowWithIdUpdatesLegacyEntryWithoutDuplicatingIt() throws Exception {
|
||||
String owner = "legacy-import-user-" + UUID.randomUUID();
|
||||
String flowName = "Imported Flow " + UUID.randomUUID();
|
||||
FlowData originalFlow = FlowData.builder()
|
||||
.block(llmBlockFactory.create(LLMBlockConfiguration.builder()
|
||||
.name("legacy-llm")
|
||||
|
|
@ -97,15 +104,14 @@ public class FlowImportComponentTest {
|
|||
.build()))
|
||||
.build();
|
||||
FlowEntity legacyEntity = FlowEntity.builder()
|
||||
.id(UUID.randomUUID().toString())
|
||||
.name("Imported Flow")
|
||||
.name(flowName)
|
||||
.description("Legacy description")
|
||||
.owner("testuser")
|
||||
.owner(owner)
|
||||
.createdAt(LocalDateTime.of(2026, 3, 1, 10, 0))
|
||||
.lastUpdateAt(LocalDateTime.of(2026, 3, 1, 10, 0))
|
||||
.flow(originalFlow)
|
||||
.build();
|
||||
flowRepository.save(legacyEntity);
|
||||
FlowEntity persistedLegacyEntity = flowRepository.save(legacyEntity);
|
||||
|
||||
FlowData updatedFlow = FlowData.builder()
|
||||
.block(llmBlockFactory.create(LLMBlockConfiguration.builder()
|
||||
|
|
@ -119,9 +125,9 @@ public class FlowImportComponentTest {
|
|||
.build();
|
||||
ImportedFlow importedFlow = new ImportedFlow(
|
||||
"seed-flow-id",
|
||||
"Imported Flow",
|
||||
flowName,
|
||||
"Updated description",
|
||||
"testuser",
|
||||
owner,
|
||||
LocalDateTime.of(2026, 3, 1, 10, 0),
|
||||
LocalDateTime.of(2026, 3, 2, 11, 0),
|
||||
true,
|
||||
|
|
@ -136,11 +142,14 @@ public class FlowImportComponentTest {
|
|||
|
||||
flowImportComponent.start();
|
||||
|
||||
FlowEntity saved = flowRepository.findByOwnerAndName("testuser", "Imported Flow").orElse(null);
|
||||
FlowEntity saved = flowRepository.findByOwnerAndName(owner, flowName).orElse(null);
|
||||
assertNotNull(saved);
|
||||
assertEquals(legacyEntity.getId(), saved.getId());
|
||||
assertEquals(persistedLegacyEntity.getId(), saved.getId());
|
||||
assertEquals("Updated description", saved.getDescription());
|
||||
assertTrue(saved.isPublished());
|
||||
assertEquals(1, flowRepository.count());
|
||||
long matchingFlows = flowRepository.findByOwner(owner).stream()
|
||||
.filter(flow -> flowName.equals(flow.getName()))
|
||||
.count();
|
||||
assertEquals(1, matchingFlows);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue