Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ public class AutomationPackageCollectionTestBase {
private final JavaAutomationPackageReader reader;

// To use a different source directory, override in subclass constructor
protected File sourceDirectory = new File("src/test/resources/testdata/ap1");
protected final File sourceDirectory;
protected File destinationDirectory;
protected Path expectedFilesPath = new File("src/test/resources/expected").toPath();
protected AutomationPackageYamlFragmentManager fragmentManager;
protected File resourcesDirectory;
protected ResourceManager resourceManager;

public AutomationPackageCollectionTestBase() {
this(new File("src/test/resources/testdata/ap1"));
}

public AutomationPackageCollectionTestBase(File sourceDirectory) {
this.sourceDirectory = sourceDirectory;
AutomationPackageSerializationRegistry serializationRegistry = new AutomationPackageSerializationRegistry();
AutomationPackageHookRegistry hookRegistry = new AutomationPackageHookRegistry();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public class AutomationPackageDataSourceCollectionTest extends AutomationPackage
private Collection<Plan> planCollection;

public AutomationPackageDataSourceCollectionTest() {
super();
sourceDirectory = new File("src/test/resources/testdata/ap-with-datasource");
super(new File("src/test/resources/testdata/ap-with-datasource"));
}

@Before
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (C) 2026, exense GmbH
*
* This file is part of STEP
*
* STEP is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* STEP is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with STEP. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package step.core.collections;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import step.automation.packages.AutomationPackageReadingException;
import step.core.plans.Plan;
import step.plans.parser.yaml.YamlPlan;

import java.io.File;
import java.io.IOException;
import java.util.Optional;
import java.util.Properties;

public class AutomationPackagePlanFieldOrderingTest extends AutomationPackageCollectionTestBase {

private Collection<Plan> planCollection;

public AutomationPackagePlanFieldOrderingTest() {
super(new File("src/test/resources/testdata/ap-field-ordering"));
}

@Before
public void setUp() throws IOException, AutomationPackageReadingException {
super.setUp();
AutomationPackageCollectionFactory collectionFactory = new AutomationPackageCollectionFactory(new Properties(), fragmentManager);
planCollection = collectionFactory.getCollection(YamlPlan.PLANS_ENTITY_NAME, Plan.class);
}

@Test
public void testPlanFieldOrdering() throws IOException {

Optional<Plan> optionalPlan = planCollection.find(Filters.equals("attributes.name", "FieldOrdering"), null, null, null, 100).findFirst();

Assert.assertTrue(optionalPlan.isPresent());

Plan plan = optionalPlan.get();
planCollection.save(plan);

assertFilesEqual(expectedFilesPath.resolve("FieldOrdering.yml"), destinationDirectory.toPath().resolve("plans").resolve("FieldOrdering.yml"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class AutomationPackageWithEmptyWildcardTest extends AutomationPackageCollectionTestBase {

public AutomationPackageWithEmptyWildcardTest() {
super.sourceDirectory = new File("src/test/resources/testdata/ap-with-empty-wildcard");
super(new File("src/test/resources/testdata/ap-with-empty-wildcard"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
plans:
- name: "FieldOrdering"
root:
testCase:
nodeName: "FieldOrdering"
instrumentNode: true
children:
- sequence:
nodeName: "Sequence - Sequence Name"
description: "Description"
skipNode: true
instrumentNode: true
continueParentNodeExecutionOnError: true
continueOnError: true
pacing: 5000
before:
continueOnError: false
steps:
- echo:
nodeName: "Echo - Init"
description: "Bla"
skipNode: true
instrumentNode: true
continueParentNodeExecutionOnError: true
text:
expression: "Test"
children:
- callKeyword:
nodeName: "Keyword call"
description: "Description"
keyword: "Keyword"
inputs:
- parameter: "Test"
instrumentNode: true
continueParentNodeExecutionOnError: true
remote: false
children:
- assert:
actual: "returnValue"
operator: "EQUALS"
doNegate: true
expected: "1"
customErrorMessage: "afda"
- switch:
nodeName: "Switch - switch"
description: "Description"
expression: "testd"
children:
- case:
value: "Bla"
- case:
value: "Blub"
- for:
nodeName: "For - Loop"
item: "a"
maxFailedLoops: 1
threads: 2
globalCounter: "c"
userItem: "b"
start: 0
end: 1
inc: 2
children:
- set:
nodeName: "Set - variable"
key: "variable"
value: "value"
after:
continueOnError: false
steps:
- echo:
nodeName: "Echo - After"
text: "After"
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ plans:
expression: "mySimpleKey"
- callKeyword:
nodeName: "CallMyKeyword2"
keyword: "MyKeyword2"
inputs:
- myInput: "myValue"
keyword: "MyKeyword2"
categories:
- "Yaml Plan"
plansPlainText:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ plans:
expression: "mySimpleKey"
- callKeyword:
nodeName: "CallMyKeyword2"
keyword: "MyKeyword2"
inputs:
- myInput: "myValue"
keyword: "MyKeyword2"
categories:
- "Yaml Plan"
- name: "New Name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ plans:
expression: "mySimpleKey"
- callKeyword:
nodeName: "CallMyKeyword2"
keyword: "MyKeyword2"
inputs:
- myInput: "myValue"
keyword: "MyKeyword2"
categories:
- "Yaml Plan"
plansPlainText:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
schemaVersion: 1.2.0
name: "YAML Field Ordering"
fragments:
- "keywords/*.yml"
- "plans/*.yml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
keywords:
- Composite:
name: "Keyword"
schema:
properties:
parameter:
type: "string"
required:
- "parameter"
routing: {}
plan:
root:
sequence: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
plans:
- name: "FieldOrdering"
root:
testCase:
nodeName: "FieldOrdering"
instrumentNode: true
children:
- sequence:
continueParentNodeExecutionOnError: true
description: "Description"
nodeName: "Sequence - Sequence Name"
instrumentNode: true
continueOnError: true
pacing: 5000
before:
continueOnError: false
steps:
- echo:
text:
expression: "Test"
nodeName: "Echo - Init"
description: "Bla"
skipNode: true
instrumentNode: true
continueParentNodeExecutionOnError: true
after:
continueOnError: false
steps:
- echo:
nodeName: "Echo - After"
text: "After"
children:
- callKeyword:
nodeName: "Keyword call"
description: "Description"
keyword: "Keyword"
inputs:
- parameter: "Test"
instrumentNode: true
children:
- assert:
actual: "returnValue"
operator: "EQUALS"
doNegate: true
expected: "1"
customErrorMessage: "afda"
- switch:
nodeName: "Switch - switch"
description: "Description"
expression: "testd"
children:
- case:
value: "Bla"
- case:
value: "Blub"
- for:
nodeName: "For - Loop"
item: "a"
threads: 2
userItem: "b"
start: 0
end: 1
inc: 2
children:
- set:
nodeName: "Set - variable"
key: "variable"
value: "value"
globalCounter: "c"
maxFailedLoops: 1
continueParentNodeExecutionOnError: true
remote: false
skipNode: true
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected <T extends AutomationPackageFragmentYaml> void logAfterRead(String pac
log.info("{} plan(s) found in automation package {}", res.getPlans().size(), StringUtils.defaultString(packageName));
}
if (!res.getPlansPlainText().isEmpty()) {
log.info("{} plain text plan(s) found in automation package {}", res.getPlans().size(), StringUtils.defaultString(packageName));
log.info("{} plain text plan(s) found in automation package {}", res.getPlansPlainText().size(), StringUtils.defaultString(packageName));
}
for (Map.Entry<String, PatchableYamlList<?>> additionalEntry : res.getAdditionalFields().entrySet()) {
log.info("{} {} found in automation package {}", additionalEntry.getValue().size(), additionalEntry.getKey(), StringUtils.defaultString(packageName));
Expand Down
Loading