Skip to content

Commit

Permalink
Identify Tasks and Services based on their spelling
Browse files Browse the repository at this point in the history
- Use that a Task always starts in lower case, a Service does not
- Adjust test to cover this behaviour
  • Loading branch information
OliverStolzBO committed May 13, 2024
1 parent fb57ead commit f63e712
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
16 changes: 11 additions & 5 deletions client/src/code_visualization/element_creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,23 @@ const buildTreeStructure = (
// assign the colors
for (const container of containers) {
const containerLabel = container.label.toLowerCase();
if (containerLabel.includes('task')) {
container.fillColor = taskColor;
} else if (containerLabel.includes('condition')) {
if (containerLabel.includes('condition')) {
container.fillColor = conditionColor;
} else if (containerLabel.includes('parallel')) {
container.fillColor = parallelColor;
} else if (containerLabel.includes('loop')) {
container.fillColor = loopColor;
} else {
// service is the only remaining boxtype
container.fillColor = serviceColor;
// Tasks and Services may not include a keyword, differentiate by the first letter
const labelStart = container.label[0];
const labelStartLowercase = containerLabel[0];
if (labelStart == labelStartLowercase) {
// lower case -> Task
container.fillColor = taskColor;
} else {
// upper case -> Service
container.fillColor = serviceColor;
}
}
}
return containers;
Expand Down
2 changes: 1 addition & 1 deletion client/src/test/dot_files/simple_task_test.dot
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ call_tree:{
"children": [
{
"id": "28f29fd8-cb15-4ebc-9fc0-994c54c3ed80",
"name": "paintingTask",
"name": "painting",
"children": [
{
"id": "67681725-92ef-438d-90df-8a68a75c09e8",
Expand Down
15 changes: 9 additions & 6 deletions client/src/test/graph_element_creation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function checkDotfileSplitting(dotfileString, treeStructure) {

const paintingTask = treeStructure.children[0];
expect(paintingTask.children).toBeArrayOfSize(1);
expect(paintingTask.name).toBe('paintingTask');
expect(paintingTask.name).toBe('painting');

const painting = paintingTask.children[0];
expect(painting.children).toBeArrayOfSize(0);
Expand All @@ -129,22 +129,25 @@ function checkContainerCreation(dotfileString, treeStructure) {
expect(productionTask).toBeDefined();
expect(productionTask.level).toBe(0);
expect(productionTask.parentId).toBeNull();
expect(productionTask.fillColor).toBe('#000'); // predefined Task color
const productionTaskId = productionTask.id;

const paintingTask = containers.find(
(container) => container.label == 'paintingTask'
(container) => container.label == 'painting'
);
expect(paintingTask).toBeDefined();
expect(paintingTask.level).toBe(1);
expect(paintingTask.parentId).toBe(productionTaskId);
expect(paintingTask.fillColor).toBe('#000'); // predefined Task color
const paintingTaskId = paintingTask.id;

const painting = containers.find(
const paintingService = containers.find(
(container) => container.label == 'Painting'
);
expect(painting).toBeDefined();
expect(painting.level).toBe(2);
expect(painting.parentId).toBe(paintingTaskId);
expect(paintingService).toBeDefined();
expect(paintingService.level).toBe(2);
expect(paintingService.fillColor).toBe('#111'); // predefined Service color
expect(paintingService.parentId).toBe(paintingTaskId);
}

function checkElementCreation(dotfileString) {
Expand Down

0 comments on commit f63e712

Please sign in to comment.