waltz icon indicating copy to clipboard operation
waltz copied to clipboard

Data Generator - Physical Flow: Fails to generate sample Physical Flows

Open TL41 opened this issue 1 year ago • 0 comments

Description

I was trying to generate sample Physical Flows using PhysicalFlowGenerator called from LoadAll. I created logical flows and physical specifications successfully (following the natural progression laid out in 'LoadAll') but it was failing to create new Physical Flows records.

Upon tracing the steps, it seems to be related to the number generation here --> IntStream.range(0, logicalFlowIds.size() - 1)

logicalFlowIds.size() is coming in with a value of 1, but 'IntStream.range' has an exclusive upper-bound, so it doesn't generate anything to call .mapToObj against. [0, 0)

Further, 'nextInt(logicalFlowIds.size() - 1)' seems to be hit with the same exclusive upper bound issue.

I'm able to generate data if I remove the '- 1' from both lines. I'm not sure if this is a bug with this code or if it's an issue in that the sample Logical Flows are maybe getting created with just 1 side (i.e. Downstream but no Upstream)?

        return IntStream.range(0, logicalFlowIds.size() - 1)
                .mapToObj(i -> {
                    Long logicalFlowId = logicalFlowIds.remove(rnd.nextInt(logicalFlowIds.size() - 1));

                    PhysicalFlowRecord record = new PhysicalFlowRecord();
                    record.setSpecificationId(spec.id().get());
                    record.setLogicalFlowId(logicalFlowId);
                    record.setDescription("Description: " + spec + " - " + logicalFlowId.toString());
                    record.setProvenance(SAMPLE_DATA_PROVENANCE);
                    record.setBasisOffset(randomPick(newArrayList(0, 0, 0, 0, 1, 1, 2, -1)));
                    record.setTransport(randomPick(transportKinds));
                    record.setFrequency(randomPick("DAILY", "MONTHLY", "WEEKLY", "ON_DEMAND"));
                    record.setCriticality(randomPick(criticalityDistribution).name());
                    record.setEntityLifecycleStatus(randomPick(lifecycleStatusDistribution).name());
                    record.setLastUpdatedBy("admin");
                    record.setCreatedBy("admin");
                    record.setCreatedAt(nowUtcTimestamp());
                    return record;
                })

Waltz Version

1.56

Steps to Reproduce

  1. Generate sample Logical Flow Data
  2. Attempt to generate sample Physical Flow Data
  3. See that no Physical Flow data is generated ...

Expected Result

Physical Flow data is generated

Actual Result

No Physical Flow data is generated

TL41 avatar Jan 12 '24 04:01 TL41