Search in sources :

Example 6 with HTTPStubMapping

use of io.irontest.models.HTTPStubMapping in project irontest by zheng-wang.

the class TestcaseDAO method createByImport.

@Transaction
default long createByImport(Testcase testcase, long targetFolderId) throws JsonProcessingException {
    if (_nameExistsInFolder(testcase.getName(), targetFolderId)) {
        throw new RuntimeException("Duplicate test case name: " + testcase.getName());
    }
    // insert the test case record
    testcase.setParentFolderId(targetFolderId);
    long testcaseId = _insertWithName(testcase);
    // insert UDPs
    for (UserDefinedProperty udp : testcase.getUdps()) {
        udpDAO()._insertWithName(testcaseId, udp.getName(), udp.getValue());
    }
    // insert test steps
    for (Teststep teststep : testcase.getTeststeps()) {
        teststep.setTestcaseId(testcaseId);
        teststepDAO().insertByImport(teststep);
    }
    // insert data table
    dataTableDAO().insertByImport(testcaseId, testcase.getDataTable());
    // insert HTTP stubs
    for (HTTPStubMapping stub : testcase.getHttpStubMappings()) {
        httpStubMappingDAO().insertByImport(testcaseId, stub);
    }
    return testcaseId;
}
Also used : Teststep(io.irontest.models.teststep.Teststep) HTTPStubMapping(io.irontest.models.HTTPStubMapping) UserDefinedProperty(io.irontest.models.UserDefinedProperty) Transaction(org.jdbi.v3.sqlobject.transaction.Transaction)

Aggregations

HTTPStubMapping (io.irontest.models.HTTPStubMapping)6 StubMapping (com.github.tomakehurst.wiremock.stubbing.StubMapping)3 UserDefinedProperty (io.irontest.models.UserDefinedProperty)3 Teststep (io.irontest.models.teststep.Teststep)3 DataTable (io.irontest.models.DataTable)2 HTTPStubsSetupTeststepProperties (io.irontest.models.teststep.HTTPStubsSetupTeststepProperties)2 Transaction (org.jdbi.v3.sqlobject.transaction.Transaction)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)1 WireMock.matchingJsonPath (com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath)1 MapValueLookup (io.irontest.core.MapValueLookup)1 Testcase (io.irontest.models.Testcase)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 PermitAll (javax.annotation.security.PermitAll)1 StrSubstitutor (org.apache.commons.text.StrSubstitutor)1