Search in sources :

Example 1 with TestFolderReport

use of de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestFolderReport in project IPK-BrAPI-Validator by plantbreeding.

the class TestCollectionRunner method runTests.

/**
 * Runs the tests specified in the TestCollection config
 *
 * @return Test report.
 */
public TestCollectionReport runTests() {
    String name = testCollection.getInfo().getName();
    TestCollectionReport tcr = new TestCollectionReport(name, url);
    String baseUrl = url.replaceAll("/$", "");
    VariableStorage storage = new VariableStorage(baseUrl);
    List<Folder> folderList = testCollection.getItem();
    folderList.forEach(folder -> {
        TestFolderRunner tfr = new TestFolderRunner(baseUrl, folder, storage);
        TestFolderReport tfReport = tfr.runTests();
        tcr.addFolder(tfReport);
    });
    tcr.setVariables(storage);
    return tcr;
}
Also used : TestFolderReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestFolderReport) VariableStorage(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.VariableStorage) TestCollectionReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestCollectionReport) Folder(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.Folder)

Example 2 with TestFolderReport

use of de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestFolderReport in project IPK-BrAPI-Validator by plantbreeding.

the class TestFolderRunner method runTestsFromCall.

public TestFolderReport runTestsFromCall(List<String> doneTests) {
    TestFolderReport tcr = new TestFolderReport(this.baseUrl);
    tcr.setName(this.folder.getName());
    tcr.setDescription(this.folder.getDescription());
    List<String> inCalls = new ArrayList<String>();
    JsonNode calls = storage.getVariable("callResult");
    if (calls != null && calls.isArray()) {
        ObjectMapper mapper = new ObjectMapper();
        for (JsonNode call : calls) {
            inCalls.add("/" + mapper.convertValue(call.get("call"), String.class));
        }
    }
    LinkedHashMap<String, Object> folderTests = new LinkedHashMap<String, Object>();
    List<Item> itemList = this.folder.getItem();
    itemList.forEach(item -> {
        if (inCalls.contains(item.getEndpoint())) {
            if (storage.getKeys().containsAll(item.getRequires())) {
                TestItemRunner tir = new TestItemRunner(item, storage);
                TestItemReport tiReport = tir.runTests();
                tcr.addTestReport(tiReport);
                doneTests.add(item.getName());
                folderTests.put(item.getName(), tiReport);
            } else {
                folderTests.put(item.getName(), "missingReqs");
            }
        } else {
            folderTests.put(item.getName(), "skipped");
        }
    });
    tcr.setTestsShort(folderTests);
    return tcr;
}
Also used : TestFolderReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestFolderReport) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) LinkedHashMap(java.util.LinkedHashMap) Item(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.Item) TestItemReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestItemReport) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with TestFolderReport

use of de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestFolderReport in project IPK-BrAPI-Validator by plantbreeding.

the class TestCollectionRunner method runTestsFromCall.

public TestCollectionReport runTestsFromCall() {
    String name = testCollection.getInfo().getName();
    TestCollectionReport tcr = new TestCollectionReport(name, url);
    String baseUrl = url.replaceAll("/$", "");
    VariableStorage storage = new VariableStorage(baseUrl);
    List<Folder> folderList = testCollection.getItem();
    List<String> doneTests = new ArrayList<String>();
    for (int i = 0; i < folderList.size(); i++) {
        TestFolderRunner tfr = new TestFolderRunner(baseUrl, folderList.get(i), storage);
        TestFolderReport tfReport;
        if (i == 0) {
            tfReport = tfr.runTests(doneTests);
        } else {
            tfReport = tfr.runTestsFromCall(doneTests);
        }
        tcr.addFolder(tfReport);
    }
    ;
    tcr.setVariables(storage);
    return tcr;
}
Also used : TestFolderReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestFolderReport) VariableStorage(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.VariableStorage) ArrayList(java.util.ArrayList) TestCollectionReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestCollectionReport) Folder(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.Folder)

Example 4 with TestFolderReport

use of de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestFolderReport in project IPK-BrAPI-Validator by plantbreeding.

the class TestFolderRunner method runTests.

/**
 * Runs the tests specified in the Folder config
 * @param doneTests
 *
 * @return Test report.
 */
public TestFolderReport runTests(List<String> doneTests) {
    TestFolderReport tcr = new TestFolderReport(this.baseUrl);
    tcr.setName(this.folder.getName());
    tcr.setDescription(this.folder.getDescription());
    List<Item> itemList = this.folder.getItem();
    LinkedHashMap<String, Object> folderTests = new LinkedHashMap<String, Object>();
    itemList.forEach(item -> {
        TestItemRunner tir = new TestItemRunner(item, storage);
        TestItemReport tiReport = tir.runTests();
        tcr.addTestReport(tiReport);
        doneTests.add(item.getName());
        folderTests.put(item.getName(), tiReport);
    });
    tcr.setTestsShort(folderTests);
    return tcr;
}
Also used : Item(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.Item) TestItemReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestItemReport) TestFolderReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestFolderReport) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

TestFolderReport (de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestFolderReport)4 Folder (de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.Folder)2 Item (de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.Item)2 TestCollectionReport (de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestCollectionReport)2 TestItemReport (de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestItemReport)2 VariableStorage (de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.VariableStorage)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1